コード例 #1
0
        public void Register()
        {
            Scheduler.PageBuilderAndMenu.clsPageBuilder pageToRegister;

            _hs.RegisterPage(_pageName, Utility.PluginName, Utility.InstanceFriendlyName);

            var linkText = _pageName;

            linkText = linkText.Replace("MelCloud_", "").Replace("_", " ").Replace(Utility.PluginName, "");
            var pageTitle = linkText;

            var wpd = new WebPageDesc
            {
                link       = _pageName,
                plugInName = Utility.PluginName
            };

            _callback.RegisterConfigLink(wpd);

            var webPageDescription = new WebPageDesc
            {
                plugInName = Utility.PluginName,
                link       = _pageName,
                linktext   = pageTitle,
                page_title = pageTitle
            };

            _hs.RegisterPage(_pageName, Utility.PluginName, string.Empty);
            _callback.RegisterLink(webPageDescription);
        }
コード例 #2
0
        private IConfigPage CreateConfigPage(string pageName)
        {
            Scheduler.PageBuilderAndMenu.clsPageBuilder pageToRegister;
            switch (pageName)
            {
            case MelcloudGeneralConfig:
                pageToRegister = new GeneralConfig(pageName, _hs, _callbackApi, _iniSettings, _log);
                break;

            case MelcloudAbout:
                pageToRegister = new AboutPage(pageName, _hs);
                break;

            default: throw new NotImplementedException($"Page {pageName} is not implemented");
            }

            _hs.RegisterPage(pageName, Utility.PluginName, Utility.InstanceFriendlyName);

            var linkText = pageName;

            linkText = linkText.Replace("RFLink_", "").Replace("_", " ").Replace(Utility.PluginName, "");
            var pageTitle = linkText;

            var webPageDescription = new WebPageDesc
            {
                plugInName = Utility.PluginName,
                link       = pageName + Utility.InstanceFriendlyName,
                linktext   = pageTitle,
                page_title = pageTitle + Utility.InstanceFriendlyName
            };

            _callbackApi.RegisterLink(webPageDescription);
            return((IConfigPage)pageToRegister);
        }
コード例 #3
0
        private void RegisterPlugin()
        {
            var wpd = new WebPageDesc
            {
                link       = MelcloudGeneralConfig,
                plugInName = Utility.PluginName
            };

            _callbackApi.RegisterConfigLink(wpd);
        }
コード例 #4
0
        public override string InitIO(string port)
        {
            Program.WriteLog(LogType.Verbose, "InitIO");

            bool ignoreCertificateLegacy = hs.GetINISetting("Config", "ignore_invalid_certificates", "0", IniFilename) == "1";

            if (ignoreCertificateLegacy)
            {
                hs.SaveINISetting("Config", "ignore_invalid_certificates", "", IniFilename);
            }

            for (byte i = 1; i <= TOTAL_WEBHOOK_SLOTS; i++)
            {
                if (ignoreCertificateLegacy)
                {
                    hs.SaveINISetting("IgnoreCertificate", "webhook" + i, "1", IniFilename);
                }

                string url = hs.GetINISetting("Config", "webhook_endpoint" + (i == 1 ? "" : i.ToString()), "", IniFilename);
                bool   ignoreCertificate = hs.GetINISetting("IgnoreCertificate", "webhook" + i, "0", IniFilename) == "1";
                webHooks[i - 1] = url.Length > 0
                                        ? new WebHook(url)
                {
                    CheckServerCertificate = !ignoreCertificate
                }
                                        : null;
            }

            ignoreTimerEvents     = hs.GetINISetting("Config", "ignore_timer_events", "0", IniFilename) == "1";
            ignoreUnchangedEvents = hs.GetINISetting("Config", "ignore_unchanged_events", "0", IniFilename) == "1";
            _updateIgnoredDeviceRefs();

            callbacks.RegisterEventCB(Enums.HSEvent.VALUE_SET, Name, InstanceFriendlyName());
            callbacks.RegisterEventCB(Enums.HSEvent.VALUE_CHANGE, Name, InstanceFriendlyName());
            callbacks.RegisterEventCB(Enums.HSEvent.STRING_CHANGE, Name, InstanceFriendlyName());

            // Config page
            hs.RegisterPage("WebHookNotificationConfig", Name, InstanceFriendlyName());
            WebPageDesc configLink = new WebPageDesc {
                plugInName     = Name,
                plugInInstance = InstanceFriendlyName(),
                link           = "WebHookNotificationConfig",
                linktext       = "Settings",
                order          = 1,
                page_title     = "WebHook Notifications Settings"
            };

            callbacks.RegisterConfigLink(configLink);
            callbacks.RegisterLink(configLink);

            return("");
        }
コード例 #5
0
ファイル: MainConfig.cs プロジェクト: oesolberg/DataCurveSeer
        public void RegisterConfigs()
        {
            var wpd = new WebPageDesc
            {
                link       = _dataCurveGeneralConfig,
                plugInName = Utility.PluginName
            };

            _callback.RegisterConfigLink(wpd);

            if (_configPages == null)
            {
                _configPages = new List <IConfigPage>();
            }
            _configPages.Add(CreateConfigPage(_dataCurveGeneralConfig));
            _configPages.Add(CreateConfigPage(_dataCurveAboutConfig));
        }
コード例 #6
0
        ///<summary>
        /// Registers the web page in HomeSeer
        ///</summary>
        ///<param name="linktext">The text to be shown</param>
        ///<param name="link">A short link to the page</param>
        ///<param name="page_title">The title of the page when loaded</param>
        /// <param name="config">RegisterConfigLink for "manage Interfaces" page</param>
        public void RegisterWebPageDesc(string linktext, string link, string page_title, bool config = false, bool helplink = false)
        {
            // Register page
            if (!helplink)
            {
                string err = HS.RegisterPage(link, this.Name, PluginInstance: "");
                if (!String.IsNullOrEmpty(err))
                {
                    Console.WriteLine($"RegisterPage: {link} - {err}");
                }
            }

            // Register callback
            //try
            {
                WebPageDesc wpd = new WebPageDesc
                {
                    plugInName = (config || helplink) ? this.Name : this.PluginNameCleaned,
                    link       = link,
                    linktext   = linktext,
                    page_title = page_title
                };

                if (helplink)
                {
                    // Link for Help Menu
                    HS.RegisterHelpLink(wpd);
                }
                else if (config)
                {
                    // Link for "Manage Plugins" page
                    Callback.RegisterConfigLink(wpd);
                }
                else
                {
                    // Link for Plugins Menu
                    Callback.RegisterLink(wpd);
                }
            }
            //catch (Exception ex)
            //{
            //    Console.WriteLine("Registering Web Links (RegisterWebPage): " + ex.Message);
            //}
        }
コード例 #7
0
ファイル: HSPI.cs プロジェクト: lulzzz/HS3_EnOcean_Plugin
        public string InitIO(string port)
        {
            Console.WriteLine("InitIO called!");
            Thread.Sleep(5000);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");

            mCore = new EnOceanManager(hsHost, hsHostCB, this);
            mCore.Initialize();
            hsHostCB.RegisterEventCB(Enums.HSEvent.CONFIG_CHANGE, Name, "");
            //hsHostCB.RegisterEventCB(Enums.HSEvent.LOG, Name, "");
            hsHostCB.RegisterEventCB(Enums.HSEvent.SETUP_CHANGE, Name, "");
            //hsHostCB.RegisterEventCB(Enums.HSEvent.STRING_CHANGE, Name, "");
            hsHostCB.RegisterEventCB(Enums.HSEvent.GENERIC, Name, "");

            this.mPageBuilder = new PageBuilder(hsHost, hsHostCB, this, mCore);

            hsHost.RegisterPage(Constants.PLUGIN_STRING_ID, Name, "");
            hsHost.RegisterPage(Constants.PLUGIN_STRING_ID + "_Interfaces", Name, "");

            WebPageDesc wpd = new WebPageDesc();

            wpd.link       = Constants.PLUGIN_STRING_ID;
            wpd.linktext   = "Configuration";
            wpd.page_title = "Configuration";
            wpd.plugInName = Name;
            hsHostCB.RegisterLink(wpd);
            hsHostCB.RegisterConfigLink(wpd);

            WebPageDesc wpi = new WebPageDesc();

            wpi.link       = Constants.PLUGIN_STRING_ID + "_Interfaces";
            wpi.linktext   = "Interfaces";
            wpi.page_title = "Interfaces";
            wpi.plugInName = Name;
            hsHostCB.RegisterLink(wpi);

            Console.WriteLine("INIT IO complete");
            return(""); // empty == OK
        }
コード例 #8
0
ファイル: MainConfig.cs プロジェクト: oesolberg/DataCurveSeer
        private IConfigPage CreateConfigPage(string pageName)
        {
            Scheduler.PageBuilderAndMenu.clsPageBuilder pageToRegister;
            var pageNameWithoutStart = pageName.Replace(Utility.PluginName, "");

            switch (pageNameWithoutStart)
            {
            case GeneralConfig:
                pageToRegister = new ConfigGeneral(pageName, _hs, _iniSettings, _logging, _mainPlugin);
                break;

            case AboutConfig:
                pageToRegister = new ConfigAbout(pageName, _hs, _iniSettings, _logging);
                break;

            default: throw new NotImplementedException($"Page {pageName} is not implemented");
            }

            _hs.RegisterPage(pageName, Utility.PluginName, Utility.InstanceFriendlyName);

            var linkText = pageName;

            linkText = linkText.Replace("GCalSeer_", "").Replace("_", " ").Replace(Utility.PluginName, "");
            var pageTitle = linkText;

            var webPageDescription = new WebPageDesc
            {
                plugInName = Utility.PluginName,
                link       = pageName + Utility.InstanceFriendlyName,
                linktext   = pageTitle,
                page_title = pageTitle + Utility.InstanceFriendlyName
            };

            _callback.RegisterLink(webPageDescription);
            return((IConfigPage)pageToRegister);
        }
コード例 #9
0
        public override string InitIO(string port)
        {
            // debug
            HS.WriteLog(Name, "Entering InitIO");

            // initialise everything here, return a blank string only if successful, or an error message

            var _port = HS.GetINISetting("Config", "Port", "8080", IniFilename);


            // Configure events for when values change
            Callback.RegisterEventCB(Enums.HSEvent.VALUE_SET, PLUGIN_NAME, "");
            Callback.RegisterEventCB(Enums.HSEvent.VALUE_CHANGE, PLUGIN_NAME, "");
            Callback.RegisterEventCB(Enums.HSEvent.STRING_CHANGE, PLUGIN_NAME, "");

            HS.RegisterPage("WebSocketNotificationConfig", Name, "");

            WebPageDesc configLink = new WebPageDesc
            {
                plugInName     = Name,
                plugInInstance = "",
                link           = "WebSocketNotificationConfig",
                linktext       = "Config",
                order          = 1,
                page_title     = "WebSockets Notifications Settings"
            };

            Callback.RegisterConfigLink(configLink);
            Callback.RegisterLink(configLink);

            WebSocketServer.Start("http://localhost:" + _port + "/");

            // debug
            HS.WriteLog(Name, "Completed InitIO");
            return("");
        }
コード例 #10
0
        public string InitIO(string port)       //Init plugin
        {
            dayOfYear = DateTime.Now.DayOfYear; //delays the first reset to the next day,  kind of an iffy solution

            Console.WriteLine("InitIO called with parameter port as " + port);

            string[] plugins = Util.hs.GetPluginsList();
            Util.gEXEPath = Util.hs.GetAppPath();

            try
            {
                // create our jquery web page

                //  if (pluginpage == null)
                {
                    pluginpage = new OptionsPage(WebPageName);
                    // register the page with the HS web server, HS will post back to the WebPage class
                    // "pluginpage" is the URL to access this page
                    // comment this out if you are going to use the GenPage/PutPage API istead
                    if (string.IsNullOrEmpty(Util.Instance))
                    {
                        Util.hs.RegisterPage(Util.IFACE_NAME, Util.IFACE_NAME, Util.Instance);
                    }
                    else
                    {
                        Util.hs.RegisterPage(Util.IFACE_NAME + Util.Instance, Util.IFACE_NAME, Util.Instance);
                    }
                    Console.WriteLine("Creates options page...");
                }
                WebPageDesc wpd = new WebPageDesc();
                // create test page


                // register a normal page to appear in the HomeSeer menu

                wpd.link = Util.IFACE_NAME + Util.Instance;
                if (!string.IsNullOrEmpty(Util.Instance))
                {
                    wpd.linktext = Util.IFACE_NAME + " Page instance " + Util.Instance;
                }
                else
                {
                    wpd.linktext = Util.IFACE_NAME + " Status/Options";
                }
                wpd.page_title     = Util.IFACE_NAME + " Status/Options";
                wpd.plugInName     = Util.IFACE_NAME;
                wpd.plugInInstance = Util.Instance;


                Util.callback.RegisterLink(wpd);
                Util.callback.RegisterGenericEventCB("sample_type", Util.IFACE_NAME, "");



                Util.Log("InitIO called, plug-in is being initialized...", Util.LogType.LOG_TYPE_INFO);



                // register for events from homeseer if a device changes value
                Util.callback.RegisterEventCB(Enums.HSEvent.VALUE_CHANGE, Util.IFACE_NAME, "");


                start_test_timer();

                //Util.hs.SaveINISetting("Settings", "test", null, "hspi_HSTouch.ini");

                // example of how to save a file to the HS images folder, mainly for use by plugins that are running remotely, album art, etc.
                //SaveImageFileToHS(gEXEPath & "\html\images\browser.png", "sample\browser.png")//TODO look here
                //SaveFileToHS(gEXEPath & "\html\images\browser.png", "sample\browser.png")
            }
            catch (Exception ex)
            {
                bShutDown = true;
                return("Error on InitIO: " + ex.Message);
            }

            bShutDown = false;
            return("");
            // return no error, or an error message
        }
コード例 #11
0
ファイル: hspi.cs プロジェクト: geoffreypietz/SIID_Plugin
        public string InitIO(string port)
        {
            Console.WriteLine("InitIO called with parameter port as " + port);
            Instance = Program.AllInstances[InstanceFriendlyName()];
            string[] plugins = Instance.host.GetPluginsList();


            try {
                Instance.siidPage.LoadINISettings();
                Console.WriteLine("Instance " + Instance.name);

                //All may not be needed or used, is for ajax callbacks
                //Instance.host.RegisterPage(MainSiidPageName, Util.IFACE_NAME, "");
                //Instance.host.RegisterPage("SIIDPage" + Instance.name, Util.IFACE_NAME,"");
                // Instance.host.RegisterPage("SIIDPage" + Instance.name, "", Instance.name);

                //Instance.host.RegisterPage("SIIDPage" + Instance.name, Util.IFACE_NAME, Instance.name); //Necessary to do the GetPagePlugin  Want also for postbackproc
                //Doesn't seem to work for multiple instances for postback
                Instance.host.RegisterPage(Util.IFACE_NAME, Util.IFACE_NAME, Instance.name);
                Instance.host.RegisterPage("ModBus", Util.IFACE_NAME, Instance.name);                                                                                                                                                                       //  Console.WriteLine(MainSiidPageName + "  " + Util.IFACE_NAME+"  "+ Instance.name);

                Instance.host.RegisterPage("Scratch", Util.IFACE_NAME, Instance.name);


                Instance.host.RegisterPage("ModbusDevicePage", Util.IFACE_NAME, Instance.name);  //MODBUS specifc ajax callback.  used in the PostBackPlugin switch area

//FigureOut These ones
                Instance.host.RegisterPage("AddModbusGate", Util.IFACE_NAME, Instance.name);
                Instance.host.RegisterPage("ModBusGateTab", Util.IFACE_NAME, Instance.name);
                Instance.host.RegisterPage("ModBusDevTab", Util.IFACE_NAME, Instance.name);
                Instance.host.RegisterPage("AddModbusDevice", Util.IFACE_NAME, Instance.name);


                //Instance.host.RegisterPage("BACnet", Util.IFACE_NAME, Instance.name); //Ajax calls from BACnet builder
                //Instance.host.RegisterPage("discoverBACnetDevices", Util.IFACE_NAME, Instance.name);//Redirect from the Gobutton for discoverBACnetDevices
                //Instance.host.RegisterPage("addBACnetDevice", Util.IFACE_NAME, Instance.name);

                Instance.host.RegisterPage(BACnetDataService.BaseUrl, Util.IFACE_NAME, Instance.name);
                Instance.host.RegisterPage(BACnetDevices.BaseUrl, Util.IFACE_NAME, Instance.name);
                Instance.host.RegisterPage(BACnetHomeSeerDevices.BaseUrl, Util.IFACE_NAME, Instance.name);
                //so don't register page with the instance ajax name.  But the request URL's need it in order for it to be routed to the correct plugin instance



                //Instance.host.RegisterPage(Instance.bacnetDataService.PageName, Util.IFACE_NAME, Instance.name);
                //Instance.host.RegisterPage(Instance.bacnetDevices.PageName, Util.IFACE_NAME, Instance.name);
                //Instance.host.RegisterPage(Instance.bacnetHomeSeerDevices.PageName, Util.IFACE_NAME, Instance.name);


                //Instance.host.RegisterPage(BACnetDataService.BaseUrl + Instance.ajaxName.Replace(":", "_"), Util.IFACE_NAME, Instance.name);
                //Instance.host.RegisterPage(BACnetDevices.BaseUrl + Instance.ajaxName.Replace(":", "_"), Util.IFACE_NAME, Instance.name);
                //Instance.host.RegisterPage(BACnetHomeSeerDevices.BaseUrl + Instance.ajaxName.Replace(":", "_"), Util.IFACE_NAME, Instance.name);



                //Instance.host.RegisterPage("BACnetDataService", Util.IFACE_NAME, Instance.name);
                //Instance.host.RegisterPage("BACnetDevices", Util.IFACE_NAME, Instance.name);
                //Instance.host.RegisterPage("BACnetHomeSeerDevices", Util.IFACE_NAME, Instance.name);



                //Instance.host.RegisterPage("BACnetHomeSeerDevicesEdit", Util.IFACE_NAME, Instance.name);


                Instance.host.RegisterPage("file", Util.IFACE_NAME, Instance.name);


                //Figure out these ones

                // Instance.host.RegisterPage(MainSiidPageName+"SIIDConfPage", Util.IFACE_NAME, Instance.name); //Need unique pagenames for each instance?
                //     Console.WriteLine(MainSiidPageName + "SIIDConfPage");

                // register a normal page to appear in the HomeSeer menu
                WebPageDesc wpd = new WebPageDesc();
                wpd.link = Util.IFACE_NAME;



                if (!string.IsNullOrEmpty(Instance.name))
                {
                    wpd.linktext = Util.IFACE_NAME + " main page instance " + Instance.name;
                }
                else
                {
                    wpd.linktext = Util.IFACE_NAME + " main page";
                }
                wpd.page_title     = Util.IFACE_NAME + Instance.name;
                wpd.plugInName     = Util.IFACE_NAME;
                wpd.plugInInstance = Instance.name;
                Instance.callback.RegisterLink(wpd); //THis page used in the GenPagePlugin function.  Returns our webpage when the address goes to the one we registered



                wpd = new WebPageDesc();

                if (!string.IsNullOrEmpty(Instance.name))
                {
                    wpd.link     = Util.IFACE_NAME;// + "?instance=" + Instance.name;
                    wpd.linktext = Util.IFACE_NAME + " main page instance " + Instance.name;
                }
                else
                {
                    wpd.link     = Util.IFACE_NAME;
                    wpd.linktext = Util.IFACE_NAME + "  main page";
                }
                wpd.page_title     = Util.IFACE_NAME + Instance.name;
                wpd.plugInName     = Util.IFACE_NAME;
                wpd.plugInInstance = Instance.name;

                Instance.callback.RegisterConfigLink(wpd); //Looks like the plugin config link doesn't go to specific instances



                Instance.host.WriteLog(Util.IFACE_NAME, "InitIO called, plug-in is being initialized...");
            }
            catch (Exception ex)
            {
                bShutDown = true;
                return("Error on InitIO: " + ex.Message);
            }

            bShutDown = false;
            return("");
            // return no error, or an error message
        }
コード例 #12
0
        public override string InitIO(string port)
        {
            Program.WriteLog(LogType.Verbose, "InitIO");

            dimmersByRef          = new Dictionary <int, DimmerDevice>();
            haveDoneInitialUpdate = false;

            Dictionary <byte, DimmerDevice> dict       = new Dictionary <byte, DimmerDevice>();
            clsDeviceEnumeration            enumerator = (clsDeviceEnumeration)hs.GetDeviceEnumerator();

            do
            {
                DeviceClass device = enumerator.GetNext();
                if (device != null)
                {
                    if (device.get_Interface(hs) != "Z-Wave")
                    {
                        continue;
                    }

                    // It's a Z-Wave device
                    PlugExtraData.clsPlugExtraData extraData = device.get_PlugExtraData_Get(hs);
                    string[] addressParts = device.get_Address(hs).Split('-');
                    byte     nodeId       = byte.Parse(addressParts[1]);
                    if (dict.ContainsKey(nodeId))
                    {
                        continue;
                    }

                    if (DeviceIsDimmer(extraData))
                    {
                        DimmerDevice dimmerDevice = new DimmerDevice {
                            HomeID = addressParts[0],
                            NodeID = nodeId,
                            SwitchMultiLevelDeviceRef = device.get_Ref(hs)
                        };

                        dict[nodeId] = dimmerDevice;
                        dimmersByRef[dimmerDevice.SwitchMultiLevelDeviceRef] = dimmerDevice;
                    }
                }
            } while (!enumerator.Finished);

            callbacks.RegisterEventCB(HomeSeerAPI.Enums.HSEvent.VALUE_SET, Name, InstanceFriendlyName());
            callbacks.RegisterEventCB(HomeSeerAPI.Enums.HSEvent.VALUE_CHANGE, Name, InstanceFriendlyName());

            hs.RegisterPage("IdleLightColorsSettings", Name, InstanceFriendlyName());
            WebPageDesc configLink = new WebPageDesc {
                plugInName     = Name,
                link           = "IdleLightColorsSettings",
                linktext       = "Settings",
                order          = 1,
                page_title     = "HS-WD200+ Idle Light Colors Settings",
                plugInInstance = InstanceFriendlyName()
            };

            callbacks.RegisterConfigLink(configLink);
            callbacks.RegisterLink(configLink);

            offColor = (WD200NormalModeColor)int.Parse(hs.GetINISetting("Colors", "idle_color",
                                                                        ((int)WD200NormalModeColor.Blue).ToString(), IniFilename));
            onColor = (WD200NormalModeColor)int.Parse(hs.GetINISetting("Colors", "active_color",
                                                                       ((int)WD200NormalModeColor.White).ToString(), IniFilename));

            Program.WriteLog(LogType.Info, string.Format(
                                 "Init complete. Active color: {0}. Idle color: {1}. Found {2} dimmers with node IDs: {3}",
                                 onColor,
                                 offColor,
                                 dimmersByRef.Keys.Count,
                                 string.Join(", ", dimmersByRef.Values.Select(dimmerDevice => dimmerDevice.NodeID))
                                 ));

            return("");
        }