I have a heatpump and with
sensors:
- name: HP
unique_id: HPA
slave: 1
address: 2035
input_type: holding
data_type: custom
scan_interval: 2
count: 45
structure: ">HHHHH10xHHHHxxxxxxHHxxH32xHHHHHHL"
in an imported modbus.yaml, I get a sensor which reads 90 bytes every few seconds and gives a string like
0.00,0.00,0.00,0.00,0.00,415.00,402.00,467.00,183.00,414.00,240.00,311.00,0.00,119.00,0.00,0.00,0.00,0.00,8449.00
all very straightforward as sensor.hp_2
In Developer | Template I’ve got:
template:
{% set HP=states('sensor.hp_2').split(',') %}
- sensor
- name: "Heating Return Temp"
- state: "{{ HP[0] | float / 10 }}"
- name: "Heating Leaving Temp"
- state: "{{ HP[1] | float / 10 }}"
- name: "DHW Tank Temp"
- state: "{{ HP[6] | float / 10 }}"
and that works as expected splitting the string into an array once then using the array to populate 3 sensors (in reality there will be lots more).
I cannot for the life of me figure out how to make them work as sensors in config.yaml and have scoured the net for examples but it looks like the templating system has changed?
I could do 3 separate splits in 3 separate sensors (done, works) but that’s ugly. It should be 1 split and 1 intermediate array.
Basically, what’s the recommended way to take data from 1 sensor (in this case a comma separated string) and create/update a large number of sensors from that data.
Before I tear even more hair out… can some kind soul point me in the right direction?