Hi,
I am at a loss and mainly due to having no experiencing with creating these from scratch. I have tried examples shown in the forums but not having any luck and suspect it is easy but perhaps missing the obvious.
The Goal: I have a power plug that I would like to manually control from Lovelace using a Timer. Concept: To be able to manually type (each time) how many minutes for it to remain on and then for it to turn off. Device Name = Meross_Plug_05 - outlet Entity ID = switch.meross_plug_05_outlet
Any chance someone could assist me with correct method in getting this working? Once I get one done, I am sure I can then apply principle to other simular tasks?
or forgett that and use the line with the Timestamp as “template trigger”
description: "Turn off after X min, where X = text input in min"
mode: single
trigger:
- platform: template
value_template: "{{ now().timestamp() + (input_text.time_in_min|float * 60) }}"
condition: []
action:
- service: switch.turn_off
data: {}
target:
entity_id: switch.meross_plug_05_outlet
Edit: I think you may have to first set some datetime to now when changing the timer. Because otherwise it is always x min till now()…would never trigger.
A shorter approach than using a timer is to create an input number helper like
input_number:
meross_05_on:
name: meross_05_on
min: 0
max: 120
step: 1
mode: box # uncomment this/drop it if you want to have a slider
unit_of_measurement: min.
I suspect this is where I am getting lost. So now I have two things i.e. the The Helper and the Automation.
On my Homepage, I added two entity cards, one for the Helper for selecting the time to set and one for the Automation. I suspect that this is not what I am meant to do as it doesn’t work?
Agghhh. Silly me, I didn’t restart HA. Once I did that it “WORKED”. Excellent and now have something that is making some sense. By you writing the correct code helped a lot so far…
So would I be right in saying that I would need a min of 3 Entity Cards i.e.
1: Plug On/Off button. To turn the plug on.
2: The Helper for inputting preferred duration in advance
and
3:The Automation for activating it?
Apologies in advance for such what may seem basic questions. First time around is not so obvious.
In my case and as I want to be able to quickly turn On/Off the Automation without going to Automation’s as it won’t always be used.
Switch On Card: If I do this, then by default it turns everything within card on (incl the automation). As I may not always use the Timer, I can just use the On/Off switch for the Plug that I added to the card. I hope that makes sense?
EXTRA QUESTION (please): Is there a way to see how long is left before it turns off i.e. a countdown timer within the card?
So if you have 1 automation for 1 plug with 1 helper then you would not need to turn the automation off.
Because the trigger timestamp would not change until you use the input again.
But sure you can do it that way.
Just play around with it…
For the Time that is left to see, I personaly use the bar timer card installed from hacs. Works great for me.
Sorry, yes, at this point I am using @pedolsky example.
Just need to get my head around the basics of that one. I’ll play around with your one tomorrow as no doubt will learn a little more i.e. many ways to tie a pair of shoelaces.
This chat was to get anything working and and thanks to you both have now been successful. I have wasted many hours trying to figure it out by myself prior to posting here and failed! Now I just need to build on this. I’ll also try work out how to integrate the
@ [pedolsky: Thanks for the “Timer Helper” suggestion & code.
Now, don’t laugh but how do I see the time left? I added both of those and then added to Lovelace as Entities. Timer shows as Idle and the Automation shows as “On”