Set Sinope Line Voltage thermostat outside temperature from HAOS Weather integration

There are other posts on this subject but they are outdated this one is for HAOS 11.5

  • The automation posted by EtienneMD does not work as is in HAOS 11.5. Some syntax seems to have changed I finally got it working. Here is the exact automation pasted in yaml editor.

-I use this automation to set the outside temperature of Sinope Line Voltage Thermostats MODEL TH1124ZB
-The temperature source is Environment Canada Weather integration built in to HAOS. (Just have to add and configure it)
-The automation is triggered by temperature change.
In the code below, “saint_lazare” is the weather station that the Environment Canada chose base on my position, LATITUDE,LONGITUDE.

STEPS
Create a New automation, click the three dots in upper right corner, select Edit in YAML, copy the attached yaml code and paste it in the editor, save.
Then change:
1- the entity_id of the trigger (change the “saint_lazare” part of it with your Environment Canada weather station).
2- the IEEE values for your thermostats this example shows two (2), add as many as you want. (find them by selecting the Zigbee device and clicking “Zigbee info” in the upper left box)
3- the value, (same as step 1)
4- Save again

You can RUN the automation and then click TRACE to see if all went OK.
Check your thermostat the Out temp should display.

Here is the exact code I use:

alias: SendOutTemp
description: ""
trigger:
  - platform: state
    entity_id: sensor.saint_lazare_temperature
condition: []
action:
  - repeat:
      count: "{{thermostats|length}}"
      sequence:
        - service: zha.set_zigbee_cluster_attribute
          data:
            ieee: "{{ thermostats[repeat.index-1] }}"
            endpoint_id: 1
            cluster_id: 65281
            cluster_type: in
            attribute: 16
            value: "{{ (states('sensor.saint_lazare_temperature') |float * 100 )|int}}"
variables:
  thermostats:
    - 4c:5b:b3:ff:fe:2e:2c:bf
    - 50:0b:91:33:00:02:bc:71

If you want, you can use a for_each to iterate through the list of thermostat addresses.

alias: SendOutTemp
description: ""
trigger:
  - platform: state
    entity_id: sensor.saint_lazare_temperature
    not_to:
      - 'unavailable'
      - 'unknown' 
condition: []
action:
  - variables:
      temp: "{{ (trigger.to_state.state | float(0) * 100) | int(0) }}"
  - repeat:
      for_each:
        - 4c:5b:b3:ff:fe:2e:2c:bf
        - 50:0b:91:33:00:02:bc:71
      sequence:
        - service: zha.set_zigbee_cluster_attribute
          data:
            ieee: "{{ repeat.item }}"
            endpoint_id: 1
            cluster_id: 65281
            cluster_type: in
            attribute: 16
            value: "{{ temp }}"

Reference

for_each


EDIT

Don’t attempt to test this version using the Run command. This version uses the trigger variable which is defined only when the automation is actually triggered by one of its triggers. The Run command triggers nothing and only executes the automation’s actions.

Hi Taras,
Thank you for the suggestion. “for each”
I understand your version uses the trigger.to_state so it cannot be used with RUN but my version works fine when RUN from the UI.

Because your version unnecessarily queries the State Machine to get the value of sensor.saint_lazare_temperature. That value is already available from the State Trigger via the trigger variable.

Reference

Automation Trigger Variables - State Trigger

As you develop more complex automations you’ll discover more uses for the trigger variable including the trigger.id to differentiate between which one of multiple triggers occurred. The Run command cannot be used to test such an automation. In addition, if the automation contains a condition, the Run command doesn’t test it. Its usefulness is limited to testing the actions (and only the actions) of a very simple automation.

Reference

Testing your automation

However, if the Run command is important to you then simply replace trigger.to_state.state in my example with states('sensor.saint_lazare_temperature').

Hi Taras, thanks again for your nice explanation. As you can see I’m new to scripting in HA and to me yes testing the automation was crucial. I cannot tell you how many versions I tried after being misled by other comments saying I would need to use Templating to achieve this. Then I lost myself in trying to understand templates (not there yet). Anyway I agree your version is a better and more efficient implementation and I will surely modify my automation accordingly (now that I know it works). I hope our conversation will have helped others to understand. Thank you again.

Here’s a way to quickly test an automation by actually triggering it.

You can trigger your automation’s State Trigger without waiting for sensor.saint_lazare_temperature to be changed by the Environment Canada integration.

You can temporarily “force” the sensor’s value to be whatever you want. For example, if the sensor’s current value is -15 you can temporarily “force” it to be a different value like -16. That state-change will trigger your automation’s State Trigger.

The new value is temporary because it will be changed by the Environment Canada integration the next time it performs an update (or you can force it back to its original value).

  1. Go to Developer Tools > States
  2. Find sensor.saint_lazare_temperature in the list and click it.
  3. Scroll to the top of the page where all of the sensor’s properties are displayed in a form.
  4. Take note of its current State value (perhaps make a copy of it). Let’s say it’s currently -15.
  5. Change the value to -16 or any number other than its current value.
  6. Click the Set State button.
  7. That should be sufficient to trigger the automation’s State Trigger.

Optionally, use the same technique to set the sensor’s value back to the original temperature (-15). Otherwise, simply wait for the Environment Canada integration to update the sensor’s value.

Here’s a screenshot from my system showing sensor.outdoor_temperature.