#if you have it, just split it on the /
1 messages · Page 1 of 1 (latest)
base mqtt topic would 'frigate/#' ... the subtopic I would be interested in is the camera triggering the mqtt stream, ex. 'frigate/camera1/[...]'
trying to figure out the syntax of the payload before I just start whackin at the keyboard
yes but what are you trying to do
I need more details other than "I have htis topic"
if it's just "I have this topic" then you literally just use .split('/')[1]
creating an automation that is triggered via mqtt, but I need to isolate the camera generating the mqtt string
ok, then it would be {{ trigger.topic.split('/')[1] }}
ahh ok -- not the payload_json
that's what I was hoping
thanks again petro
I'm sure this is wrong; but that would hopefully return true/false, yes?
value_template: ('input_boolean.frigate_' ~ {{ trigger.topic.split('/')[1] }} ~ '_override') == "on"
i'd need a states() in there
you wrap the whole thing in {{ }} not just the trigger part.
it'd still see the trigger, though right
I don't follow
with the trigger.topic.split('/)[1] ... the whole of the template would still pull out that value from the mqtt string
of that input boolean, yea. so i should use is state
ok
i gotcha
i just wasnt sure if you could nest the trigger peice into the template value
you can't nest {{ }} in eachother, but you don't need to. The whole line is a template
so,
value_template: {{ is_state('input_boolean.frigate_' ~ {{ trigger.topic.split('/')[1] }} ~ '_enabled') == "on" }} would work, then
no, you're using is_state wrong. it's is_state('entity', 'state')
also, you need to wrap the whole template in quotes
also, your outside quotes need to be opposite your inside quotes
use the template editor to test
but you're nesting {{ }} inside {{ }}, which you don't need to do
right
sorry .. work meeting;
gonna go with {{ is_state('input_boolean.frigate' ~ trigger.topic.split('/')[1] ~ '_enabled', 'on') }} ... as always (thanks) petro
I swear, if I could do like LinkedIn and endorse you for all the times you've helped me understand things ... sheesh you'd be gold
Heh, I am on linked in
can i use the same idea here with a time condition?
What do you mean time condition
eg. after: "{{states('input_datetime.frigate_'~trigger.topic.split('/')[1]~'_time_on').state}}"
or would it barf
it will barf because conditions don't accept templates
yeah figured
how do you mean, ... like {{ xxx and yyy }} ??
like now between time a and b
post what you want the condition to be
i have 2 date_times, on and off
1 is set to 0630, the other lets say 2100
the automation i am rewriting (for myself) is this:
- if:
condition:
- condition: time
after: input_datetime.frigate_lighting_time_on
before: input_datetime.frigate_lighting_time_off
then:
condition: template
value_template: >
{% set start = states('input_datetime.frigate_'~trigger.topic.split('/')[1]~'_time_on') | as_datetime | as_local %}
{% set end = states('input_datetime.frigate_'~trigger.topic.split('/')[1]~'_time_off') | as_datetime | as_local %}
{{ start <= now() <= end }}
can you explain the return to me? -- start is lessthan equalto now() lessthan equalto end?
no 'and' operator?
is that a jinja thing?
yep, that's how it reads
the and is implied
ahh
this is a python thing
ohhh
ok
thats my vb logic showing
lol
so in writing for example, it would be the equivilent of 'start is lessthan equalto now() [and now()] lessthan equalto end'
yep