예제 #1
0
        public static Climate ToConfig(this clsThermostat thermostat, enuTempFormat format)
        {
            Climate ret = new Climate();

            if (format == enuTempFormat.Celsius)
            {
                ret.min_temp = "7";
                ret.max_temp = "35";
            }

            ret.unique_id = $"{Global.mqtt_prefix}thermostat{thermostat.Number.ToString()}";
            ret.name      = Global.mqtt_discovery_name_prefix + thermostat.Name;
            ret.current_temperature_topic = thermostat.ToTopic(Topic.current_temperature);

            ret.temperature_low_state_topic   = thermostat.ToTopic(Topic.temperature_heat_state);
            ret.temperature_low_command_topic = thermostat.ToTopic(Topic.temperature_heat_command);

            ret.temperature_high_state_topic   = thermostat.ToTopic(Topic.temperature_cool_state);
            ret.temperature_high_command_topic = thermostat.ToTopic(Topic.temperature_cool_command);

            ret.mode_state_topic   = thermostat.ToTopic(Topic.mode_state);
            ret.mode_command_topic = thermostat.ToTopic(Topic.mode_command);

            ret.fan_mode_state_topic   = thermostat.ToTopic(Topic.fan_mode_state);
            ret.fan_mode_command_topic = thermostat.ToTopic(Topic.fan_mode_command);

            ret.hold_state_topic   = thermostat.ToTopic(Topic.hold_state);
            ret.hold_command_topic = thermostat.ToTopic(Topic.hold_command);
            return(ret);
        }
예제 #2
0
        public static Sensor ToConfigTemp(this clsThermostat thermostat, enuTempFormat format)
        {
            Sensor ret = new Sensor();

            ret.unique_id           = $"{Global.mqtt_prefix}thermostat{thermostat.Number.ToString()}temp";
            ret.name                = $"{Global.mqtt_discovery_name_prefix}{thermostat.Name} Temp";
            ret.device_class        = Sensor.DeviceClass.temperature;
            ret.state_topic         = thermostat.ToTopic(Topic.current_temperature);
            ret.unit_of_measurement = (format == enuTempFormat.Fahrenheit ? "°F" : "°C");
            return(ret);
        }