Integrating Comet Wifi basic functionality

I think the best way to get it to work as a climate in HA is by using this

It can be configured to map target and current temperature from other entities which can then be synced via mqqt

Great finds, those are a lot more than I thought there to be. I only really wiresharked for the temperature values.
I don’t think generic thermostat will really work, unless there’s a trick I don’t know of yet.

It uses a sensor and a switch connected to a heater or air conditioning under the hood.

and it requires a toggle device as a heater, where as we would ideally want an input number:

heater string Required
entity_id for heater switch, must be a toggle device. Becomes air conditioning switch when ac_mode is set to true.

Seems to me this would only turn a device on or off, but that’s a job the thermostats are already doing themselves.

From what I’ve seen there’s a whole new integration needed. I’ve looked into writing integrations a little bit but I’m not sure I could do it yet. I will do more research into what kind of effort that would take.

Super interesting to learn there is an MQTT connection you were able to piggyback on! I take it their MQTT broker does not allow subscriptions for the credentials the thermostats use?

Not sure about that one, I’ve seen in the mosquitto logs that the phone app also authenticates with the same username, although the log entry looked a little different. But if you can reverse engineer the way the phone app works, you could also have HA act as the client probably. Everything is in unencrypted MQTT 3.1 so easy to packet capture.

Great work!

I just integrated three of them and I can set and receive the desired temperature (after some adaptions to the scripts above). I’m still working on how to get the actual temperature (periodically?).

I also think, it’s a kind of new device, where you just “program” a thermostat (but I don’t know if this already exists). I have two different scenarios in my mind:

  1. Just program the thermostat like the APP does and let it run.
  2. Disable almost all functions on the thermostat and control it via HA.

Since I’m a newbee here I don’t know how to write code for a new device (1). Is there any template I can use to modify/adapt?
The second approach seems to be more easy (for me).

Can somebody give me some hints?

Hi,

you can get the temperature periodically by setting up an automation that sends “#0B” to the /S/AF topic of each thermostat, like so:

  alias: receive current temps schedule
  description: ''
  trigger:
  - platform: time_pattern
    hours: /1
    seconds: '30'
  condition: []
  action:
  - service: mqtt.publish
     data:
        topic: 02/00002F71/D43D391523AA/S/AF
        payload: "#0B"
        qos: 2
  mode: single
  trace:
    stored_traces: 10

This will run every hour and thirty seconds (10:00:30, 11:00:30, …).
The thermostat will then send out info to the /V/ topics which should update your MQTT sensor listening to /V/A1
Keep in mind that doing this will drain their batteries faster.

  1. Just program the thermostat like the APP does and let it run.
  2. Disable almost all functions on the thermostat and control it via HA.

I’m going with option two. While in your local network you can also use the app to program the thermostats since your phone also talks to the HA MQTT broker, since I only implemented temperature control so far.

Also now that I’ve gotten more familiar with Home Assistant I would no longer use scripts the way I do currently. You can mirror everything in the script directly in the automation action, so you should probably only be using scripts when you need to reuse them often. I’m currently thinking of two ways to do this that make it feel “more correct”:

  1. Make a few big automation that run regularly and have the logic in the automation action using conditions
  2. Make many small automations that each have minimal logic in their automation conditions.

Right now I have most of my previous setup migrated to big automations but I’m not spending a lot of time on this right now so progress is slow.

Hello all,
thanks for you great work, it was a good starting point for me. I have 9 Comet Wifi running since October 2022 and a Homeassistant running since 4 weeks on my Rock4SE board. I’ve not setup PiHole, yet, so I’m using nextdns.io as intermediate solution to change the eurotronic addresses. I’m still at the point reading data from the devices, so I’m still using the app as controller (it still works with the local Mosquitto) and the internal temp profile schedulers (just kept it as it was).
But I’m facing some issues, maybe you have some ideas:

  • FYI, my devices have different username/password combination, so it seems not to be a fixed value for all devices. But all have the same, so I guess it depends on app setup
  • One device lost time sync, it gets like all other time via time.windows.com at boot, but scheduled temp profiles are triggered at wrong time, maybe on the device the timezone setting got garbled, maybe using …/S/AF with #FFFFFFFF payload? I found maybe a solution for this. In wireshark I found a topic sending a timestamp like this: 02/FFFFFFFF/000000000004/T/B7: #23.03.09-09:00 (UTC). Further investigating by subscribing to mqtt.eurotronic.io I found that there are 4 of these topics (considering daylight savings time or not), so I added this to my 10-minute automation:
alias: Comet Scheduler
description: ""
trigger:
  - platform: time_pattern
    minutes: /10
condition: []
action:
  - service: mqtt.publish
    data:
      qos: "2"
      topic: 02/FFFFFFFF/000000000001/T/B7
      retain: false
      payload_template: "{{ now().strftime('#%y.%m.%d-%H:%M') }}"
    alias: Timestamp 1
  - service: mqtt.publish
    data:
      qos: "2"
      topic: 02/FFFFFFFF/000000000002/T/B7
      retain: false
      payload_template: "{{ (utcnow()+timedelta(hours = 1)).strftime('#%y.%m.%d-%H:%M') }}"
    alias: Timestamp 2
  - service: mqtt.publish
    data:
      qos: "2"
      topic: 02/FFFFFFFF/000000000003/T/B7
      retain: false
      payload_template: "{{ (now()-timedelta(hours=13)).strftime('#%y.%m.%d-%H:%M') }}"
    alias: Timestamp 3
  - service: mqtt.publish
    data:
      qos: "2"
      topic: 02/FFFFFFFF/000000000004/T/B7
      retain: false
      payload_template: "{{ (utcnow()-timedelta(hours=12)).strftime('#%y.%m.%d-%H:%M') }}"
    alias: Timestamp 4
[...]
  • Another device lost connection to the local Mosquitto overnight, wiresharking a hard reboot shows that it still gets the local router DNS server but didn’t ask for mqttx.eurotronic.io. Instead it directly contacted IP address of mqtt1.eurotronic.io. Do you know if IP addresses are persistently cached on the devices? Or is the device now in a fall-back mode using hardcoded address? I solved this by removing local DNS rewrite and then reboot the devices again. Then re-enabled the DNS rewrite and cycled wifi connection. All is still a little bit tricky and not stable.
    Some weeks later I still have problems with sporadic disconnection of devices from MQTT (#COMM-LOSS) which requires reconnection of WiFi. Keep observing.

I didn’t do any factory reset on the devices, yet (I guess this would require to restore original eurotronic connection so the devices could be setup with the app).

I’m not yet very experienced with Homeassistant scripting. Current approach to manually add all devices to config.yaml looks not very generic. Is it somehow possible to create the entities with a loop over the MAC addresses automatically (I didn’t figured it out, yet)?

Hello everyone,
can someone adjust thermostat definition from linked forum to our Comet WiFi? Is that even possible? It would be nice to use the thermostats as such objects.

Hello @hausmeisterHA,
I’m experimenting with a climate configuration that seems to work.
Paste this to your developer-tools/template section and replace name: topic in the map at the beginning with yours:

{% set comet_map={
  "Wohnzimmer": "02/0000XXXX/YYYYYYYYYYYY",
  "Schlafzimmer": "02/0000XXXX/YYYYYYYYYYYY",
} -%}
mqtt:
  sensor:
    {% for name,topic in comet_map.items() -%}
    {% set mac=topic[-12:] -%}
    {% set id=name|lower|replace("ü","ue") -%}
    - name: Heizung {{ name }} Battery
      object_id: comet_{{ id }}_battery
      unique_id: sensor.comet_{{ id }}_battery
      device:
        identifiers: [ '{{ topic }}' ]
      state_class: measurement
      device_class: battery
      unit_of_measurement: "%"
      state_topic: {{ topic }}/V/A6
      value_template: "{{"{{"}} int(value[1:],base=16) {{"}}"}}"
    {% endfor %}
  climate:
    {% for name,topic in comet_map.items() -%}
    {% set mac=topic[-12:] -%}
    {% set id=name|lower|replace("ü","ue") -%}
    - name: Heizung {{ name }}
      object_id: comet_{{ id }}
      unique_id: climate.comet_{{ id }}
      device:
        connections: [ ['mac', '{{ mac }}'] ]
        identifiers: [ '{{ topic }}' ]
        manufacturer: Eurotronic
        model: Comet Wifi
        name: Comet {{ name }} {{ mac }}
      initial: 7.5
      min_temp: 7.5
      max_temp: 28.5
      precision: 0.5
      temp_step: 0.5
      temperature_unit: C
      optimistic: true
      modes:
        - "off"
        - "heat"
        - "auto"
      availability:
        - topic: {{ topic }}/V/XX
          value_template: "{{"{{"}} 'offline' if value=='#COMM-LOSS' else 'online' {{"}}"}}"
        - topic: {{ topic }}/S/XX
          value_template: "{{"{{"}} 'online' {{"}}"}}"
        - topic: {{ topic }}/V/A1
          value_template: "{{"{{"}} 'online' {{"}}"}}"
      current_temperature_topic: {{ topic }}/V/A1
      current_temperature_template: "{{"{{"}} int(value[1:],base=16)/2 {{"}}"}}"
      temperature_state_topic: {{ topic }}/V/A0
      temperature_state_template: "{{"{{"}} int(value[1:],base=16)/2 {{"}}"}}"
      temperature_command_topic: {{ topic }}/S/A0
      temperature_command_template: "{{"{{"}} '#' + '%02x' %int(float(value)*2) {{"}}"}}"
      mode_state_topic: {{ topic }}/V/A3
      mode_state_template: "{{"{{"}} 'auto' if value[:2]!='#2' else 'heat' if state_attr('climate.comet_{{ id }}','temperature')>7.5 else 'off' {{"}}"}}"
      mode_command_topic: {{ topic }}/S/A3
      mode_command_template: "{{"{{"}} '#00200000' if value=='auto' else '#20000000' {{"}}"}}"
      qos: 2
      retain: false
    {% endfor -%}

I configured 3 modes: auto is mapped to enabled heat profile in the app, if the heat profile is disabled, this will result to the states off if the target temp is 7.5° or heat if it is higher. I also added a sensor for the battery state and configured devices.
You still need the #COMM-TEST automation from @DracoTomes and an automation to poll the values:

- id: ''
  alias: Comet Scheduler
  description: ''
  trigger:
  - platform: time_pattern
    minutes: /10
  condition: []
  action:
  - service: mqtt.publish
    data:
      qos: '2'
      topic: 02/0000XXXX/YYYYYYYYYYYY/S/AF
      payload: '#4B'
      retain: true
    alias: Wohnzimmer
  - service: mqtt.publish
    data:
      qos: '2'
      topic: 02/0000XXXX/YYYYYYYYYYYY/S/AF
      payload: '#4B'
      retain: true
    alias: Schlafzimmer

I will work on this to make the automation smart to automatically detect all climate.comet entities, but currently all are added manually. I also added topic to send timestamp here (see my previous post).

1 Like

Hi there,
I’m kind of “new” to HA (half a year) and have a problem with setting in the code in configuration.yaml:

**

bad indentation of a mapping entry (98:24)

**
Maybe someone could give me a hint :slight_smile:


 95 | mqtt:
 96 |     sensor:
 97 |         - name: kitchen-temp
 98 |             state_topic: 02/00002F71/MYDEVICEMAC/V/A1
-----------------------------^
 99 |             unit_of_measurement: °C
type or paste code here

What am I doing wrong?

Thanks for your help.

I think I got it…

mqtt:
  - sensor:
      name: temp_basti_buero
      state_topic: "02/00002F71/MYDEVIDEMAC/V/A1"
      unit_of_measurement: °C

input_number:
    temp_basti_buero:
        name: temp_basti_buero
        initial: 20
        min: 13
        max: 30
        step: 0.5
        unit_of_measurement: °C

Hey there,

I’m relatively new to all of home assistant, so maybe I will ask some basic stuff…

I think I got everything set up correctly but my mqtt logs show that my comet tries to log in with a different login. So, I must snoop in on the mqtt connect massage to retrieve username and Password.

I tried to use Wireshark but not successful. Can someone elaborate on the way to get the right Password and User combination?

The help of this awesome community would be much appreciated.

Hi Commode,
it’s really easy if you would use an app on Android where you have installed Eurotronic App.
1.Make an Eurotronic account and log in.
2.Get an App - https://play.google.com/store/apps/details?id=com.minhui.networkcapture
set as a source that App and you can see all your unencrypted MQTT traffic data to external Server - mqtt.eurotronic.io.
3.Create in mosquitto new user with your settings (login/password) and it should work. :slight_smile:

Thank you very much! :+1:

I have successfully integrated the Comet WiFi into Home Assistant. I wrote a blog post about it:

1 Like

@HelgeB
Thanks for youre template for sensor and device, that is what I needed for the thermostats. I added the Wifi Signal Strength as a sensor with the following:

  - name: Heizung Test Wifi
    object_id: comet_test_wifi
    unique_id: sensor.comet_test_wifi
    device:
      identifiers: ["02/0000XXXX/MAC-ADDR"]
    state_class: measurement
    device_class: signal_strength
    unit_of_measurement: "dB"
    state_topic: 02/0000XXXX/MAC-ADDR/V/B3
    value_template: "{{ int(value[1:]) }}"

Also for the option to check if the setting “Open Window” is set:

switch:
  - name: Heizung Test Open Window
    object_id: comet_test_open_window
    unique_id: sensor.comet_test_open_window
    device:
      identifiers: ["02/0000XXXX/MAC-ADDR"]
    command_topic: 02/0000XXXX/MAC-ADDR/S/A5
    state_topic: 02/0000XXXX/MAC-ADDR/V/A5
    payload_on: "#140A"
    payload_off: "#040A"

This option can be used, but after set with Home Assistant it may need a manual call with “/S/AF” topic and #FFFFFFF payload. After this it shows the correct value with the switch.

Also if anyone need it, I figured out that you can call just battery, keylock, summertime and rotation settings with this:

Topic: 02/0000XXXX/MAC-ADDR/S/AF
Payload: #48000000
1 Like

How can i set/ask a current time to the Comet wifi? I have one (from 5) that shifts a given profile about 3 hours and i can’t fix it.
Any ideas?

@hausmeisterHA well, all devices should get the current time automatically. At boot time, they access time.windows.com NTP server. And during runtime, they are getting timestamps from MQTT server. You can check topics 02/FFFFFFFF/000000000001/T/B7 ... 02/FFFFFFFF/000000000004/T/B7 from mqtt.eurotronic.com. Values look like: #23.12.29-20:52 and are sent every minute. I sent these topics via my mosquitto server using these HA templates (not required if using original mqtt servers):

{{ now().strftime('#%y.%m.%d-%H:%M') }}
{{ (utcnow()+timedelta(hours = 1)).strftime('#%y.%m.%d-%H:%M') }}
{{ (now()-timedelta(hours=13)).strftime('#%y.%m.%d-%H:%M') }}
{{ (utcnow()-timedelta(hours=12)).strftime('#%y.%m.%d-%H:%M') }}

So the templates containing now() will follow the daylight saving time and the utcnow() not. Looks like there are 2 timezones defined for the devices.

I also have also one Comet WIFI that gets out-of-sync frequently. All others are fine. Currently I’ve not found out, what’s the difference.

Thank you for your answer! I think i found a cause for my difficulties - it was a new mqtt server mqtt2.eurotronic.io that was queried from one my thermostat with FW 5.5/2.5. All the others have 5.4/2.4 FW and no issues. Now i have set the new host to my mosquitto in pihole and all works as expected again.

I used a bit of a different strategy to get this working:

Most guides / info I could find involves redirecting the communication between the Thermostats and the Eurotronic MQTT Broker to a local MQTT Broker, I wanted to avoid that and basically wanted Home Assistant to act like the iOS App that came with the devices so that no rerouting is required, this obviously means that I am now dependent on the Eurotronic MQTT Server staying alive, this is how I did it:

  1. Setup a functioning system (Devices registered and configured using the iOS app).

  2. Get the login credentials from the iOS app: (Capture the communication between iOS and the Eurotronic Broker using Wireshark)
    a. Create a Wireless Hotspot using a Windows computer
    l3WK9S4AFN
    b. Connect your phone to the wireless hotspot
    c. Start Wireshark, record the communication on the Wireless interface
    Wireshark_yMmQY3h4I2
    d. Filter for MQTT Communication and open the app on your phone, you should then see the login credentials and server used when you click on the “Connect Command” in the packet log:


    e. Copy out the User Name, Password and server used (IP Address).

  3. Create Helper devices in Home Assistant to store the values we will be communicating for each
    Thermostat:
    a. Setpoint.
    b. Actual Setpoint.
    c. Current Temperature.

  4. Create a Flow in Node Red to interact with the Eurotronic MQTT Broker:

  5. Add the Interface components on the Dashboard:
    msedge_eKzZUwlTMl

Here an export of the flow in which I replaced sensitive info with the following tags:
{{USER_ID}} → 0000XXXX
{{THERMOSTAT1_MACADDRESS}} → Mac Address of Thermostat 1
{{THERMOSTAT2_MACADDRESS}} → Mac Address of Thermostat 2
{{BEDROOM_MACADDRESS}} → Mac Address of Thermostat 3
https://pastebin.com/raw/DZHdVqFb

hausmeisterHA, Yes I also found the new mqtt mirrors at eurotronic.io. There is also mqtt3.eurotronic.io. So now I redirected all 4 using pi.hole to my local mosquitto.

Another question. I again have just one (another) Comet Wifi with different behavior. Beside of sending #COMM-TEST to topic .../S/XX, it is sometimes sending #AP-TEST. But it looks like it is not listening for the same message sent back and is sometimes going offline then (no error code on the display) and I need to restart it. Ever observed something like this?

Received 09:40:08
QoS: 2
Payload: #COMM-TEST
Received 12:37:51
QoS: 2
Payload: #AP-TEST
Received 12:37:52
QoS: 2
Payload: #AP-TEST
Received 12:49:42
QoS: 2
Payload: #AP-TEST
Received 12:49:43
QoS: 2
Payload: #AP-TEST
Received 14:04:39
QoS: 2
Payload: #COMM-TEST
Received 14:04:40
QoS: 2
Payload: #COMM-TEST

Hmm, strange behavior… Is it may be a margin wi-fi signal strength for a Comet, that sends such a query?
And i found a workaround to set all/one of thermos back to local mqtt - on the router i close internet connection to an “failed” thermo and in 2-3 min affected one goes fine again.