#Debugging an automation's condition
1 messages · Page 1 of 1 (latest)
I think I know the difference
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.
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
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
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
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
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?
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
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
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
Yeah single quotes around the condition bits
Sorry lol I spoke wrong the first time
You can't have unescaped " inside a "
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
Lol
I did, but it changed it auto
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
there's no way to create this condition on the UI? I just feel more comfy without dealing with the code tbh
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
I think something's wrong
Lol not surprising with yaml, it's very indent sensitive
Oh for sure, the UI editor has drastically improved over the years
The traces is super helpful too in identifying where something went wrong
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 }}"
So the whole point of those variables is so you can have multiple devices using a single automation at the same time
And this is you calling up that variable I think
- action: "{{ action_living_room }}"
Yeah
then you wait for the same variable to be received
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
Because they use unique context.id values to keep them separate
In your case it's very atomic so not needed
aha, not sure what are those context.id, but ok
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
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?
context.id is just unique per execution of the automation
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
meh, it's going a bit over my head tbh. I kind of get it but I really don't xD
Just remember the action value you pick has to be globally unique across all automations
that's all that matters in the end
it's my first time using them, but if I do more I guess I will face the issue eventually
If you look at mine, it has multiple back-and-forth notifications to drill down into proverbial menus
like asking brightness and colours you mean
Yeah
You may be able to use adaptive lighting to manage that automatically
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
That's the point of adaptive lighting
It uses sun position mostly to alter brightness/color temp
ahh for adaptive I assumed you meant using sensors, not sun
you mean this? https://www.home-assistant.io/integrations/flux