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

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:

timer:
  brightness_timer:
    duration: '00:00:03'

In automations.yaml:

- alias: 'Bathroom light brightness'
  trigger:
  - platform: state
    entity_id: light.your_bathroom_light
    to: 'on'
  action:
  - service: light.turn_on
    entity_id: light.your_bathroom_light
    data_template:
      brightness_pct: >
        {% if is_state('timer.brightness_timer','active') %}
          100
        {% elif now().hour > 20 or now().hour < 7 %}
          15
        {% else %}
          50
        {% 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'
  trigger:
  - platform: state
    entity_id: light.your_bathroom_light
    to: 'off'
  action:
  - 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') %}
100
{% elif 18 >= now().hour < 23 %}
50
{% elif now().hour >= 23 or now().hour < 7 %}
15
{% else %}
100
{% 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?

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.

Yea that’s what I was afraid of.

So I kind of got this to work, but the code isn’t nearly as sexy as what you have all been showing me.

The following template did not work as expected. Whenever I turned to light on after 7pm, it just came on to 100%.

  - service: light.turn_on
    entity_id: light.master_bathroom
    data_template:
      brightness_pct: >
        {% if is_state('input_boolean.dim_cancel','on') %}
        100
        {% elif 19 >= now().hour < 23 %}
        50
        {% elif now().hour >= 23 or now().hour < 6 %}
        15
        {% else %}
        100
        {% endif %}

It’s highly probable that I don’t/didn’t have something setup properly, but I couldn’t figure it out.

However with these automations, timer and input boolean…I’ve managed to make this work.

edit: (see the august 13th post for all code in one place).

#############
#automations#
#############

- alias: 'dim_timer_started'
  trigger:
  - platform: event
    event_type: timer.started
    event_data:
      entity_id: timer.dim_cancel
  action:
  - service: input_boolean.turn_on
    entity_id: input_boolean.dim_cancel

- alias: 'dim_timer_finished'
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.dim_cancel
  action:
  - service: input_boolean.turn_off
    entity_id: input_boolean.dim_cancel

#########################
#Master Bath Evening Dim#
#########################
- id: mbath_evening
  alias: MBathroom Evening
  initial_state: true
  trigger:
  - platform: state
    entity_id: light.master_bathroom
    from: 'off'
    to: 'on'
  condition:
  - condition: time
    after: '19:30:00'
    before: '23:00:00'
  action:
  - service: light.turn_on
    entity_id: light.master_bathroom
    data:
      brightness_pct: 50
  - condition: state
    entity_id: input_boolean.dim_cancel
    state: 'on'
  - service: light.turn_on
    entity_id: light.master_bathroom
    data:
      brightness_pct: 100

(I’ve setup another automation for the overnight dim level as well).

################
#input booleans#
################

input_boolean:
  dim_cancel:
    name: Auto Dimming Cancel
    initial: off
#######
#timer#
#######
timer:
  dim_cancel:
    duration: '00:00:02'

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.

Thank you everyone for your input! Super helpful!