Hi I want to constantly copy the temperature from sensor.viking_0203502038_87_00_temperature to number.wago_vent_forrad_temperatur_sensor_write.
Since I’m not aware of any direct copying feature I tried an automation.
alias: Förråd Write temperature
description: ""
trigger:
- platform: state
entity_id:
- sensor.viking_0203502038_87_00_temperature
condition: []
action:
- service: number.set_value
data:
value: "{{ states('sensor.viking_0203502038_87_00_temperature') }}"
target:
entity_id: number.wago_vent_forrad_temperatur_sensor_write
mode: single
but when I run the action I get
expected float for dictionary value @ data[‘value’]. Got None
Is Automation the right way to go, and how do I write it?
Apologies for replying to my own post. This is somewhat strange. I renamed sensor.viking_0203502038_87_00_temperature yesterday. But when the question came to rename the entity as well (not entirely sure of wording) I answered no. But today as I am working with it, it suddenly renamed itself. So the problem was that the sensor did not exist. Hence → Got None.
If number.wago_vent_forrad_temperatur_sensor_write wasn’t created by an integration, you could make it a template sensor instead and have it read your sensor. The state would literally just be
You will also get that error if the sensor’s value is ever unavailable (or unknown). You should modify the template to guard against that possibility.
value: >
{% set x = 'sensor.viking_0203502038_87_00_temperature'
if has_value('sensor.viking_0203502038_87_00_temperature')
else 'number.wago_vent_forrad_temperatur_sensor_write' %}
{{ states(x) }}
BTW, what is the reason for copying the sensor’s value to a number entity?
@hawksj Even though it wouldnt have solved this problem, this is indeed a very good solution if you change temperature sensor in the future. You could easily just change the template and all automation would go unchanged. Thanks for the tip!
@123 Nice to see the syntax for variable and if clause, thanks.
Yes I have the automation split up between two computers at home. One Wago-PLC running the heating and critical things collecting sensor data via ModbusRTU. And one Home Assistant Core with a custom_component towards Wago-PLC. And now I just wanted to add a (temporary) additional temperature sensor for one very offsite location so that the Wago-PLC could regulate the heating there.