Homeautomation and other stuff
I was interested to know how long it was left before my lights would turn off and did not find a good solution. Home Assistant has a timer but unfortunately it does not want to show the remaining time as a sensor so this was not a viable route.
I made a pretty smooth solution, it's cool, I promise!
You can use the Home Assistants timer as your own card, but many times you want the information as part of something else. I usually use Node-Red and their trigger node as a timer and this does not show the remaining time.
Time left before it goes out
I came into contact with the following forum thread that pushed me in the right direction: https://discourse.nodered.org/t/time-remaining-on-trigger-node-debug-or-msg-property/343/7. There, user Andrei builds a flow with two triggers (one of which is called heartbeat) and a function node that shows the remaining time. I initially built on Exactly on Andrei's flow and exposed a node to home assistant but for several reasons this was not a solution that fell to my liking.
The answer comes right away
Unusually, this will not be a guide in the usual sense, but you will have the answer serviced directly with a ready-made solution, that is the allure of subflows!
The first thing to do is to create a counter with step value 1. So every time we count down, it pulls away for a second.
Give the subflower a name and enter the ID of your counter, and then choose how long to count.
In the documentation for the subflow, I have written some useful information. For example, you get new info with residual time from the top node connection (i.e. every second) while the lower node connection gives you timer_triggerd and timer_finsihed at start and stop.
What can I find the node?
You can find the node on node-red's website here: https://flows.nodered.org/flow/b03fbbcdd934854de98f6c034659172d
You're going to have to give it 5 stars!
How do I use it in Home Assistant?
type: entities show_header_toggle: false entities: - entity: light.lounge_lights type: 'custom:multiple-entity-row' name: Gillestugan show_state: false state_color: true tap_action: action: call service service: svc2evnt.fire_event service_data: event_type: custom_event Data: event_id: playroom_lights brightness: 0 secondary_info: entity: counter.lounge_timer name: false unit: seconds
It's almost shamefully simple!
On the left I use lovely multiple-entity-row and as a secondary_info I have entered my counter. It doesn't have to be harder than that.
If you want to use this in a Node-Red feed, here is an example that I have in the basement. Two different sensors record movement, depending on the time of day we send in different light strengths. After X-time without movement, we turn off the lights, but when we move, we extend all the time. The remaining time is visible in the previous image.
Thoughts and suggestions!?
I hope you get the benefit of the subflow, I'm happy to receive pictures and comments if you thought it was good.
THINK ABOUT IT!
After troubleshooting with Dan who wrote the comment below: Remember to go into all the "Home Assistant nodes" in the subflow and change to your Home Assistant server.