#Debugging an automation's condition

1 messages · Page 1 of 1 (latest)

opaque linden
#

Just opening the thread to avoid disturbing others.

hearty void
#

I think I know the difference

opaque linden
#

The variables step, I just got from a blog post tutorial. I honestly don't see why it's needed, and when I tested, with or without didn't make a diff.

hearty void
#

You need to template the action in the wait_for_trigger

#

it should be {{ bed_light }} for action

#

Not just bed_light

#

look at the YAML I posted for an example

#

Same for the message data actions

#

When you combine it with the context ID under variables, you've got to reference it as a template to get it's stored value

#

The reason for the context.id is so you have have these notifications serve multiple devices in parallel at the same time

opaque linden
#

hmmm struggling to understand, cause still not expert in YAML and no clue what templates are

#

so, the wait for trigger actually works, as you can see in the post image

#

it triggers :S

#

the right action, which I assume means it's getting it right from the phone notification

hearty void
#

Yeah it only works because you didn't use the template for the notification actions

#

So it triggers off the same literal value

#

But when you refer to "bed_light" in the condition template it stops being a literal string and becomes the variable you set earlier

#

So basically when you just say action: bed_light it's just looking at that as a literal value

#

But if you say action: {{ bed_light }} it looks at the variable above which is entirely different contents

opaque linden
#

let me see if I'm following

hearty void
#

So you could just quote "bed_light" in the condition

#

And drop the variable entirely

#

Effectively you're using bed_light in two different ways right now

opaque linden
#

so you're saying I set up that variable at the top, and the action in the wait is picking it up because it matches. But then the condition of the action matches, but doesn't find anything inside the variable?

#

is that it?

hearty void
#

Oh it's finding NO_ and whatever random context.id was created for that execution

#

The wait is just waiting for a literal string value of "bed_light" because you didn't tell it to evaluate it as a variable with {{}}

#

But then below your condition DOES look inside the variable named bed_light haha

opaque linden
#

ok, so what do I do to ditch the variables? I think I will start with the basic, and once I understand that it will be easier for me to understand th value of doing a variable

hearty void
#

For this case, a single notification to a single user you don't actually need the variables

#

If you just put double quotes around the terms bed_light and living_lights in the condtion template you'll be golden

#

wait, single quotes haha

#

the rest of the field is already double quoted

opaque linden
#

hmm ok... Something weird happened

#

so I disabled the variable step

hearty void
#

Yeah single quotes around the condition bits

#

Sorry lol I spoke wrong the first time

#

You can't have unescaped " inside a "

opaque linden
#

hmm I'm testing it

#

but it's triggering the lights without asking

#

I mean

#

it toggles them automatically. It also sends the notif, and when I tap it it switches them again.

#

it's like this now

#

wait

#

I have another auto xD

#

lol

#

fucking YEEEES

#

finally

hearty void
#

Lol

opaque linden
#

it works 😄

#

it automatically changed the syntax to this now

#

oh no, wait

hearty void
#

Yeaht that's legal lol

#

Or use single quotes inside the statement

opaque linden
#

I did, but it changed it auto

hearty void
#

It's just the results of the YAML rules

#

That's just an escaped double quote that means it's not the end of the statement

opaque linden
#

there's no way to create this condition on the UI? I just feel more comfy without dealing with the code tbh

hearty void
#

Yeah I was going to say there is a way to make this UI-able

#

where you just have conditions:

#
  - conditions:
      - condition: template
        value_template: "{{ test }}"
    sequence: []```
#

Re-format it to look more like that

#

And the UI will support it

#

You currently have the shorthand notation that the UI does not support

opaque linden
#

I think something's wrong

hearty void
#

Lol not surprising with yaml, it's very indent sensitive

opaque linden
#

oh wait, that's not it

hearty void
#

yeah value_template has to be at the same level as condition above

#

so close

opaque linden
#

yay

#

damn this is so much easier to understand for me 😂

hearty void
#

Oh for sure, the UI editor has drastically improved over the years

#

The traces is super helpful too in identifying where something went wrong

opaque linden
#

so going from this point, where it works and I kind of understand. Can you make one last attempt for me to understand what's the diff between this vs setting up variables etc?

#

This is you setting up a variable called action_living_room. Correct?

action_living_room: "{{ 'LIVING_ROOM_' ~ context.id }}"

hearty void
#

So the whole point of those variables is so you can have multiple devices using a single automation at the same time

opaque linden
#

And this is you calling up that variable I think

  • action: "{{ action_living_room }}"
hearty void
#

Yeah

opaque linden
#

then you wait for the same variable to be received

hearty void
#

So mine is triggered from an action I serve up to mobile devices, but both the wife and I could be using it at the same time without colliding

opaque linden
#

aha

#

why would mine collide?

hearty void
#

Because they use unique context.id values to keep them separate

#

In your case it's very atomic so not needed

opaque linden
hearty void
#

but if you ever use the same action value elsewhere it will collide

#

I think context.id is literally a unique value for that specific execution of the automation

opaque linden
#

so those context.id are ids unique for each of your devices, right?

#

I can see down there there are all the possible variable combinations. Is that it?

hearty void
#

context.id is just unique per execution of the automation

opaque linden
#

well no, I can't see the combinations, I'm wrong

#

ah ok

hearty void
#

Mine are dynamic in that they send the notification back to the device that triggered the action in the first place

#

You have a static one for one user so context.id doesn't gain you anything

opaque linden
#

meh, it's going a bit over my head tbh. I kind of get it but I really don't xD

hearty void
#

Just remember the action value you pick has to be globally unique across all automations

#

that's all that matters in the end

opaque linden
#

it's my first time using them, but if I do more I guess I will face the issue eventually

hearty void
#

If you look at mine, it has multiple back-and-forth notifications to drill down into proverbial menus

opaque linden
#

like asking brightness and colours you mean

hearty void
#

Yeah

opaque linden
#

I might try to do that tbh

#

at least for brightness

hearty void
#

You may be able to use adaptive lighting to manage that automatically

opaque linden
#

I don't have sensors in the rooms atm, don't see the need for them really. I only have a couple for transit areas (kitchen and stairs)

#

the motion sensors I have haven't been provided a super consistent lux value, so I haven't enjoyed using them too much and don't rely on them tbh

#

maybe it's just ignorance, but I see too many spikes and weird stuff

hearty void
#

That's the point of adaptive lighting

#

It uses sun position mostly to alter brightness/color temp

opaque linden
#

ahh for adaptive I assumed you meant using sensors, not sun

hearty void
#

This one has a fair bit more features

opaque linden
#

cool, will look into it one of these days

#

thank you very much mate, really you've been insanely helpful and have unblocked me on several points today