Why is HA so annoying for Simple Automations?

Hi,

i wanna make a simple automation with HA and i dont get or i am to stupid…
If my Cam goes to “Person detected”, a single light bulb shoul flash 5x in red and after that it goes to the previous state…

Light entity is: light.couch_rechts
Cam entity is: binary_sensor.kamera_person

i´ve tried so many configuration but also the color selection in HA doesnt work. if i select red it goes white, altthough i´ve selected go red.
if i select red before i activate the automation it flash red but it stays red…

This is such a simple do that and then that thing, but i dont find anything in HA to realise that… or i am blind ?
why is this so complicated for such a easy process ?

i also tried scene.create etc., but doesnt work and the documentation is unclear.

Maybe because this is not that simple automation as you think it is. It is complex automation.
You can try this. Create two triggers for that camera, one when motion is detected and other when motion is cleared. Add triger id to this triggers.
Then use building block to and use choose. If it is triggered by motion turn light on, if it is triggered by cleared turn light off.
If it is working add gradually more complex things to this automation, like how long will light be on, what color will be etc.

1 Like

The example in the docs covers this pretty well, it just uses 2 automations.

This would be your full automation.

- alias: Flash bulb 5 times
  trigger:
  - platform: state
    entity_id: binary_sensor.kamera_person
    from: 'off'
    to: 'on'
  action:
  - service: scene.create
    data:
      scene_id: flash_light_couch_rechts
      snapshot_entities:
      - light.couch_rechts
  - repeat:
      count: 5
      sequence:
      - service: light.turn_on
        target:
          entity_id: light.couch_rechts
        data:
          color_name: red
      - delay:
          seconds: 1
      - service: scene.turn_on
        target:
          entity_id: scene.flash_light_couch_rechts
      - delay:
          seconds: 1
1 Like

It sounds like you were almost successful, in both attempts, but maybe only one more step was required.

Post the automation(s) you created (as formatted YAML).

Ok i think i found the error…
if set up this automation via the visual editor, the step “scene.turn_on” doenst find the scene that we create with action “scene.create”

and thats why my automation dont work and i cant either save cause this error message appear:

Message malformed: not a valid value for dictionary value @ data[‘action’][1][‘repeat’][‘sequence’][2][‘target’][‘entity_id’]

thats what the yaml look like if selected over the visual editor:

service: scene.turn_on
metadata: {}
target:
  entity_id: flash_light_couch_rechts

if the visual editor would do it right, then there must be a “scene.” befor the entity name… right ?
i change from visual to yaml editor and change the above to this:

service: scene.turn_on
metadata: {}
target:
  entity_id: scene.flash_light_couch_rechts

i can save, only the “metadata” stays, but i think thats not a problem…
if i remove it, the visual editor change the choices:

with string “metadate {}”
image

without (deleted in yaml mode and change back to visual):
image

Thats more then confusing…

So, i tested then the automation. It works, i´ve fine tuned just a little bit. Cause if the Light is already red, i dont see the flash. there must a “go off” command.

another question is, should i create a delete scene command. cause i think it will bring errors when everytime the automation create the same scene with the same name… or does it matter ?
Already included but dont know if this is necessary.

here is now my finished code… any tipps or suggestions ?
(the data{} comes everytime i open the automation, so i leave it there…)

alias: Person erkannt
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.kamera_person
    from: "off"
    to: "on"
action:
  - service: scene.create
    data:
      snapshot_entities:
        - light.couch_rechts
      scene_id: flash_light_couch_rechts
  - service: light.turn_off
    target:
      entity_id: light.couch_rechts
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - repeat:
      count: 5
      sequence:
        - service: light.turn_on
          target:
            entity_id: light.couch_rechts
          data:
            color_name: red
        - delay:
            seconds: 1
        - service: light.turn_off
          target:
            entity_id: light.couch_rechts
          data: {}
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.flash_light_couch_rechts
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: scene.delete
    target:
      entity_id: scene.flash_light_couch_rechts
    data: {}
mode: single

thank you all for helping me…

You don’t need to delete the scene.

Read the section “ Creating scenes on the fly”

1 Like

Does your light.couch_rechts natively support the flash option?

Yes, I have hue bulbs - but with the “flash” option it doesn’t work good. On \ off is for me the better option

That’s odd. I successfully use the flash option with my Hue bulbs.

Anyway, if you’re satisfied with sending a stream of on/off commands, then I won’t belabor the point.

You could share your setting if you like… I could try again.
Maybe I have a setting wrong or something, with my previous settings,they only flash 1 time and then the entire Automation freeze…

You’re using the wrong effect, there’s a flash red effect that lasts forever until you cancel it. I forget the name of it. But it seems like you’re using the quick flash green once effect.