Milor
(Milor)
1
Excuse the use of language. Because I am using a translator: /
This my automation:
alias: Tramo Actual
description: ''
trigger:
- platform: state
entity_id: sensor.electricperiod
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Valle
sequence:
- type: turn_on
device_id: 3b9501733261d7713019e95931292c2f
entity_id: light.xiaomi_gateway_light
domain: light
brightness_pct: 100
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Llana
sequence:
- type: turn_on
device_id: 3b9501733261d7713019e95931292c2f
entity_id: light.xiaomi_gateway_light
domain: light
brightness_pct: 50
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Punta
sequence:
- type: turn_on
device_id: 3b9501733261d7713019e95931292c2f
entity_id: light.xiaomi_gateway_light
domain: light
brightness_pct: 10
default: []
mode: single
TESTING and ERROR
alias: Tramo Actual
description: ''
trigger:
- platform: state
entity_id: sensor.electricperiod
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Valle
sequence:
- type: turn_on
device_id: 3b9501733261d7713019e95931292c2f
entity_id: light.xiaomi_gateway_light
domain: light
brightness_pct: 50
rgb_color: [0,0,255]
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Llana
sequence:
- type: turn_on
device_id: 3b9501733261d7713019e95931292c2f
entity_id: light.xiaomi_gateway_light
domain: light
brightness_pct: 50
rgb_color: [0,255,0]
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Punta
sequence:
- type: turn_on
device_id: 3b9501733261d7713019e95931292c2f
entity_id: light.xiaomi_gateway_light
domain: light
rgb_color: [255,0,0]
brightness_pct: 50
default: []
mode: single
ERROR: Message malformed: extra keys not allowed @ data[‘rgb_color’]
I got an error, I can’t quite understand what I’m doing wrong … How can I put the light in a different color?
Milor
(Milor)
3
Thanks, I think I got it right now although it looks a little different than in my HA.
I hope someone can help me. And apologize for my mistake.
123
(Taras)
4
Try this version that uses a service call to set the light instead of a device action.
alias: Tramo Actual
description: ''
trigger:
- platform: state
entity_id: sensor.electricperiod
condition: []
action:
- choose:
- conditions: "{{ trigger.to_state.state == 'Valle' }}"
sequence:
- service: light.turn_on
target:
entity_id: light.xiaomi_gateway_light
data:
brightness_pct: 50
rgb_color: [0,0,255]
- conditions: "{{ trigger.to_state.state == 'Llana' }}"
sequence:
- service: light.turn_on
target:
entity_id: light.xiaomi_gateway_light
data:
brightness_pct: 50
rgb_color: [0,255,0]
- conditions: "{{ trigger.to_state.state == 'Puna' }}"
sequence:
- service: light.turn_on
target:
entity_id: light.xiaomi_gateway_light
data:
brightness_pct: 50
rgb_color: [255,0,0]
default: []
mode: single
2 Likes
Milor
(Milor)
5
It works perfect, I have tried it. But I take the opportunity to learn how the scenes were going and it also works for me.
Thanks a lot.
Change the light of a XIAOMI HUB according to the current electrical section (Spain) the sensor code I took it from: home-assistant-config/energy.yaml at 63f561a13fb235c67dd1ea6dfd0a0867517e3c57 · danimart1991/home-assistant-config · GitHub
automations.yaml
alias: Tramo Actual
description: ''
trigger:
- platform: state
entity_id: sensor.electricperiod
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Valle
sequence:
- scene: scene.cortesia_en_verde
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Llana
sequence:
- scene: scene.cortesia_en_amarillo
- conditions:
- condition: state
entity_id: sensor.electricperiod
state: Punta
sequence:
- service: light.turn_on
target:
entity_id: light.xiaomi_gateway_light
data:
brightness_pct: 50
color_name: red
default: []
mode: single
scenes.yaml
- id: '1625160791094'
name: Cortesia en Rojo
entities:
light.xiaomi_gateway_light:
supported_color_modes:
- hs
color_mode: hs
brightness: 255
hs_color:
- 0
- 100
rgb_color:
- 255
- 0
- 0
xy_color:
- 0.701
- 0.299
friendly_name: Cortesía
supported_features: 17
state: 'on'
- id: '1625161305309'
name: Cortesia en Amarillo
entities:
light.xiaomi_gateway_light:
supported_color_modes:
- hs
color_mode: hs
brightness: 255
hs_color:
- 60
- 100
rgb_color:
- 255
- 255
- 0
xy_color:
- 0.444
- 0.517
friendly_name: Cortesía
supported_features: 17
state: 'on'
- id: '1625161364732'
name: Cortesia en Verde
entities:
light.xiaomi_gateway_light:
supported_color_modes:
- hs
color_mode: hs
brightness: 255
hs_color:
- 120
- 100
rgb_color:
- 0
- 255
- 0
xy_color:
- 0.172
- 0.747
friendly_name: Cortesía
supported_features: 17
state: 'on'
magomao
(Magomao)
6
Is a HASSIO bug
follow this issue
123
(Taras)
7
It wasn’t a bug 2 years ago when this topic was created.
1 Like