Open carl-bb opened 1 year ago
Your problem is that when you're calling your services, you're using values from the template-cliame entity. However, at that point the climate entity is not holding the new values you've selected from the card interface. So you're just passing the unchanged value before you change it.
What you need to do is to use the specific variables provided by the template for the appropriate action you want to do.
here is a suggestion:
set_temperature:
- service: modbus.write_register
data:
hub: fancoil_hub
slave: 2
address: 231
value: "{{ temperature | int * 10}}"
set_hvac_mode:
- service: modbus.write_register
data:
hub: fancoil_hub
slave: 2
address: 233
value: |-
{%- if hvac_mode == 'heat' -%}
3
{%- else -%}
5
{%- endif -%}
set_fan_mode:
- service: modbus.write_register
data:
hub: fancoil_hub
slave: 2
address: 201
value: >
{% if fan_mode == 'auto') %}
{{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65528) }}
{% elif fan_mode == 'low') %}
{{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65530) | bitwise_or(2) }}
{% elif fan_mode == 'medium') %}
{{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65529) | bitwise_or(1) }}
{% else %}
{{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65531) | bitwise_or(3) }}
{% endif %}
set_swing_mode:
- service: modbus.write_register
data:
hub: fancoil_hub
slave: 2
address: 201
value: >
{% if swing_mode == 'on') %}
{{ states('sensor.fc_soggiorno_prg') | int | bitwise_or(128) }}
{% else %}
{{ states('sensor.fc_soggiorno_prg') | int | bitwise_and(65407) }}
{% endif %}
Hello,
if you like, you can use my forked repo, where I am merging multiple feature request with some of my own patches. ;-) The above error is patched there.
The problem
Hello,
I have fancoil wired in a modbus rs485 serial network. I want to use hass-template-climate component because i have to do math with some modbus registers and the standard modbus climate component doesn't allow to do that and also lack of the fan_mode functionality.
I have set all as in the .yaml attached. all readings are fine but when I try to execute an action like 'set_temperature', 'set_hvac_mode' or 'set_fan_mode' nothing happen and the value is restored to the original one. I have tried to execute the service 'modbus.write_register' on the 'developer tools' tab and all of them work. In the log I see "running script requires passing in a context"
What's going on? How can I fix this?
Thanks
What version of Template Climate has the issue?
0.6.1
What version of Home Assistant are you running?
2023.5.4
What type of installation are you running?
Home Assistant OS
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response