From 53128a12558f0794ab1658b5d2b136b693b9fdb2 Mon Sep 17 00:00:00 2001 From: gus8313 Date: Sat, 2 Jan 2021 18:15:29 +0100 Subject: [PATCH] Improve heaters display --- boiler.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/boiler.py b/boiler.py index c51fee6..22fcc6c 100644 --- a/boiler.py +++ b/boiler.py @@ -12,8 +12,8 @@ current_temperature_topic = "climate/tydom/{id}/temperature" mode_state_topic = "climate/tydom/{id}/hvacMode" mode_command_topic = "climate/tydom/{id}/set_hvacMode" -swing_mode_state_topic = "climate/tydom/{id}/thermicLevel" -swing_mode_command_topic = "climate/tydom/{id}/set_thermicLevel" +hold_state_topic = "climate/tydom/{id}/thermicLevel" +hold_command_topic = "climate/tydom/{id}/set_thermicLevel" out_temperature_state_topic = "sensor/tydom/{id}/temperature" #temperature = current_temperature_topic @@ -80,9 +80,9 @@ async def setup(self): self.config['modes'] = ["off", "heat"] self.config['mode_state_topic'] = mode_state_topic.format(id=self.id) self.config['mode_command_topic'] = mode_command_topic.format(id=self.id) - self.config['swing_modes'] = ["STOP","ANTI_FROST","ECO","COMFORT"] - self.config['swing_mode_state_topic'] = swing_mode_state_topic.format(id=self.id) - self.config['swing_mode_command_topic'] = swing_mode_command_topic.format(id=self.id) + self.config['hold_modes'] = ["STOP","ANTI_FROST","ECO","COMFORT"] + self.config['hold_state_topic'] = hold_state_topic.format(id=self.id) + self.config['hold_command_topic'] = hold_command_topic.format(id=self.id) # Electrical heater without thermostat # else: # self.boilertype = 'Electrical' @@ -93,8 +93,8 @@ async def setup(self): # self.config['mode_state_topic'] = mode_state_topic.format(id=self.id) # self.config['mode_command_topic'] = mode_command_topic.format(id=self.id) # self.config['swing_modes'] = ["STOP","ANTI-FROST","ECO","COMFORT"] -# self.config['swing_mode_state_topic'] = swing_mode_state_topic.format(id=self.id) -# self.config['swing_mode_command_topic'] = swing_mode_command_topic.format(id=self.id) +# self.config['hold_state_topic'] = hold_state_topic.format(id=self.id) +# self.config['hold_command_topic'] = hold_command_topic.format(id=self.id) self.config['unique_id'] = self.id @@ -105,21 +105,18 @@ async def update(self): await self.setup() if (self.mqtt != None): - if 'temperature' in self.attributes and self.attributes['temperature'] != 'None': - self.mqtt.mqtt_client.publish(self.config['current_temperature_topic'], self.attributes['temperature'], qos=0) + if 'temperature' in self.attributes: + self.mqtt.mqtt_client.publish(self.config['current_temperature_topic'], '0' if self.attributes['temperature'] == 'None' else self.attributes['temperature'], qos=0) if 'setpoint' in self.attributes: - if self.attributes['setpoint'] != 'None': -# self.mqtt.mqtt_client.publish(self.config['temperature_command_topic'], self.attributes['setpoint'], qos=0) - self.mqtt.mqtt_client.publish(self.config['temperature_state_topic'], self.attributes['setpoint'], qos=0) - else: - self.mqtt.mqtt_client.publish(self.config['temperature_state_topic'], '10', qos=0) +# self.mqtt.mqtt_client.publish(self.config['temperature_command_topic'], self.attributes['setpoint'], qos=0) + self.mqtt.mqtt_client.publish(self.config['temperature_state_topic'], '10' if self.attributes['setpoint'] == 'None' else self.attributes['setpoint'], qos=0) # if 'hvacMode' in self.attributes: # self.mqtt.mqtt_client.publish(self.config['mode_state_topic'], "heat" if self.attributes['hvacMode'] == "NORMAL" else "off", qos=0) # if 'authorization' in self.attributes: # self.mqtt.mqtt_client.publish(self.config['mode_state_topic'], "off" if self.attributes['authorization'] == "STOP" else "heat", qos=0) if 'thermicLevel' in self.attributes: self.mqtt.mqtt_client.publish(self.config['mode_state_topic'], "off" if self.attributes['thermicLevel'] == "STOP" else "heat", qos=0) - self.mqtt.mqtt_client.publish(self.config['swing_mode_state_topic'], self.attributes['thermicLevel'], qos=0) + self.mqtt.mqtt_client.publish(self.config['hold_state_topic'], self.attributes['thermicLevel'], qos=0) if 'outTemperature' in self.attributes: self.mqtt.mqtt_client.publish(self.config['state_topic'], self.attributes['outTemperature'], qos=0) @@ -141,4 +138,4 @@ async def put_hvacMode(tydom_client, device_id, boiler_id, set_hvacMode): async def put_thermicLevel(tydom_client, device_id, boiler_id, set_thermicLevel): print(boiler_id, 'thermicLevel', set_thermicLevel) if not (set_thermicLevel == ''): - await tydom_client.put_devices_data(device_id, boiler_id, 'thermicLevel', set_thermicLevel) \ No newline at end of file + await tydom_client.put_devices_data(device_id, boiler_id, 'thermicLevel', set_thermicLevel)