I have for some time been trying to set up automations for my lights (tradfri) with different brightness based on time. I have set up different automations with time conditionals for after 07:00:00 before 23:59:59 and after 00:00:00 before 07:59:59 but when I insert brightness_pct: (value) on a line above the entity_I’d in the service data field the automation stops working. Without brightness it works as it is supposed to.
I have experienced this problem for a long time and thought it might be solved in future releases, but since it is still bothering me it looks like I have to add to the pile of posts in the forum.
I know there are scripts and templates that solves what I’m trying to achieve, but I am only using the automation ui. And want to continue doing so in order to keep automations easily maintainable.
Well, it looks ok to me. When you try this, where/when do you see errors? Or do you not see errors and it just doesn’t work? If you’re able to save the automation with this, can you see what it looks like in the yaml file, and possibly post that? I don’t use the automation editor, so not sure why what you show doesn’t work.
I tried to make sure that I did not make false claims and tried to set up yet another automation.
Usuallly it causes a non working set of automations when I combine time conditional and brightness_pct, but to my surprise my last automation “Lys toalett night” did not mess up and the automation "Lys toalett day is still working.
But there are three other sets of day and night automations that does not work, unless i remove the brightness_pct. (It also beaves the same way with the regular brightness 0-255)
I also noticed that the ui-editor reformats values with inconsistent encapsulation. Look at all locations of time and notice that some have ’ while other does not. I went through the file and placed ’ on all occourences of time, but after having editet an automation in the ui it all went back to the inconsistent state.
I have pasted my whole automations.yaml here.
- id: '1548785885000'
alias: Lys plantelys off
trigger:
- at: '21:00:00'
platform: time
condition: []
action:
- data:
entity_id: light.plantelys
service: light.turn_off
- id: '1548787329983'
alias: Lys plantelys on
trigger:
- at: 08:00:00
platform: time
condition: []
action:
- data:
entity_id: light.plantelys
service: light.turn_on
- id: '1548787451454'
alias: Lys terrasse off
trigger:
- at: 00:00:00
platform: time
condition: []
action:
- data:
entity_id: light.terrasse
service: light.turn_off
- id: '1548787611548'
alias: Lys terrasse on
trigger:
- event: sunset
platform: sun
condition: []
action:
- data:
entity_id: light_terrasse
service: light.turn_on
- id: '1548787710871'
alias: Lys hage off
trigger:
- event: sunrise
platform: sun
condition: []
action:
- data:
entity_id: switch.lys_hage
service: switch.turn_off
- id: '1548787754899'
alias: Lys hage on
trigger:
- event: sunset
platform: sun
condition: []
action:
- data:
entity_id: switch.lys_hage
service: switch.turn_on
- id: '1548787839196'
alias: Lys veranda on
trigger:
- entity_id: binary_sensor.pir_veranda
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
entity_id: switch.lys_veranda
service: switch.turn_on
- id: '1548787891801'
alias: Lys veranda off
trigger:
- entity_id: binary_sensor.pir_veranda
for: 00:05:00
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: switch.lys_veranda
service: switch.turn_off
- id: '1548788131090'
alias: Lys entre on
trigger:
- entity_id: binary_sensor.pir_entre
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
entity_id: light.entre
service: light.turn_on
- id: '1548788215043'
alias: Lys entre off
trigger:
- entity_id: binary_sensor.pir_entre
for: 00:02:00
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.entre
service: light.turn_off
- id: '1548788618767'
alias: Lys bua off
trigger:
- entity_id: binary_sensor.pir_bua
for: 00:15:00
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
entity_id: light.bua
service: light.turn_off
- id: '1548795677739'
alias: Lys bua on
trigger:
- entity_id: binary_sensor.pir_bua
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
entity_id: light.bua
service: light.turn_on
- id: '1548795749589'
alias: Lys aquarium off
trigger:
- at: '23:00:00'
platform: time
condition: []
action:
- data:
entity_id: switch.lys_aquarium
service: switch.turn_off
- id: '1548795820146'
alias: Lys aquarium on
trigger:
- at: '12:00:00'
platform: time
condition: []
action:
- data:
entity_id: switch.lys_aquarium
service: switch.turn_on
- id: '1548795943113'
alias: Lys kitchen on 7-23
trigger:
- entity_id: binary_sensor.pir_kitchen
from: 'off'
platform: state
to: 'on'
condition:
- after: 07:00:00
before: '22:59:59'
condition: time
action:
- data:
brightness_pct: 100
entity_id: light.kitchen
service: light.turn_on
- id: '1548796005176'
alias: Lys kitchen off
trigger:
- entity_id: binary_sensor.pir_kitchen
for: 00:15:00
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.kitchen
service: light.turn_off
- id: '1548796266933'
alias: Lys gang on 00-07
trigger:
- entity_id: binary_sensor.pir_gang
from: 'off'
platform: state
to: 'on'
condition:
- after: 00:00:00
before: 06:59:59
condition: time
action:
- data:
brightness_pct: 10
entity_id: light.gang
service: light.turn_on
- id: '1548796332064'
alias: Lys gang off
trigger:
- entity_id: binary_sensor.pir_gang
for: 00:05:00
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.gang
service: light.turn_off
- id: '1548796401433'
alias: Lys spisestue on 7-23
trigger:
- entity_id: binary_sensor.pir_stueost
from: 'off'
platform: state
to: 'on'
condition:
- after: 07:00:00
before: '23:00:00'
condition: time
action:
- data:
brightness_pct: 100
entity_id: light.spisestue
service: light.turn_on
- id: '1548796464197'
alias: Lys spsiestue off
trigger:
- entity_id: binary_sensor.pir_stueost
for: 00:30:00
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.spisestue
service: light.turn_off
- id: '1548796566142'
alias: Lys bod on
trigger:
- entity_id: binary_sensor.pir_bod
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
entity_id: light.bod
service: light.turn_on
- id: '1548796621769'
alias: Lys bod off
trigger:
- entity_id: binary_sensor.pir_bod
for: 00:02:00
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.bod
service: light.turn_off
- id: '1548796686594'
alias: Lys sauna on
trigger:
- entity_id: switch.ovn_sauna
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
entity_id: light.sauna
service: light.turn_on
- id: '1548796746841'
alias: Lys sauna off
trigger:
- entity_id: switch.ovn_sauna
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.sauna
service: light.turn_off
- id: '1548796819052'
alias: Sauna auto off
trigger:
- entity_id: switch.ovn_sauna
for: 04:00:00
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
entity_id: switch.ovn_sauna
service: switch.turn_off
- id: '1548844649466'
alias: Lys toalett on
trigger:
- entity_id: binary_sensor.pir_toalett
from: 'off'
platform: state
to: 'on'
condition:
- after: 08:00:00
before: '23:59:59'
condition: time
action:
- data:
brightness_pct: 100
entity_id: light.toalett
service: light.turn_on
- id: '1548844718862'
alias: Lys toalett off
trigger:
- entity_id: binary_sensor.pir_toalett
for: 00:05:00
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.toalett
service: light.turn_off
- id: '1548899908163'
alias: Lys gang on 07-24
trigger:
- entity_id: binary_sensor.pir_gang
from: 'off'
platform: state
to: 'on'
condition:
- after: 07:00:00
before: '23:59:59'
condition: time
action:
- data:
brightness_pct: 100
entity_id: light.gang
service: light.turn_on
- id: '1548900953061'
alias: Lys spisestue 23-7
trigger:
- entity_id: binary_sensor.pir_stueost
from: 'off'
platform: state
to: 'on'
condition:
- after: '23:00:00'
before: 06:59:59
condition: time
action:
- data:
entity_id: light.spisestue
service: light.turn_on
- id: '1548901107723'
alias: Lys kitchen 23-7
trigger:
- entity_id: binary_sensor.pir_stueost
from: 'off'
platform: state
to: 'on'
condition:
- after: '23:00:00'
before: 06:59:59
condition: time
action:
- data:
brightness_pct: 10
entity_id: light.kitchen
service: light.turn_on
Again, can’t comment on how well (or not) the automation editor works. But I can say, I recently discovered that times in time condition before and after parameters seem to need to be quoted, whereas times in time trigger at parameters do not. It’s probably safest to always quote times. If the editor isn’t doing that properly, then that sounds like a bug.