Simple script to turn off/on a light

Hi,

I start to feel stupid. I am not able to get a simple script to work that could turn on or off a light. I am able to toggle it but turning it specifically on or off does not work.

 - service: light.turn_on
    data:
      entity_id: light.tv

The same script with light.toggle works.
Any idea what I am doing wrong ?

Thanks,
mcb

Is that your full script?

It should have a few more things like this:

script:
  tv_light_on:
    sequence:
      service: light.turn_on
      entity_id: light.tv

@tom_l’s solution is correct. I just wanted to point out that the reason your yaml was not working is because your spacing is off.

 - service: light.turn_on
    data:
      entity_id: light.tv
   ^
   |
Remove indent
 - service: light.turn_on
   data:
     entity_id: light.tv

So here is the full file /config/scripts.yaml:

'1568061272142':
  alias: 'Testscript #2 - v1.16'
  sequence:
  - alias: ''
    data:
      entity_id: light.lightstrip
    service: light.toggle

So the light.toggle works, but neither light.turn_on nor light.turn_off does switch the light

What kind of light is is? Which integration is being used to control it?

I tried this with 3 lights:

  • Philips HUE lightstrip
  • OSRAM LightStrip
  • Dresden Electronics Lightstrip

The Hue and Osram are connected through the HUE bridge and the other through a Dresden Electronics ConBee II

Are you able to turn the lights on and off using the Services page?

Screenshot%20from%202019-09-11%2008-55-30

1 Like

@123 I have no idea why and how, but since I tried this on the dev tools and copied the json part into my script it works.

Glad to hear it, even though the solution is seemingly inexplicable. :thinking: :man_shrugging: