Just for completeness, and to help anyone else who is trying to get dimming and brightening working on bulbs, here’s the solution I used:
I created 3 vars in configuration.yaml:
var:
dimmer_down:
friendly_name: "dimmer_down"
initial_value: 0
dimmer_up:
friendly_name: "dimmer_UP"
initial_value: 0
study_pct:
friendly_name: "study_pct"
initial_value: 10
Then I created several automations to handle the up and down buttons being held and released:
They basically set the “dimmer_down” and “dimmer_up” variables to a 1 when the up or down buttons are held
- id: '1611139744189'
alias: PhilipsDimmerUpHold
description: ''
trigger:
- platform: device
domain: mqtt
device_id: b1c7bded8a06fdeb1befc4e5dcd0e87e
type: action
subtype: up-hold
discovery_id: 0x00178801080d9758 action_up-hold
condition: []
action:
- service: var.set
data:
entity_id: var.dimmer_up
value: 1
entity_id: var.dimmer_up
mode: single
- id: '1611139985457'
alias: PhilipsDimmerUpHold-Released
description: ''
trigger:
- platform: device
domain: mqtt
device_id: b1c7bded8a06fdeb1befc4e5dcd0e87e
type: action
subtype: up-hold-release
discovery_id: 0x00178801080d9758 action_up-hold-release
condition: []
action:
- service: var.set
data:
entity_id: var.dimmer_up
value: 0
entity_id: var.dimmer_up
mode: single
- id: '1610974443418'
alias: PhilipsDimmerDownHold
description: ''
trigger:
- platform: device
domain: mqtt
device_id: b1c7bded8a06fdeb1befc4e5dcd0e87e
type: action
subtype: down-hold
discovery_id: 0x00178801080d9758 action_down-hold
condition: []
action:
- service: var.set
data:
entity_id: var.dimmer_down
value: 1
entity_id: var.dimmer_down
mode: single
- id: '1610976772292'
alias: PhilipsDimmerDownHold-Released
description: ''
trigger:
- platform: device
domain: mqtt
device_id: b1c7bded8a06fdeb1befc4e5dcd0e87e
type: action
subtype: down-hold-release
discovery_id: 0x00178801080d9758 action_down-hold-release
condition: []
action:
- service: var.set
data:
entity_id: var.dimmer_down
value: 0
entity_id: var.dimmer_down
mode: single
Then I created the automations to react to the “dimmer_down” and “dimmer_up” variables changing to a 1:
- id: '1611139257625'
alias: StudyLightLoop_BRIGHTEN
description: ''
trigger:
- platform: state
entity_id: var.dimmer_up
from: '0'
to: '1'
condition: []
action:
- service: light.turn_on
data: {}
entity_id: light.studylightbulb
- delay: '1'
- repeat:
until:
- condition: numeric_state
entity_id: var.dimmer_up
below: '1'
sequence:
- service: script.setstudybulb1brightnessfrom_study_pct
data: {}
entity_id: light.studylightbulb
- delay: '0.5'
- service: var.set
data:
value_template: '{{ (states(''var.study_pct'') | int) + 10 }}'
entity_id: var.study_pct
mode: single
- id: '1610977578691'
alias: StudyLightLoop_DIM
description: ''
trigger:
- platform: state
entity_id: var.dimmer_down
from: '0'
to: '1'
condition: []
action:
- service: light.turn_on
data: {}
entity_id: light.studylightbulb
- delay: '1'
- repeat:
until:
- condition: numeric_state
entity_id: var.dimmer_down
below: '1'
sequence:
- service: script.setstudybulb1brightnessfrom_study_pct
data: {}
entity_id: light.studylightbulb
- delay: '0.5'
- service: var.set
data:
value_template: '{{ (states(''var.study_pct'') | int) - 10 }}'
entity_id: var.study_pct
mode: single
And finally, as I’m using the brightness_pct, I need to keep the study_pct value between 0 and 100, so 2 more automations:
- id: '1611141225253'
alias: Keep_study_pct below 101
description: ''
trigger:
- platform: numeric_state
entity_id: var.study_pct
above: '100'
condition: []
action:
- service: var.set
data:
value: 100
entity_id: var.study_pct
mode: single
- id: '1611141263301'
alias: Keep_study_pct above -1
description: ''
trigger:
- platform: numeric_state
entity_id: var.study_pct
below: '0'
condition: []
action:
- service: var.set
data:
value: 0
entity_id: var.study_pct
mode: single
And finally, just to keep this all in one place, here’s the script that is called to apply the study_pct value to the bulb:
setstudybulb1brightnessfrom_study_pct:
alias: SetStudyBulb1BrightnessFrom_study_pct
sequence:
- service: light.turn_on
data_template:
entity_id: light.studylightbulb
brightness_pct: '{{ (states(''var.study_pct'')) |int }}'
mode: single
icon: mdi:bulb