I’ve been looking for a way to add attributes to a sensor reading but found a dead end.
I have a lightning sensor connected that sends distance and energy readings through json over mqtt HA. Each reading is being picked up by a sensor and thus the relation between both is gone. I’ve tried to correct that through influx and mysql and even though I can get the readings back, I can’t display them together in a table ( list card ).
Query:
SELECT i.created as datetime, i.state as distance, s.state as energy
FROM states i
LEFT JOIN states s ON i.created = s.created
WHERE i.entity_id = ‘sensor.lightning_distance’ AND s.entity_id = ‘sensor.lightning_energy’
AND i.state != ‘unknown’ AND s.state != ‘unknown’
AND i.state != 0 AND s.state != 0
ORDER BY datetime DESC
As a template sensor I can only select 1 column and in influxdb I can’t join them either. I would like to create a list with the last 10 lightning strikes together with distance and energy.
I’ve seen as the only solution this post which is python script that needs to be run to at intervals.
Does someone know a way around that to append attribute data to a sensor on recording?