Пример #1
0
        public static BinarySensor ToConfigBurglary(this clsArea area)
        {
            BinarySensor ret = new BinarySensor();

            ret.name           = $"{Global.mqtt_discovery_name_prefix}{area.Name} Burglary";
            ret.device_class   = BinarySensor.DeviceClass.safety;
            ret.state_topic    = area.ToTopic(Topic.json_state);
            ret.value_template = "{% if value_json.burglary_alarm %} ON {%- else -%} OFF {%- endif %}";
            return(ret);
        }
Пример #2
0
        public static BinarySensor ToConfigTemp(this clsArea area)
        {
            BinarySensor ret = new BinarySensor();

            ret.unique_id      = $"{Global.mqtt_prefix}area{area.Number.ToString()}temp";
            ret.name           = $"{Global.mqtt_discovery_name_prefix}{area.Name} Temp";
            ret.device_class   = BinarySensor.DeviceClass.heat;
            ret.state_topic    = area.ToTopic(Topic.json_state);
            ret.value_template = "{% if value_json.temperature_alarm %} ON {%- else -%} OFF {%- endif %}";
            return(ret);
        }
Пример #3
0
        public static BinarySensor ToConfig(this clsZone zone)
        {
            BinarySensor ret = new BinarySensor();

            ret.unique_id = $"{Global.mqtt_prefix}zone{zone.Number.ToString()}binary";
            ret.name      = Global.mqtt_discovery_name_prefix + zone.Name;

            Global.mqtt_discovery_override_zone.TryGetValue(zone.Number, out OverrideZone override_zone);

            if (override_zone != null)
            {
                ret.device_class = override_zone.device_class;
            }
            else
            {
                switch (zone.ZoneType)
                {
                case enuZoneType.EntryExit:
                case enuZoneType.X2EntryDelay:
                case enuZoneType.X4EntryDelay:
                    ret.device_class = BinarySensor.DeviceClass.door;
                    break;

                case enuZoneType.Perimeter:
                    ret.device_class = BinarySensor.DeviceClass.window;
                    break;

                case enuZoneType.Tamper:
                    ret.device_class = BinarySensor.DeviceClass.problem;
                    break;

                case enuZoneType.AwayInt:
                case enuZoneType.NightInt:
                    ret.device_class = BinarySensor.DeviceClass.motion;
                    break;

                case enuZoneType.Water:
                    ret.device_class = BinarySensor.DeviceClass.moisture;
                    break;

                case enuZoneType.Fire:
                    ret.device_class = BinarySensor.DeviceClass.smoke;
                    break;

                case enuZoneType.Gas:
                    ret.device_class = BinarySensor.DeviceClass.gas;
                    break;
                }
            }

            ret.state_topic = zone.ToTopic(Topic.basic_state);
            return(ret);
        }