When you walk into the bathroom in the evening, you turn on the switch and it brightens to some level less than 100%. That’s the user’s first ‘hands-on’ with the switch. Now the user must operate the switch two more times: turn off, then turn back on. That’s a total of three operations to get the light to maximum brightness.
Here’s the catch. The timer-based solution requires the user to perform the on/off/on sequence within a short time span (all done within ~ 3 seconds). What the user cannot do is turn on the light and hesitate before deciding the light needs to be brighter. By that point, the additional off->on operation is too late. Now they have to start from scratch which means they have to turn the light off first, then turn it on/off/on (that’s four operations, five if you count the first turn-on). To compensate, you can extend the timer’s duration to, perhaps, 5 seconds. However, you don’t want to extend it for too long because that can make it susceptible to other problems.
I agree that the rest of what I explained (more than 3 taps) applies only if the timer is started at the first turn-on (which is how the automation is shown). Changing it to start the timer when the switch is turned off is a good idea.
Okay so these templates are still a bit of a mystery to me. I’ve used a few, but I’m still learning whenever a new one comes up…
Can you explain the above part to me? do I need to add something in the parentheses?
You don’t need to add anything between the parentheses. Now() is just the syntax for the current date and time. Now().hour is the syntax for the number of the hour right now.
Your first example wouldn’t work the way you think it might and the second example wouldn’t work at all.
The function now().hour returns the current hour as an integer value. So if the current time is 21:45 then now().hour will report 21.
What it won’t do is report 21.75. now().hour reports the current, not some sort of floating-point representation of the time. That’s why your first example:
19.5 >= now().hour < 23
won’t work correctly. If the current time is 19:45, it lies between 19:30 and 23:00. However, it won’t in your template because now().hour will report 19:45 as 19.
The second example contains invalid syntax. 19:30 is not an integer value so you can’t use it in a comparison with other integer values.
As I stated, this code could probably be much sexier and more condensed with the templates, but for now this is working for me.
I’ll probably come back to the templating issue in time.
Okay so in case anyone else is reading this, I did get this working.
Within the ISY, I set default on levels during specific hours. So in the evenings/night the lights turn on at 50% and overnight they come on at 15%
Then with every event of the lights turning off at the switch, the 2 second timer is started. If the lights get turned on while the timer is active, they come on at full brightness.
The only down side is if you want to go back to dim levels, you have to turn off the lights and wait at least 2 seconds to turn them back on. Not a huge deal really, but I can’t think of any other way around this.
Overall I’m super happy with this setup (as is my wife…score!). I actually kind of like the “secret handshake” of it all. I would like all the automation-ing to be within HA, but the default on levels being in the ISY is actually pretty great. They come on directly to the preferred level rather than on at full brightness, then quickly changing to the preferred dim level.
So thank you 123 Taras, Emphyrio, FunkyBoT, and sparkydave for all your help with this.
If anyone wants to see the code, let me know. It’s pretty straightforward, actually, but I’m happy to post it here.
It would be good if you did post it here for anyone looking in the future. I’d be interested to see the code to see if it can help improve/complement what I have
So here is the code. The actual dimming of the lights in the evening and the overnight hours happens in my ISY program as I stated earlier.
This dimming could be achieved with one automation with a template action (if you read above, I never could get that to work…not smart enough with templates) or a couple different automations.
######This goes in your automation file or under automation: in your config file
#########################
#Bathroom Dimming, Timer#
#########################
############Timer turns on every time the light turns off between 730p and 6a
- id: mbath_eve_begin_timer
alias: MBathroom Evening Begin Timer
initial_state: true
trigger:
- platform: state
entity_id: light.master_bathroom
from: 'on'
to: 'off'
condition:
- condition: time
after: '19:30:00'
before: '06:00:00'
action:
- service: timer.start
entity_id: timer.dim_cancel
######If light turns on and timer is active, then it sets the lights to 100%
- id: mbath_evening
alias: MBathroom Evening
initial_state: true
trigger:
- platform: state
entity_id: light.master_bathroom
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: timer.dim_cancel
state: 'active'
action:
- service: light.turn_on
entity_id: light.master_bathroom
data:
brightness_pct: 100
#########This goes in your config file##########
###########Timer Code 2 seconds
timer:
dim_cancel:
duration: '00:00:02'
Hope this helps anyone reading. I’m really loving this automation. Thanks again everyone that helped out.
Thanks so much for the solution, it works flawless. I’m using a slightly modified version of the code to turn all my garden lights on using the alfresco light switch. So I can just turn the alfresco lights on/off with the standard wall switch with a tasmotized sonoff basic or by turning the switch off and on again within 2 seconds all the garden lights will come on too. Now wife is happy as well