I know there is states.sensor.entity.last_changed but sometimes it would be nice to get the actual state the entity had before the change or the last time an entity changed to a specific state.
Example:
- An awesome 3d printer integration exposes the remaining time of a currently running 3d print in minutes (e.g.
sensor.printer_time_remaining
). - There is also
sensor.printer_state
with the printers current state (some of the possible states arefailed
,finish
,idle
andrunning
)
Idea:
- Every now and then a 3d printer needs maintenance (cleaning the printing chamber, cleaning and greasing rods, bearings, etc.), which heavily depends on usage.
- Therefore it would be nice to track the total printing time since the last maintenance.
- To active this, one could create an automation which adds the
sensor.printer_time_remaining
to an input_number helper wheneversensor.printer_state
changes torunning
.
Problem:
- When the print fails (e.g.
sensor.printer_state
changes tofailed
) the previously added time has to be reduced again. - As soon as the print fails the necessary information isn’t available anymore since the remaining time changed to 0.
- If
sensor.printer_time_remaining.last_state
was available, one could use this to instead of crating an additional helper to temporarily store said time. - Since the information needed is already available (e.g. in the sensors history), creating helpers seems even more… well… what the heck?!