Blueprint to send external temp to Sinope thermostat

Hi,

I’ve created a blueprint that allow select a temperature sensor and the Sinope thermostats that you have under HASS so that all the device selected are updated in near realtime. However, I have two issue. The first one is that even if the script do exactly the same as an automation that I have, the result is not the same. Here an extract of what is sent to the thermostat:

Iteration 1

Executed: February 22, 2025 at 5:05:28 PM
Result:
params:
  domain: zha
  service: set_zigbee_cluster_attribute
  service_data:
    ieee: xx:xx:xx:xx:xx:xx:xx:d6
    endpoint_id: 1
    cluster_id: 65281
    cluster_type: in
    attribute: 16
    value: -600
  target: {}
running_script: false

I have the same exact result with the blueprint. With my initial automation, this has the effect of displaying “-6.0” for the outdoor temperature. With the same script in the blueprint and the save automation from it, the thermostat will display “0.0” for the outdoor temperature. So it is talking to the thermostat correctly but won’t display proper temperature. I’m thinking at value type. Even if I see “value: -600”, it doesn’t mean that one is not char vs integer. That said, both automation are doing the same formula:

temperature_sensor_value: '{{ states(temperature[0]) | float * 100 | int }}'

But one is done while definitely the variable at the beginning of the sequence in a for each (blueprint) while the working automation is doing it directly on the line “value” of the script. What is expected, is an integer. I would think that both case should be integer wherever I do extract the value of the sensor but… did I missed something?

Second issue is that when selecting the thermostat, what is generated is a variable that has this aspect:

 thermostats:
    - device_id:
        - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5d
        - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx55

So, in the action, when doing a repeat with a for_each, it return a list of 1 item (the device_id level) so I have to create a second level of “for_each” to iterate between the devices that are enclosed under “device_id”. If I try, at the first for_each level to work with {{ thermostats.device_id }}, it’s not recognized as a list so it won’t do the iteration. What trick did I missed that would allow to remove the first level of “for_each” which is basically doing nothing?

Extract of the code:

action:
  - repeat:
      for_each: "{{ thermostats }}"
      sequence:
        - variables:
            temperature_sensor_value: "{{ states(temperature[0]) | float * 100 | int }}"
        - repeat:
            for_each: "{{ repeat.item.device_id }}"                         
            sequence:


              - service: zha.set_zigbee_cluster_attribute
                data:
                  ieee: '{{ (device_attr(repeat.item, "identifiers")|list).0.1 }}'
                  endpoint_id: 1
                  cluster_id: 65281
                  cluster_type: in
                  attribute: 16
                  value: "{{ temperature_sensor_value }}"

Right now, this also force me to work with devices because the second loop is iterating on the repeat.item.device_id so it won’t recognize entity_id.

Any comment or assistance would be appreciated. Thank you.

ehfortin

Just found how to fix the issue with the value of the sensor. I’ve added int to it like this:

value: "{{ temperature_sensor_value | int }}"

Now it is showing the proper temperature. So the only missing aspect is about how to only have a single level of “for_each” to get to the device_id/entity_id.

Thank you.

ehfortin