I’m looking for some help and ideas. I have an Enbrighten Z-Wave switch in a bathroom, connected to an exhaust fan.
I would two things:
Retain local control so HA is not needed for simply turning it on and off.
Pressing the on button (or something similar) while it’s already running turns it off after 20 minutes.
Here’s my current code. The issue I’m running into with HA is that it’s starting the timer when I first turn on the fan, which I’m guessing is because:
The switch immediately turns on.
HA starts the action because of the On press.
HA interrogates the switch and sees that it is on, so it carries on.
Can any of you give me suggestions for how to do what I want?
Here’s the code I currently have, for reference:
alias: "Bathroom Exhaust: 20 Minute Run Timer"
description: ""
trigger:
- platform: device
type: turned_on
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
condition:
- condition: state
entity_id: switch.in_wall_paddle_switch_qfsw_700s_4
state: "on"
action:
- device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: select
entity_id: c252e9f450e682b0c890d1693c97c4a2
type: select_option
option: Green
alias: Change LED to Green
- delay:
hours: 0
minutes: 20
seconds: 0
milliseconds: 0
- type: turn_off
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
- device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: select
entity_id: c252e9f450e682b0c890d1693c97c4a2
type: select_option
option: White
alias: Change LED to White
mode: single
This also doesn’t seem to do the trick. I tried to have this trigger on an on-press (works), then two wait-for things (waiting for on and off presses) running in parallel, but instead what happens is:
First on press, fan turns on.
Second on-press, LED turns green, fan turns off after N time. LED silently set back to white. (This is good/as-desired.)
Press on, fan turns on. Press off, fan turns off. Press on again, fan turns on and LED turns green, then fan turns off after N time. (This is not good, it’s as if the wait-for off and stop didn’t stop the whole action; only that branch.)
Code:
alias: "Bathroom Exhaust: 20 Minute Run Timer"
description: ""
trigger:
- platform: device
type: turned_on
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
condition: []
action:
- parallel:
- alias: Wait for On then Execute
sequence:
- wait_for_trigger:
- platform: device
type: turned_on
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
alias: Wait for On
- device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: select
entity_id: c252e9f450e682b0c890d1693c97c4a2
type: select_option
option: Green
alias: Set LED to Green
- delay:
hours: 0
minutes: 0
seconds: 15
milliseconds: 0
- type: turn_off
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
- device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: select
entity_id: c252e9f450e682b0c890d1693c97c4a2
type: select_option
option: White
alias: Set LED to White
- alias: Wait for Off then Stop
sequence:
- wait_for_trigger:
- platform: device
type: turned_off
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
alias: Wait for Off
- stop: Fan turned off.
mode: single
First, it turns out that these switches (Enbrighten 58433) support scene selection via long press, double-click, and triple-click.
Since I was having so many problems detecting a single-click only when on, I changed my automation to start the timer on double-click.
Code for this is as follows. Note that the one second delay between turning off the fan and setting the LED back to White is due to latency in the switch itself. If I don’t do this, the LED on the switch will flash white as the fan is turning off.
alias: "Upstairs Bathroom: Exhaust Fan Timer"
description: ""
trigger:
- platform: device
device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: zwave_js
type: event.value_notification.central_scene
property: scene
property_key: "001"
endpoint: 0
command_class: 91
subtype: Endpoint 0 Scene 001
value: 3
condition:
- condition: device
type: is_on
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
action:
- device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: select
entity_id: c252e9f450e682b0c890d1693c97c4a2
type: select_option
option: Green
alias: Set LED to Green
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
- type: turn_off
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: select
entity_id: c252e9f450e682b0c890d1693c97c4a2
type: select_option
option: White
alias: Set LED to White
mode: single
I also used this automation on off-press to stop/start the timer one (if it’s running) to reset it, and reset the LED to white. It only acts if the LED is set to green, using this as an indicator that the timer is still executing. This is to handle if the fan is manually switched off while the timer is counting down:
alias: "Upstairs Bathroom: Reset Exhaust Fan Switch on Manual Off"
description: >-
Resets the upstairs bathroom exhaust fan LED to white and stops/starts the
timer automation. Uses the state of the LED (if green) to indicate if timer
was manually interrupted.
trigger:
- platform: device
type: turned_off
device_id: ea7e58105c13a179e2392e7a0f5c52d2
entity_id: 333e5d5070e291ce16b4cc0c2f53a050
domain: switch
condition:
- condition: device
device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: select
entity_id: c252e9f450e682b0c890d1693c97c4a2
type: selected_option
option: Green
action:
- device_id: ea7e58105c13a179e2392e7a0f5c52d2
domain: select
entity_id: c252e9f450e682b0c890d1693c97c4a2
type: select_option
option: White
- service: automation.turn_off
metadata: {}
data:
stop_actions: true
target:
entity_id: automation.bathroom_exhaust_fan_timer
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: automation.turn_on
metadata: {}
data: {}
target:
entity_id: automation.bathroom_exhaust_fan_timer
mode: single