I use some of these Comet WiFi thermostats from eurotronic , they are quite cheap. They were also easy to integrate into my old Telekom smart home solution. When I switched to Home Assistant, I found that there was no integration for the thermostats. So I went on a search and found information in several articles on the Internet on how these thermostats can be integrated into Home Assistant.
The thermostat uses MQTT over a WiFi connection for communication. Unfortunately, the MQTT server entry of the thermostat cannot be changed. There is also no documentation from the manufacturer about the topics used to control the thermostat. I found blogs in various forums and gathered the information.
Since the MQTT server is not configurable, the data must first be redirected to your own MQTT server via your own DNS server. The thermostat uses two MQTT servers (mqtt.eurotronic.io / mqtt1.eurotronic.io), both are redirected to their own server in the DNS. For DNS redirection I used the add-on Dnsmasq, as MQTT broker Mosquitto.
All clients that do Comet Wifi thermostats must log on to the MQTT, all with the same username/password combination, which I found in plain text in a Wireshark trace. To do this, trace with WireShark and reset and re-integrate a thermostat.
This username/PW combination is then entered in the Mosquitto.
With an MQTT explorer on your own PC, you can then connect to the Mosquitto and see all MQTT messages.
MQTT builds hierarchical structures, so-called topics. Each topic then has a value. I have four thermostats integrated, each thermostat has the same structure of the topics.
I was able to find out the following topics through research on the Internet. Each topic can be sent to the thermostat and also read out. Some topics are used to query the thermostat.
<!-- wp:code -->
<pre class="wp-block-code"><code>S/ set value
V/ reported value from device.
/S/XX verify connection
/S/AF request temperature and other values
- #0B requests current target and actual temperature
- #02000000 -- connect with app, request current temp
- #FFFFFFFF - request device to send all fields back
A0 setpoint
A1 current temp
A2 temp Offset
A3 options bitfield keylock / summertime / rotate display
#200700 rotate off
#220500 rotate on
#230400 activate summertime
#220500 deactivate summertime
#270000 key lock on
#230400 key lock off
A5 => window open settings #1234
last byte = duration in min
first byte sensitivity
X80 => high
X08 => middle
X0C =>low
A7 - holiday settings
A8 - AE weekday program
</code></pre>
<!-- /wp:code -->
As can be seen from the values, they are HEX values. The temperature values must be converted.
The HEX value is first removed from the # control character, it is then converted into an integer value and then divided by two, since the thermostat works with 0.5° values.
{{ int(value[1:3],base=16)/2 }}
Now we must create a device of type climate so that we can also control the thermostat.
I've separated the MQTT-Settings and included them in the Configuration.yaml:
mqtt: !include mqtt.yaml
#In the mqtt.yaml each device must be configured:
climate:
- name: EssZimmer
unique_id: esszimmer1_climate
temperature_command_topic: "03/00004DA6/D43D391E23B8/S/A0"
temperature_command_template: '{{ "#" + "%0x" %int(float(value)*2) }}'
temperature_state_topic: "03/00004DA6/D43D391E23B8/V/A0"
temperature_state_template: '{{ int(value[1:3],base=16)/2 }}'
current_temperature_topic: "03/00004DA6/D43D391E23B8/V/A1"
current_temperature_template: '{{ int(value[1:3],base=16)/2 }}'
icon: mdi:temperature-celsius
modes: "heat"
temp_step: 0.5
precision: 0.5
min_temp: 16
max_temp: 30
retain: true
initial: 17
And the thermostats appear in the Home Assistant and can be controlled from there.
We are missing one step, the thermostats do not send any MQTT messages to save electricity. We need automation to regularly read out the current ACTUAL values of the thermostats. I’ve written two automations, one where I can poll one specific device, one automation that polls all Comet Devices.
The principle is always the same, I put an MQTT message on the topic “03/00004DA6/DEVICE-ID/S/A0″ with the value “#2b”. Device ID is the ID (Mac Addesse) of the device that I want to query.
The first automation starts every 2 hours and at the start of Home Assistant and polls all thermostats. Here I use the payload “#0b” when starting HA to read the ACTUAL and target temperature and “#02000000” every 2 hours to only read the current temperature.
alias: get temperature from all comet devices
description: ""
trigger:
- platform: homeassistant
event: start
id: start HA
- platform: time_pattern
hours: "2"
id: alle 2 Stunden
action:
- variables:
Comets:
- D43D39132F26
- D43D39551156
- D43D39E38DCE
- D43D391E23B8
- choose:
- conditions:
- condition: trigger
id:
- start HA
sequence:
- repeat:
count: "{{ Comets | count }}"
sequence:
- variables:
comet: "{{ Comets[repeat.index - 1] }}"
- service: mqtt.publish
data:
payload: "#0b"
topic: 03/00004DA6/{{ comet }}/S/AF
enabled: true
- conditions:
- condition: trigger
id:
- alle 2 Stunden
sequence:
- repeat:
count: "{{ Comets | count }}"
sequence:
- variables:
comet: "{{ Comets[repeat.index - 1] }}"
- service: mqtt.publish
data:
payload: "#02000000"
topic: 03/00004DA6/{{ comet }}/S/AF
enabled: true
default:
- repeat:
count: "{{ Comets | count }}"
sequence:
- variables:
comet: "{{ Comets[repeat.index - 1] }}"
- service: mqtt.publish
data:
payload: "#0b"
topic: 03/00004DA6/{{ comet }}/S/AF
enabled: true
mode: single
The second automation reacts to a change in the setpoint temperature of the thermostats and then only returns the current temperature. Here I use a helpful trick from MQTT, wildcards can be used in the topic. The “/+/” in the topic “03/00004DA6/+/S/A0″ is a placeholder, so all changes in the target temperature are recognized in the Comet Devices topics. The script only requests the current temperature of one device with the payload “#02000000”.
alias: get current temperature A0
description: use push mqtt on S/AF =
trigger:
- platform: mqtt
topic: 03/00004DA6/+/S/A0
condition: []
action:
- service: mqtt.publish
data:
qos: 0
retain: false
payload: "#0B"
topic: 03/00004DA6/{{trigger.topic[12:24]}}/S/AF
mode: queued
max: 5
That’s it, it was a bit ticky, but that’s how Comet WiFi thermostats can be controlled via Home Assistant.
Im getting an error :
true for dictionary value @ data[‘mqtt’][0][‘climate’][0][‘retain’]. Got None
it prevents my config being loaded
it seems to be a missspelling in mqtt.yaml
retain: true
Fixed it but now get a Message malformed: extra keys not allowed @ data[‘0’]
when inserting the second action ?
Any tips ?
Have you found the error?
If not, in which automation at which line do you get the error and what does the trace say?
Cool that you got it all working with a local mqtt server. I was not able to find the DNS request in Wireshark when I tried this. I think I still have one device here, maybe I will give it a try again
Is it possible tu use own Window Sensors from within HA?
I don’t know of any mqtt technology for open window detection. But you can use an automation to set the temperature to 0 when HA detects the open window.