Danfoss Ally TRV working with remote temp sensor

Hi Bjorn, thanks for the quick response.

Sorry, what I ment was that I could not get the Danfoss to react, i.e. open/close despite manipulating the external temperature to much higher/lower themperatures than the target.

Oh I did not realise the sensor in HA will report wrong value, I assume it is the Danfoss you mean?
I have now installed the file editor, so I can edit the script.yaml and automation.yaml directly - will give it a go later.
One quick question in the meantime, your script deviates from Thors which has with the use of " ’ " and " >- " in the value:

ieee: '[IEEE of your Danfoss Ally TRV]'
vs
ieee: 84:2e:14:ff:fe:5e:41:dc #TRV ieee

      value: >-
        {{ (states("[the sensor you want to read the temperature from]") | float *
        100) | round(0)}}

vs

      value: '{{ (states("sensor.bathroom_air_temperature") | float * 100) |
        round(0)}}' #external sensor

What is the difference here? I will just follow your script at first (easier to troubleshoot)

Good question, I am not particularly sure if the difference has any impact. But I can confirm my version works.

Also, not sure if it’s the exact setup you want with open windows, but here are my two automations that sets the temperature (22 or 6 celcius) depending on if my window is open or not.

I assume there is a way to just turn the TRV on and off, please let me know if you figure it out.

- id: '1615488906764'
  alias: TEM06 - Open Window - set temperature to 6
  description: ''
  trigger:
  - type: opened
    platform: device
    device_id: f957ade113eea0ef1687eae1f313cb55
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    domain: binary_sensor
  condition: []
  action:
  - service: climate.set_temperature
    data:
      temperature: 6
    target:
      device_id: 22598ea4a60d608123e5a4b88d064a88
  mode: single
- id: '1615490307443'
  alias: TEM10 - Open Window - set temperature to 22
  description: ''
  trigger:
  - type: not_opened
    platform: device
    device_id: f957ade113eea0ef1687eae1f313cb55
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    domain: binary_sensor
  condition: []
  action:
  - service: climate.set_temperature
    data:
      temperature: 22
    target:
      device_id: 22598ea4a60d608123e5a4b88d064a88
  mode: single

*Quick edit for spelling errors.
Okay I did a fresh install of Home Assistant, just to leave out any possible bias.

I seem to have narrowed down the issue, the automation seems to trigger the script correctly, but the Danfoss does not open/close accordingly. When i look at the logs there are quite a few errors for both script and automation:

Logger: homeassistant.components.automation.tem01_update_external_temp_bathroom
Source: components/zha/core/device.py:518
Integration: Automation ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 12:17:03 (106 occurrences)
Last logged: 12:42:50

* TEM01 - Update External Temp - Bathroom: Error executing script. Unexpected error for call_service at pos 1: 513
* While executing automation automation.tem01_update_external_temp_bathroom

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 262, in _async_step await getattr( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 466, in _async_call_service_step await self._async_run_long_action(service_task) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 428, in _async_run_long_action long_task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1488, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1523, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 218, in service_handler await script_entity.async_turn_on( File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 323, in async_turn_on await coro File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1041, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 254, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 262, in _async_step await getattr( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1488, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1523, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 712, in admin_handler await result File "/usr/src/homeassistant/homeassistant/components/zha/api.py", line 922, in set_zigbee_cluster_attributes response = await zha_device.write_zigbee_attribute( File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 553, in write_zigbee_attribute cluster = self.async_get_cluster(endpoint_id, cluster_id, cluster_type) File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 518, in async_get_cluster return clusters[endpoint_id][cluster_type][cluster_id] KeyError: 513

and

Logger: homeassistant.components.script.bathroom_temp_follow
Source: components/zha/core/device.py:518
Integration: Scripts ([documentation](https://www.home-assistant.io/integrations/script), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+script%22))
First occurred: 12:10:40 (54 occurrences)
Last logged: 12:42:50

Bathroom Temp Follow: Error executing script. Unexpected error for call_service at pos 1: 513

`Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 262, in _async_step await getattr( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1488, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1523, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 712, in admin_handler await result File "/usr/src/homeassistant/homeassistant/components/zha/api.py", line 922, in set_zigbee_cluster_attributes response = await zha_device.write_zigbee_attribute( File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 553, in write_zigbee_attribute cluster = self.async_get_cluster(endpoint_id, cluster_id, cluster_type) File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 518, in async_get_cluster return clusters[endpoint_id][cluster_type][cluster_id] KeyError: 513

Any idea what this could be? Perhaps related to the script’s endpoint, cluster type and id? Or perhaps the Danfoss firmware?

This is way above what I can comprehend. But it appears that your unit doesn’t recognize the zigbee attributes of the script. And if you have the same firmware (1.08) and values as mine above, I am out of ideas.

All except finding the right place at Github to log the issue.

Ha ha that’s fair enough. I can see that useing remote sensors for temperature is featured in a couple of forums, so fingers crossed it will be trivial soon. I will try to fool around with it for a bit, and see if I can get your script at automation working.

Just a little update.

So, I have spent some time checking all options. YAML is pretty annoying for a newbie like me, with the indentation. Anyways I now have most of the setup working. That is automation runs script correctly, and the script updates the “external_measured_room_sensor” on the Danfoss. Yet still no luck getting the Danfoss to do anything with this external temperature. Sigh…
However, it did get me thinking, what is the response time? I have fairly quickly warmed/cooled my external sensor to test it, but should I expect e.g. 15 min before the Danfoss react?

Just as a sidenote, there seems to be a ton of options for the Danfoss you can (perhaps) use. In this attempt with the external temperature, it is

DanfossThermostatCluster (Endpoint id: 1, Id: 0x0201, Type: in)
external_measured_room_sensor (id: 0x4015)

Converted from hexadecimal to binary we get:

1 = 1
0x0201 = 513
0x4015 = 16405

which is evident in nslrThor Jacobsen’s script. So makes good sense, despite it still teasing me.

One other example is “external_open_windows_detected (id: 0x4003)” which may be of interest to you bjorn.sivertsen, perhaps take a look here:

To check if it’s actually working, you can read the value off of the TRV in the cluster. My server is crashed right now and I’m not at home, so I can’t explain the exact steps, but you need to find the TRV under entities and fiddle around there.

It does take a while for the motor to react, so you can’t test it quickly. You need to trust that if the value is set (you can read it in the cluster), it’s working.

Thanks, I did indeed fiddle around reading the cluster values, and yes it does read the external sensor temperature. I will then assume it works, but still see if I can come up with a more efficient test setup that last longer - just to be sure.

Success!

I created a small cold box and put the external sensor in there. I was pretty disappointed when nothing happened for 2 hours. But then I got a suspicion, and sure enough the Danfoss uses a mean of its own temperature and the external. Duuuh! Actually double duh, as you nslrThor Jacobsen specifically mention it here.
So, as you can see in the attached images it works as intended. And nice feature that it is not on/off but actually gradually opening/closing.


Anyway, it works now, and it is usually within few minutes, so acceptable. That it actually uses an average is fine I guess – I might strive to position external sensors in the opposite site of the room. Otherwise, I might be able to figure something out in an equation to make the avarage temperature equal to the external sensor.

A big thanks for nslrThor Jacobsen and bjorn.sivertsen, and whoever else has have to put up with my walls of text.

Just adding to previous sidenote, I added to open/close window for fun, at it works perfectly, i.e., closes off the Danfoss. All credits go to wormie_dkDavid Alberg Peters who mentioned it here

ally1_open:
  alias: 'Danfoss Ally 1: open window'
  sequence:
  - service: zha.set_zigbee_cluster_attribute
    data:
      ieee: [IEEE of your Danfoss Ally TRV]
      endpoint_id: 1
      cluster_id: 513
      attribute: 16387
      cluster_type: in
      value: 1
      manufacturer: '4678'
  mode: single
ally1_close:
  alias: 'Danfoss Ally 1: close window'
  sequence:
  - service: zha.set_zigbee_cluster_attribute
    data:
      ieee: [IEEE of your Danfoss Ally TRV]
      endpoint_id: 1
      cluster_id: 513
      attribute: 16387
      cluster_type: in
      value: 0
      manufacturer: '4678'
  mode: single
1 Like

@nslr Hey man,

I have been shown this post by someone on z2m asking if I can make this attribute accessible.

Looking at the specification:
https://assets.danfoss.com/documents/176987/AM375549618098en-000101.pdf

The description states the following:
Recommended to be received from Gateway at least
every 3 hours but not more often than every 30 minutes @
every 0,1K change
After 3 hours the function is disabled and goes back to
standard mode

So that range is meant to be in degress Kelvin rather than Celsius? Your template seems to not do this conversion.

Can you confirm the behaviour at your end?

I wonder if this is referring to 100 value e.g. 0.1K, and nothing to do with temperature

Thanks,
Rob

Hi Rob,

No, I did not add any conversions of any kind. I’ve never noticed the docs referring to temp changes in degress Kelvin - but AFAIR a change of 1 degree Kelvin is equal to 1 degree Celcius. They just have different definitions of zero.

Also, I haven’t updated my hardware to the latest firmware, so not sure if that’ll break something for me.

Hi Thor,

Thanks for your reply. Yes you are correct, 1 degree will always be 1 degree. The value though will mean something else. The spec is obviously not clear enough whether it means 0.1k degrees or 0.1k as in 0.1 x 1000 = 100 points of value.

Can you please confirm, the value you are sending? For example 22.5C you would send 2250?

Thanks again

Ah, now I get it. Yes, the value needs to be 2250 for 22.5C - so the “k” is probably “1000s”, not “kelvin” :slight_smile:

1 Like

Thanks a lot. I got a PR to support this on zigbee2mqtt Add support for external temp sensor by robertalexa · Pull Request #2890 · Koenkk/zigbee-herdsman-converters · GitHub

I am hopeful that the value means 1000s and no conversion is needed, otherwise the internal mechanism will definitely not behave as expected. But given that every other attribute of the device is specified in C, i doubt they would have done something silly for this one.

Thanks a lot for your input!

I assume 1.12 replaces the 1.08 firmware? Does anyone have a link to it? Can only find the 1.08 one.

Same here. I sent them a support request. I’ll write back if I get it, but I hope they just update the available download and make it available for everyone.

1 Like

Sounds great, let us know what they reply!

Hej @bjorn.sivertsen, I’m a newbie with Home Assistant. Your thermostat card looks great and better suited than the default one for what we’re doing here. I guess you wrote it yourself? Would you mind sharing the code? Thanks!

Hi @BikingViking is this one installed through HACS

1 Like

Being a beginner, I am a bit confused about TRV firmware versions. How does one check What Danfoss TRV version they have?

For example I see when I go to Home Assistant Configuration / Devices / Danfoss eTRV0100- “Firmware: 0x0000010c”. Is that Danfoss firmware version?