Always used Node-Red thought about moving to native HA but unsure where to start

I thought I would give HA automations/scripts a go but really have no idea where I should do this and how to start.

I thought I would start with script but then saw in the GUI there is no conditions but in the documentation there are, this got me wondering if scripts is the right place.

I have provided a picture of a 2 simple flows I would like to migrate over to HA, a pointer on what should be a script and what should be an automation process would help a lot and if I should be looking at YAML to achieve it instead of the GUI.

From a very high level I was looking at the start of each process to be a Automation and the rest scripts (can I do split conditions in the same script?)


Both should be automations. Trigger on the event then use a choose action (based on the light state) to determine which sequence of actions to run. No scripts required.

1 Like

So I’ll add them to the Automation, do you recommend YAML or try to stay in the GUI?
Not an easy question I know but I would like to align where HA might be heading.

If you feel you might do some more advanced automation using jinja templates sometime in the future it would be good to start getting a grasp of YAML. If you can do Node Red you can do this just as easily. However for the automations above the UI editor would be sufficient.

If you are going to have a go at the YAML version, post here if you need help or have questions. The above automations will be a good introduction.

Thanks Tom,
I had seen the Choose command in the GUI but always thought “Default” would run after the other actions so I couldn’t see how this was a if/else until I read the docs a bit harder :slight_smile:


1 Like

Thanks Tom, those ones are completed, it can be weird what you think should be a breeze to set up then turns out to be a little harder than you thought.

Is this possible it a single automation
I have a push button switch that has triggers of “long press” and “long press release”. I’m looking at if the switch is longed press keep decreasing the brightness of the lights until released. I thought I would be able to do it in a Until loop but it appears I can’t repeat until a new different trigger and instead only trigger on the existing automation Trigger IDs which doesn’t appear to be any good as if I also add the “long press release” as a trigger, when the automation triggers on the release it runs as a different instance of the automation.

Thinking for this one I might need to set up (1 or 2) automations that turn on and off a script that decreases the lights, does that make sense?


latest Yaml version

id: '1628102794007'
alias: test light decrease
description: ''
  - device_id: 8621b4f2fce548a49da1d754a2c41bcb
    domain: zha
    platform: device
    type: remote_button_long_press
    subtype: button
    id: '1'
  - device_id: 8621b4f2fce548a49da1d754a2c41bcb
    domain: zha
    platform: device
    type: remote_button_long_release
    subtype: button
    id: '2'
condition: []
  - repeat:
        - condition: trigger
          id: '2'
        - device_id: 3f7189b028a7f5b5007604f8ce44fa08
          domain: light
          entity_id: light.computer_room
          type: brightness_decrease
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
mode: single

What kind of remote-control are you using?

Instead of creating automations to process the device’s button events, looks through the Blueprints Exchange section and see if there’s an existing blueprint for the device. Some of the better ones support things like long press, hold, etc.

Assuming there’s a blueprint for your device, it’ll be pre-configured to handle the device’s events. All you need to do is indicate what you want each button event to do.

For example, here’s one for the Ikea 5-button remote-control.

Even if you don’t want to use a blueprint, and prefer to create your own automation from scratch, you can examine how the blueprint is constructed and get ideas for your automation.

Hi 123, to answer your question there are all ready pre-configured commands for this switch “long press” and “release” which I am using. The issue is that the release command isn’t cancelling the until loop I am in and hence the light turns off. The automation is in single mode so unsure why this isn’t happening.

I see my YAML was badly formatted yesterday so I’ve reformatted it.

It won’t because mode: single means while the automation’s action is executing (i.e. it’s busy doing the repeat) anything attempting to trigger it again (like when it’s second trigger detects remote_button_long_release) will be rejected. Your repeat is waiting to hear from something that is actively blocked from being heard. Check the Log and you’ll probably see a message about ‘already running’ each time you released the button.

Try changing mode to restart. When you long_press, the repeat will begin iterating and the moment you release the button (triggering the second trigger: id = ‘2’), the entire action session is terminated and a new session begins. This new session won’t iterate repeat even once because until's condition will be satisfied. In other words, it will cease decreasing the light’s brightness.

1 Like

Restart has worked, I miss understood the term single in this case. I thought single meant that it would not run any more instances of this automation and only execute against the current one (eg you only have one instance running).

Is did confuse me, with the description as I expected the triggers to be able to pass a message at any time to a running automation in a loop but see this issue the case.

Thanks 123

I see how you interpreted it and you were half right, there’s only one instance running. However, while it’s running, the automation’s trigger section is, effectively, disabled and ignores attempts to trigger again. “I’m busy servicing working on the previous request, try again later!”