Beispiel #1
0
        public override void Process(UponorResponseContainer values)
        {
            foreach ((int controller, int thermostat) in _systemDetails.GetAvailableThermostats())
            {
                string deviceId = HassUniqueIdBuilder.GetThermostatDeviceId(controller, thermostat);

                // Temperature
                ISensorContainer    sensor = HassMqttManager.GetSensor(deviceId, "temperature");
                MqttStateValueTopic sender = sensor.GetValueSender(HassTopicKind.State);

                if (values.TryGetValue(UponorObjects.Thermostat(UponorThermostats.RoomTemperature, controller, thermostat),
                                       UponorProperties.Value, out float floatVal))
                {
                    if (IsValid.Temperature(floatVal))
                    {
                        sender.Value = floatVal;
                    }
                    else
                    {
                        _logger.LogWarning("Received an invalid temperature of {Value} for {Device}", floatVal, deviceId);
                    }
                }
            }
        }
        public override void Process(UponorResponseContainer values)
        {
            foreach ((int controller, int thermostat) in _systemDetails.GetAvailableThermostats())
            {
                string deviceId = HassUniqueIdBuilder.GetThermostatDeviceId(controller, thermostat);

                // Temperature
                ISensorContainer sensor = HassMqttManager.GetSensor(deviceId, "temp");

                if (values.TryGetValue(
                        UponorObjects.Thermostat(UponorThermostats.RoomTemperature, controller, thermostat),
                        UponorProperties.Value, out float floatVal))
                {
                    if (IsValid.Temperature(floatVal))
                    {
                        sensor.SetValue(HassTopicKind.CurrentTemperature, floatVal);
                    }
                    else
                    {
                        _logger.LogWarning("Received an invalid temperature of {Value} for {Device}", floatVal, deviceId);
                    }
                }

                // Setpoint
                if (values.TryGetValue(
                        UponorObjects.Thermostat(UponorThermostats.RoomSetpoint, controller, thermostat),
                        UponorProperties.Value, out floatVal))
                {
                    sensor.SetValue(HassTopicKind.TemperatureState, floatVal);
                }

                // Action & Mode
                if (values.TryGetValue(
                        UponorObjects.Thermostat(UponorThermostats.RoomInDemand, controller, thermostat),
                        UponorProperties.Value, out int intVal))
                {
                    // If this value is >0, the room is heating/cooling (see H/C mode)
                    string action, mode;

                    // Valid values: off, heating, cooling, drying, idle, fan.
                    if (intVal <= 0)
                    {
                        action = "idle";
                        mode   = "off";
                    }
                    else if (_systemDetails.HcMode == HcMode.Heating)
                    {
                        action = "heating";
                        mode   = "heat";
                    }
                    else
                    {
                        action = "cooling";
                        mode   = "cool";
                    }

                    // Override Mode as auto
                    if (_operationConfig.OperationMode == OperationMode.Normal)
                    {
                        mode = "auto";
                    }

                    sensor.SetValue(HassTopicKind.Action, action);
                    sensor.SetValue(HassTopicKind.ModeState, mode);
                }

                // Home/away
                if (values.TryGetValue(
                        UponorObjects.Thermostat(UponorThermostats.HomeAwayModeStatus, controller, thermostat),
                        UponorProperties.Value, out intVal))
                {
                    if (intVal > 0)
                    {
                        // Away
                        sensor.SetValue(HassTopicKind.AwayModeState, "on");
                    }
                    else
                    {
                        // Home
                        sensor.SetValue(HassTopicKind.AwayModeState, "off");
                    }
                }
            }
        }