Exemple #1
0
        private void Omnilink_OnConnect(object sender, EventArgs e)
        {
            if (Global.verbose_area)
            {
                for (ushort i = 1; i <= omnilink.Controller.Areas.Count; i++)
                {
                    clsArea area = omnilink.Controller.Areas[i];

                    if (i > 1 && area.DefaultProperties == true)
                    {
                        continue;
                    }

                    string status = area.ModeText();

                    if (area.ExitTimer > 0)
                    {
                        status = "ARMING " + status;
                    }

                    if (area.EntryTimer > 0)
                    {
                        status = "TRIPPED " + status;
                    }

                    log.Verbose("Initial AreaStatus {id} {name}, Status: {status}, Alarms: {alarms}", i, area.Name, status, area.AreaAlarms);
                }
            }

            if (Global.verbose_zone)
            {
                for (ushort i = 1; i <= omnilink.Controller.Zones.Count; i++)
                {
                    clsZone zone = omnilink.Controller.Zones[i];

                    if (zone.DefaultProperties == true)
                    {
                        continue;
                    }

                    if (zone.IsTemperatureZone())
                    {
                        log.Verbose("Initial ZoneStatus {id} {name}, Temp: {temp}", i, zone.Name, zone.TempText());
                    }
                    else
                    {
                        log.Verbose("Initial ZoneStatus {id} {name}, Status: {status}", i, zone.Name, zone.StatusText());
                    }
                }
            }
        }
Exemple #2
0
        private void PublishZoneState(clsZone zone)
        {
            MqttClient.PublishAsync(zone.ToTopic(Topic.state), zone.ToState(), MqttQualityOfServiceLevel.AtMostOnce, true);
            MqttClient.PublishAsync(zone.ToTopic(Topic.basic_state), zone.ToBasicState(), MqttQualityOfServiceLevel.AtMostOnce, true);

            if (zone.IsTemperatureZone())
            {
                MqttClient.PublishAsync(zone.ToTopic(Topic.current_temperature), zone.TempText(), MqttQualityOfServiceLevel.AtMostOnce, true);
            }
            else if (zone.IsHumidityZone())
            {
                MqttClient.PublishAsync(zone.ToTopic(Topic.current_humidity), zone.TempText(), MqttQualityOfServiceLevel.AtMostOnce, true);
            }
        }
        private void PublishZoneState(clsZone zone)
        {
            PublishAsync(zone.ToTopic(Topic.state), zone.ToState());
            PublishAsync(zone.ToTopic(Topic.basic_state), zone.ToBasicState());

            if (zone.IsTemperatureZone())
            {
                PublishAsync(zone.ToTopic(Topic.current_temperature), zone.TempText());
            }
            else if (zone.IsHumidityZone())
            {
                PublishAsync(zone.ToTopic(Topic.current_humidity), zone.TempText());
            }
        }
        private void PublishZones()
        {
            log.Debug("Publishing {type}", "zones");

            for (ushort i = 1; i <= OmniLink.Controller.Zones.Count; i++)
            {
                clsZone zone = OmniLink.Controller.Zones[i];

                if (zone.DefaultProperties == true)
                {
                    PublishAsync(zone.ToTopic(Topic.name), null);
                }
                else
                {
                    PublishZoneState(zone);
                    PublishAsync(zone.ToTopic(Topic.name), zone.Name);
                }

                if (zone.DefaultProperties == true || Global.mqtt_discovery_ignore_zones.Contains(zone.Number))
                {
                    PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i}/config", null);
                    PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}/config", null);
                    PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/zone{i}/config", null);
                    PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}temp/config", null);
                    PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}humidity/config", null);
                    continue;
                }

                PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i}/config",
                             JsonConvert.SerializeObject(zone.ToConfig()));
                PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}/config",
                             JsonConvert.SerializeObject(zone.ToConfigSensor()));
                PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/zone{i}/config",
                             JsonConvert.SerializeObject(zone.ToConfigSwitch()));

                if (zone.IsTemperatureZone())
                {
                    PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}temp/config",
                                 JsonConvert.SerializeObject(zone.ToConfigTemp(OmniLink.Controller.TempFormat)));
                }
                else if (zone.IsHumidityZone())
                {
                    PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}humidity/config",
                                 JsonConvert.SerializeObject(zone.ToConfigHumidity()));
                }
            }
        }
Exemple #5
0
        public static ZoneContract ToContract(this clsZone zone)
        {
            ZoneContract ret = new ZoneContract();

            ret.id       = (ushort)zone.Number;
            ret.zonetype = zone.ZoneType;
            ret.name     = zone.Name;
            ret.status   = zone.StatusText();

            if (zone.IsTemperatureZone())
            {
                ret.temp = zone.TempText();
            }
            else if (zone.IsHumidityZone())
            {
                ret.temp = zone.TempText();
            }

            return(ret);
        }
Exemple #6
0
        public List <NameContract> ListZonesTemp()
        {
            log.Debug("ListZonesTemp");

            List <NameContract> names = new List <NameContract>();

            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++)
            {
                clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i];

                if (zone.IsTemperatureZone() && zone.DefaultProperties == false)
                {
                    names.Add(new NameContract()
                    {
                        id = i, name = zone.Name
                    });
                }
            }
            return(names);
        }
Exemple #7
0
        public List <NameContract> ListZonesTemp()
        {
            Event.WriteVerbose("WebService", "ListZonesTemp");

            List <NameContract> names = new List <NameContract>();

            for (ushort i = 1; i < WebService.HAC.Zones.Count; i++)
            {
                clsZone zone = WebService.HAC.Zones[i];

                if (zone.IsTemperatureZone() && zone.DefaultProperties == false)
                {
                    names.Add(new NameContract()
                    {
                        id = i, name = zone.Name
                    });
                }
            }
            return(names);
        }
Exemple #8
0
        private void PublishZones()
        {
            log.Debug("Publishing zones");

            for (ushort i = 1; i < OmniLink.Controller.Zones.Count; i++)
            {
                clsZone zone = OmniLink.Controller.Zones[i];

                if (zone.DefaultProperties == true || Global.mqtt_discovery_ignore_zones.Contains(zone.Number))
                {
                    MqttClient.PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i.ToString()}/config", null, MqttQualityOfServiceLevel.AtMostOnce, true);
                    MqttClient.PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i.ToString()}/config", null, MqttQualityOfServiceLevel.AtMostOnce, true);
                    MqttClient.PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i.ToString()}temp/config", null, MqttQualityOfServiceLevel.AtMostOnce, true);
                    MqttClient.PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i.ToString()}humidity/config", null, MqttQualityOfServiceLevel.AtMostOnce, true);
                    continue;
                }

                PublishZoneState(zone);

                MqttClient.PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i.ToString()}/config",
                                        JsonConvert.SerializeObject(zone.ToConfig()), MqttQualityOfServiceLevel.AtMostOnce, true);
                MqttClient.PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i.ToString()}/config",
                                        JsonConvert.SerializeObject(zone.ToConfigSensor()), MqttQualityOfServiceLevel.AtMostOnce, true);

                if (zone.IsTemperatureZone())
                {
                    MqttClient.PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i.ToString()}temp/config",
                                            JsonConvert.SerializeObject(zone.ToConfigTemp()), MqttQualityOfServiceLevel.AtMostOnce, true);
                }
                else if (zone.IsHumidityZone())
                {
                    MqttClient.PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i.ToString()}humidity/config",
                                            JsonConvert.SerializeObject(zone.ToConfigHumidity()), MqttQualityOfServiceLevel.AtMostOnce, true);
                }
            }
        }