[solved] Set and use a variables for my automations

Hi, I’m still quite new to HA, I have a few devices and most of them are already working really well.

But I would now like to set a value (SonWelcomeTrigger=1) through a triggered automation, so that I can prevent multiple execution of the automation.

During the day, when he is at school, I then set SonWelcomeTrigger=0 on a time-controlled basis
I would like to ensure that certain things are only executed once a day.

A simple example: when my son comes home and the motion detector detects movement, Alexa should greet him.
But she should only do this once a day.

If someone can give me an example of how I can select this in the GUI? I’m still struggling with the YAML.

Use a input_boolean helper.

To expand on the above for you as a new user, you’ll need a condition in your greeting automation to check that it’s off. In that same automation you’ll have an action after the greeting to turn it on. You’ll have a second automation to turn the helper off at say midnight.

A slightly simpler version would be to skip the helper, and just have the automation turn itself off after sending the greeting. A second automation will turn it back on at say midnight.

Some will frown upon this version, which I’d normally agree with. The reason that one would frown is that you want to separate the ability to actually disable some functionality from running, from the conditions that allow it to run. In this case I think that’s less of an issue, since you’d disable the second automation to disable the overall behaviour, if need be.

It can be achieved with a condition in the automation.

Post your automation in YAML format.

Thanks for the keyword “helper” - I’ve found an entry point and I think that’s how I want it to work. Many thanks for your input.

Here is the code. If there are better and simpler methods, I look forward to feedback.

alias: Paul - Zuhause Begrüssung
description: “”
trigger:

  • type: motion
    platform: device
    device_id: 7b804ce7e3bcaca0111d02684987e800
    entity_id: f6035527845944d5f6f618e134cc8233
    domain: binary_sensor
    enabled: false
    condition:
  • condition: and
    conditions:
    • condition: device
      device_id: 43d19af3effe048a96526d665cf99604
      domain: device_tracker
      entity_id: ee9334d041d9eafbc668abab56fbf171
      type: is_home
    • condition: numeric_state
      entity_id: input_number.paultriggerwelcome
      above: 0
    • condition: state
      entity_id: binary_sensor.workday_sensor
      state: “on”
      action:
  • service: notify.alexa_media_children_echo
    metadata: {}
    data:
    message: Willkommen Zuhause, ich hoffe Du hattest einen guten Tag !
  • service: input_number.set_value
    metadata: {}
    data:
    value: 0
    target:
    entity_id: input_number.paultriggerwelcome
    mode: single

Glad “helper” gave you a path to your answer. Personally, I like to start that way and answer more questions after.

Your code needs to be in a code block to be useful.

Three backticks on the line above and three more on the line below.

That will allow us to see the spacing and everything that goes with yaml.

deleted message

Thanks, I had been looking for such a function, but couldn’t find it in the WYSIWYG editor.
I hope this is better now. Many thanks for your time!

alias: Paul - Zuhause Begrüssung
description: ""
trigger:
  - type: motion
    platform: device
    device_id: 7b804ce7e3bcaca0111d02684987e800
    entity_id: f6035527845944d5f6f618e134cc8233
    domain: binary_sensor
    enabled: true
condition:
  - condition: and
    conditions:
      - condition: device
        device_id: 43d19af3effe048a96526d665cf99604
        domain: device_tracker
        entity_id: ee9334d041d9eafbc668abab56fbf171
        type: is_home
      - condition: numeric_state
        entity_id: input_number.paultriggerwelcome
        above: 0
      - condition: state
        entity_id: binary_sensor.workday_sensor
        state: "on"
action:
  - service: notify.alexa_media_children_echo
    metadata: {}
    data:
      message: Willkommen Zuhause, ich hoffe Du hattest einen guten Tag !
  - service: input_number.set_value
    metadata: {}
    data:
      value: 0
    target:
      entity_id: input_number.paultriggerwelcome
mode: single

I have now also solved this.