#Is it possible to run default actions in addition to user entered actions?

63 messages · Page 1 of 1 (latest)

jade totem
#

I have a blueprint that runs an action entered from the blueprint.

      - conditions:
        - condition: state
          entity_id: !input entity_down
          attribute: event_type
          state: multi_press_2
        sequence: !input down2

I would like to run an action before the !input , and possibly after as well. Looking through the docs I was not able to find out if it is possible to combine !input calls with additional actions.

sequence:
 - action: things
 - !input down2
 - action: more things

is what I am aiming to do, though there may be other ways of accomplishing this.

tepid agate
#

You can use a nested sequence

#
actions:
  - action: things
  - sequence: !input down2
  - action: more things
untold walrus
#

Hi @jade totem,

!inputs are run (created) before the automation or script is run at all. You can't add '!input' after you run an action.

You run them when setting up what the variables are for the automation / script the blueprint was created to run.

If you want to pull data in on the fly, it would have to be a script blueprint and you would call it with data, then have fields or variables set-up in there to catch the data.

jade totem
tepid agate
#

Yeah I guess sequence action seems is missing from the docs. But you can see it in the UI.

#

kind of an odd one since it seems pointless 99% of the time, except for a few advanced edge cases

untold walrus
#

I don't think I've seen it before

tepid agate
#

it's new as of I think maybe ~3ish months ago

untold walrus
#

Is this the conditional inputs that you are talking about?

tepid agate
#

I'm not sure if you're addressing me or OP, or what you're really asking

untold walrus
#

OK, NM. not important.

#

What I was saying is you can't add !inputs in outside of the initial set-up of the automation or script that you create from the blueprint. It doesn't make sense. I think that is what @jade totem was asking for.

#

There are ways to pull in data, but that particular one has to be at the start before it's a script ot automation.

jade totem
#

If sequence can be a part of an actions list as Karwosts indicates, I think this will help accomplish my goal. Testing needed, and hopefully others can find this until docs get updated.

untold walrus
#

I guess I don't understand the difference. Those are keywords that mean the same thing, but one is in an automation, the other is in a script AFAIK.

#

I don't know what you think you will gain.

#

The actual things you do inside a script or an automation are the same things, you just pick actions: if you are doing an automation or sequence: if you are doing a script.

#

The flow you state above could be under either depending on what integration you are calling it from, script or automation. At least that's what I think anyway.

#

Except that you can't have a !input sequence in either a acript or automation, has to be in the header of a blueprint.

tepid agate
jade totem
#

Here is where the input is defined, and what it can look like from the user perspective

        downHeld:
          name: Down Held
          description: When Down is held
          default: []
          selector:
            action: {}
untold walrus
#

Obviously I don't understand

tepid agate
#

sequence is a key for a type of action. it is also the name of the top level for scripts, but that's not relevant here.

jade totem
#

The !input is a list of actions. Which is a sequence I'm pretty sure.

tepid agate
#

it's similar to parallel

untold walrus
#

ok

tepid agate
jade totem
#

here is the current relevant part of the action part of the automation, simplified.

action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - down
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: !input entity_down
                    attribute: event_type
                    state: multi_press_1
                sequence: !input downHeld
untold walrus
#

OK, you are not trying to define 'downHeld', you are using it as a variable there.

jade totem
#

and here is what I think it will end up looking like after Karwosts suggestion:

action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - down
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: !input entity_down
                    attribute: event_type
                    state: multi_press_1
                - actions: 
                   - action: TURN OFF HELPER
                   - sequence: !input downHeld
                   - action: TURN ON HELPER
untold walrus
#

I got it now, I'm on board. Thanks both of you for smacking me on the head until I got it.

tepid agate
#

I'm not sure if choose supports actions key or not or if it's still sequence

jade totem
tepid agate
#

I think this:

          - choose:
              - conditions:
                  - condition: state
                    entity_id: !input entity_down
                    attribute: event_type
                    state: multi_press_1
                sequence: 
                  - action: TURN OFF HELPER
                  - sequence: !input downHeld
                  - action: TURN ON HELPER
jade totem
tepid agate
#

I think what I typed is what you want

jade totem
#

ok so a sequence can contain sequences.

untold walrus
#

I think the next YAML fix should be git rid of sequence... to actions...

#

Why 2 names for the same thing WHERE they are the same thing that is

#

Maybe the inner loop kind fits, but the top level script one could change

#

parity is awesome.

jade totem
#

Maybe. But it would somehow need to be obvious that actions can contain both actions and action. actions containing sequence and action seems to make sense, so long as it is clearly documented.

serene shard
untold walrus
#

Right, sso the inner loop sequence is really something different, and that makes sense to be sequence, but the top key sequence closely matches the top key actions in form and function, hence my prior post.

jade totem
# tepid agate I think what I typed is what you want
- conditions:
  - condition: state
    entity_id: !input entity_down
    attribute: event_type
    state: long_press
  sequence: 
    - conditions: 
      - condition: template
        value_template:  "{{ is_state(shouldSyncLights, 'on') }}"
      action: input_boolean.turn_off
      target:
        entity_id: !input sync_helper
      data: {}
    - sequence: !input downHeld
- conditions:
  - condition: state
    entity_id: !input entity_down
    attribute: event_type
    state: long_release
  sequence: 
    - sequence: !input downReleased
    - conditions: 
      - condition: template
        value_template:  "{{ is_state(shouldSyncLights, 'off') }}"
      action: input_boolean.turn_on
      target:
        entity_id: !input sync_helper
      data: {}

is the full version with some additional logic

#

Is this still correct?

untold walrus
#

Looks to me like it would work.

  - condition: state
    entity_id: !input entity_down
    attribute: event_type
    state: long_release

would get weird but I assume you will have the entity picker pretty locked down to prevent, you know, random user inputs...

#

See how this gets weird, but if the top level were actions: it would work much better...

#

just a nod back to above...

jade totem
# untold walrus See how this gets weird, but if the top level were actions: it would work much b...

I fully get it. But what about when the sub sequence has the same issue?

actions:
  - sequence: !input downReleased

is that you are aiming for, right? And I agree this is better. But the problem can re-create itself pretty easily.

actions:
  - sequence: 
    - sequence: !input downReleased
    - action: CHANGE_SOME_STATE
  - action: SOME OTHER THING

It could be more clear instead to re-define a sequence itself as a Action_list directly addressable to actions, allow actions to contain other actions in addition to individual action , and allow actions to have the features of sequence such as parallel. Get rid of sequence entierly.

untold walrus
#

Good catch. Comment in the feature request, it will get lost in here though.

jade totem
#

so

actions:
  - sequence: 
    - sequence: !input downReleased
    - action: CHANGE_SOME_STATE
  - action: SOME OTHER THING

could become

actions:
  - actions: 
    - actions: !input downReleased
    - action: CHANGE_SOME_STATE
  - action: SOME OTHER THING
untold walrus
#

A vote would be nice if you think there should be a change. The engineering team will work out all the edge cases I'm sure if they take it on.

jade totem
#

A change could be nice, and I'll vote for it. It could simplify documentation and increase clarity for how and when sequences and actions can be used and combined.

In fact, the blue print selector is the Action Selector, but the input goes to sequences which itself isn't inutitive.

untold walrus
#

Well documentation you can pretty easily suggest changes for. Don't need [FR] for those.

#

link on every page for that.

jade totem
untold walrus
#

Which is why I've never tried to fix it.