Yes, that’s what my suggestion would accomplish. Sorry if I misunderstood. Based on this comment,
, I got the impression that you were only interested in how the graph was displayed in the Frontend. Your existing sensor and this new sensor could both be shown on a single card to achieve a look similar to the image you posted, but this would not change the timestamps in HA’s history
.
You may be able to inject a timestamp from Node-RED as I had suggested earlier, but how feasible this is would depend on the means in which the sensor is supplied from NR to HA. Also, the now()
method I previously posted would fail on the first day of each month, so it would need to be more like this:
flow:
[{"id":"ff84eecf.1ba04","type":"change","z":"93de0bd6.350048","name":"msg.template.{{ (now() | as_timestamp - 86400) | timestamp_custom('%d %a, %-I:%M %p') }}","rules":[{"t":"set","p":"template","pt":"msg","to":"{{ (now() | as_timestamp - 86400) | timestamp_custom('%d %a, %-I:%M %p') }}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":2600,"wires":[["9aa72680.b3dc88"]]},{"id":"9aa72680.b3dc88","type":"api-render-template","z":"93de0bd6.350048","name":"","server":"e9beaddb.fc24e","template":"","resultsLocation":"payload.day","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":1360,"y":2600,"wires":[["708ccc2b.ede0c4"]]},{"id":"feb9a831.1f6878","type":"change","z":"93de0bd6.350048","name":"msg.payload.{\"power_usage\": \"data\"}","rules":[{"t":"set","p":"payload","pt":"msg","to":"{ \"power_usage\": \"data\" }","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":2540,"wires":[["ff84eecf.1ba04"]]},{"id":"708ccc2b.ede0c4","type":"debug","z":"93de0bd6.350048","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1370,"y":2660,"wires":[]},{"id":"51e547be.886038","type":"inject","z":"93de0bd6.350048","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":1030,"y":2480,"wires":[["feb9a831.1f6878"]]},{"id":"e9beaddb.fc24e","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
If you could bring this in to HA as a sensor
with the “power_usage” key (your fetched power usage data) as the state
and the “day” key as an attribute
you’d at least have that as secondary information to reference in HA’s history
. You would probably still need to customize your card in the Frontend to display this attribute
instead of last_changed
/ last_updated
though.