Toggle in the scene

Hello everyone I’ve a question, there is a simple way to toggle a light in a scene?

name: Area1
entities:
  light.Bulbo:
    state: on
    brightness: 200
    rgb_color: [244,143,177]
  light.gateway_light_34ce00908135:
    state: on <-- I need toggle
    brightness: 250
    rgb_color: [244,143,177]
  switch.Luce:
    state: off

I know there is the automation way but it give me a lot of errors when I try to give brightness and color paramethers

I believe that lights/switches can only be on/off in a scene, I don’t believe you can toggle them, so you will have to go the automation route, post your non-working code here enclosing it in three back ticks, that’s the key to the left of 1 on the top row of the keyboard, or paste it leaving a blank line at the top and bottom of the code and select it then click the </> button to have it formatted so we can help :slight_smile:

I’m sure we can work through those errors! Or, you could create this scene as a script instead. (Which is essentially just the “action” portion of an automation.)

it give me error

automation 101:
  alias: 'Bottone PC'
  initial_state: True
  hide_entity: True
  trigger:
    platform: mqtt
    topic: topic/luce
    payload: 'switch'
  action:
    - service: switch.toggle
       entity_id: switch.Luce
    - service: light.tutn_off
       entity_id: light.Bulbo
    - service: light.tutn_off
       entity_id: light.Bulbo
- service: light.tutn_off
   entity_id: light.Bulbo
- service: light.tutn_off
   entity_id: light.Bulbo

Both of the above services are miss-spelled…and are incorrectly spaced…

- service: light.turn_off
  entity_id: light.Bulbo
- service: light.turn_off
  entity_id: light.Bulbo

and is your payload really ‘switch’? also why are you turning the same bulb/light off twice?

I’m sorry about the mistake in the copy/paste
I’ve tryed with the new code but it is wrong :sob:

automation 101:
  alias: 'Bottone PC'
  initial_state: True
  hide_entity: True
  trigger:
    platform: mqtt
    topic: topic/luce
    payload: 'switch'
  action:
    - service: light.toggle
    entity_id: light.Bulbo
    - service: light.toggle
    entity_id: light.gateway_light_34ce00908135

Dec 14 14:10:28 hassbian systemd[1]: Started Home Assistant for homeassistant.
Dec 14 14:10:36 hassbian hass[30940]: 2017-12-14 14:10:36 ERROR (Thread-2) [homeassistant.util.yaml] while parsing a block collection
Dec 14 14:10:36 hassbian hass[30940]:   in "/home/homeassistant/.homeassistant/configuration.yaml", line 155, column 5
Dec 14 14:10:36 hassbian hass[30940]: expected <block end>, but found '?'
Dec 14 14:10:36 hassbian hass[30940]:   in "/home/homeassistant/.homeassistant/configuration.yaml", line 156, column 5
Dec 14 14:10:36 hassbian hass[30940]: 2017-12-14 14:10:36 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.ho
Dec 14 14:10:36 hassbian hass[30940]:   in "/home/homeassistant/.homeassistant/configuration.yaml", line 155, column 5
Dec 14 14:10:36 hassbian hass[30940]: expected <block end>, but found '?'
Dec 14 14:10:36 hassbian hass[30940]:   in "/home/homeassistant/.homeassistant/configuration.yaml", line 156, column 5
Dec 14 14:10:36 hassbian hass[30940]: Config directory: /home/homeassistant/.homeassistant
  action:
    - service: light.toggle
    entity_id: light.Bulbo
    - service: light.toggle
    entity_id: light.gateway_light_34ce00908135

As noted above in my previous post …the above should be indented correctly…

  action:
    - service: light.toggle
      entity_id: light.Bulbo
    - service: light.toggle
      entity_id: light.gateway_light_34ce00908135

Having said that I have no idea which line 155 and 156 are :stuck_out_tongue:

1 Like

Thank you so much man