SOLVED...Bathroom Lights dim automatically. Great...but what if I need them to be full brightness right now?!?!

That’s brilliant! That’s exactly the kind of out-of-the-box thinking I was looking for!

I’ll give that a shot. I’ve not used a timestamp in a template yet but your code looks very promising.

Thanks sparkydave!
I’ll let you know if it works

I tried the suggestion to check if last_changed is within 2 seconds of now().

I used this:

- alias: 'toggle test'
    platform: state
    to: 'on'
    condition: template
    value_template: '{{as_timestamp(now()) - as_timestamp( < 2 }}'
    service: system_log.write
      message: "Last: {{}}, Now: {{utcnow()}}"
      level: warning

the action is executed even if you simply turn on the light (i.e. you don’t even have to do a quick toggle of on/off/on).

My automation prints last_changed and utcnow() and they are virtually identical. It would appear last_changed is updated the moment the light’s state changes to on.


Building on this train of thought: on ‘turn on’, you could start a 2 second timer. In the condition, you check for timer state = active. If active, then brightness to 100%.

Shoot. But also… Wow! Thanks for doing that testing.

Can one use an event rather than a state change? Would this make any difference? I suspect not, but you never know.

I’m solo with my kiddos for a bit today but can do some experimenting during nap time :slight_smile:

I feel like we’re headed in the right direction but wouldn’t that just turn on full brightness for 2 seconds everytime? Or are you saying in the condition of 123Taras toggle test? (say that 5 times fast)

This reminds me of another person who wanted to toggle one switch in order to activate another switch. The goal was to press on/off/on, all within 3 seconds, on switch A and have that serve as a trigger for activating switch B. Here’s the solution I offered and, yes, it involves the use of a timer:

It’s not a perfect fit for what you want because it requires the switch to be initially off before performing the on/off/on sequence. In other words, off → on/off/on. In your case, the switch is already on, at some dim level. So the sequence to detect would be on → off/on. It may be possible to adapt the solution to meet your needs but I can’t say for sure because I haven’t explored it in depth yet.

Yea I like that.
I’ve got some serious fun ahead of me…

You could also replace the light switch with a momentary one and just do double taps after setting your micro module for momentary rather than latching.
Requires hardware change, but not an additional switch.

I mean like this:

In configuration.yaml:

    duration: '00:00:03'

In automations.yaml:

- alias: 'Bathroom light brightness'
  - platform: state
    entity_id: light.your_bathroom_light
    to: 'on'
  - service: light.turn_on
    entity_id: light.your_bathroom_light
      brightness_pct: >
        {% if is_state('timer.brightness_timer','active') %}
        {% elif now().hour > 20 or now().hour < 7 %}
        {% else %}
        {% endif %}
  - service: timer.start
    entity_id: timer.brightness_timer

I think the success will depend on the responsiveness of your switch; how fast does Home Assistant pick up the changes.

Edit: just read 123’s comment; when your light is already on, this automation needs off-on-off-on to work. Let me think about that some more :slight_smile:

Edit2: I think this is better; when your light is on, tapping off-on should suffice. You’ll just need to start the timer when the light is turned off instead of on. So remove the timer.start from the automation above (the last 2 lines) and instead add this automation:

- alias: 'Timer start at switch-off'
  - platform: state
    entity_id: light.your_bathroom_light
    to: 'off'
  - service: timer.start
    entity_id: timer.brightness_timer
1 Like

I have to say that, from the point of view of an end-user, anything that requires rapidly toggling a switch feels contrived (and inconvenient). You want maximum brightness? First turn the switch off (counter-intuitive) and then quickly turn it back on.

The experience isn’t improved if there’s a need to toggle it twice (off/on/off/on) because then it feels like some sort of secret handshake. It may be fine for activating some rarely-used automation but its onerous for simply turning on a light to full brightness.

You’re right of course. The same argument could be made for double or triple tapping; that’s not very intuitive either. No guest in my house would assume to try that by himself; but for those who know the secret handshake it’s a convenient way to trigger the secret pimple mode :blush:

Double, or even triple, tapping is a different operation and, owing to widespread familiarity with ‘double-clicking’ and ‘double-tapping’, not an unusual experience for most end-users.

In contrast, toggling a two-state switch is an unfamiliar operation for most people. You want to brew stronger coffee? Just turn the coffee machine off and then quickly turn it back on. ?:thinking:?

Here’s an example from my own home. We have UPB light switches (dimmers). They can be configured to turn on at their previous light level. So if the light was at 50% the last time it was on, when you turn on the switch, the light level will be re-established to 50%.

What if you want to override that behavior and set the light to maximum brightness? Well, they are dimmer switches so you can press and hold the top of the rocker-switch and the light will brighten to whatever level you want. However, as a convenience, you can simply double-tap the top of the rocker-switch and the light will instantly increase to maximum brightness. This ‘double-tapping’ operation feels natural and intuitive for maximizing brightness.

You can even program the switch to respond to double-tapping the bottom of the rocker-switch. However, I haven’t found an application for that.

Okay… A lot has happened since this morning… However I haven’t been able to do any HA programming.

So to begin, Emphyrio, I like that 3 second timer idea from when the switch is turned off. I think I’ll try that first when I get a chance. The switches are quite responsive in HA so I’m confident.

The idea is not that it would require the double toggle, just off and then back on. But as you said this actually is for activating a rarely used automation… Most of the time these lights come on at full brightness. Only in the evenings while getting ready for bed do they come on at a lower dim level. And only occasionally during that time do we need full brightness… I do see your point and if one of these solutions doesn’t work pretty much flawlessly, it will only cause frustrations.

Insteon does make a toggle switch like the UPB switches you described. I actually have one in each of my kids rooms. I’ve never really liked them. They just don’t “feel” right. I’m not sure why.
I should mention these are all the old toggle switch style not decora. Perhaps the decora dimmer switches from Insteon would “feel” better.

All in all I’ve got some options to try and I really appreciate you guys helping me out. I will post here with whatever solution works for us.
Pimple-Mode… Engage!

I believe you mean on → off → on.

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 don’t think you are describing it right for the automations I suggested. That is why I edited my post to start the timer with ‘off’. Less taps.

Three taps, minimum.

  1. Turn on. Brightness is less than 100%.
  2. Turn off. Timer is started.
  3. Turn on. Brightness is set to 100%.

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?

I would really appreciate the explanation

If timer is inactive then:

  • If time is between 20h and 7h, turn on the light with brightness 15
  • Any other time, turn on the light with brightness 50.

Ha FunkyBoT beat me to it :slight_smile: Just a small addition about this line:

{% elif now().hour > 20 or now().hour < 7 %}

Home Assistant’s day ends at 00:00 every night. So the first part (>20) covers from 21:00 - 00:00. The second part (<7) covers from 00:00 - 07:00.

Reading you correctly, I think you’ll want something like:

{% if is_state('timer.brightness_timer','active') %}
{% elif 18 >= now().hour < 23 %}
{% elif now().hour >= 23 or now().hour < 7 %}
{% else %}
{% endif %}

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.

1 Like

If I want the first “if” time to be between 7:30pm and 11pm can I do this?

{% elif 19.5 >= now().hour < 23 %}

or would it be like this?

{% elif 19:30 >= now().hour < 23 %}

Or some other way?