Hey everyone, quick question - when dealing with trigger channels what do you do to know what the trigger output actually is?
For example, for the Astro binding the sunset/sunrise trigger outputs “START”.
But if I’m reading the GitHub correctly for the OpenUV binding I believe the channel trigger outputs nothing?
If I’m adding a new thing, and it comes with a trigger channel how can I know what it will output, without going into a GitHub or creating a string item and wait for it to do something, which may take days or weeks (home connect binding uses trigger channels for things like the dryer lint filter cleaning reminder, as an example.)
The contents of the trigger event should be explained in the readme for the add-on. If it’s not that’s a “Bug” in the docs.
The data published as the event can be any string so if it’s not in the docs you have to look a the source code or somehow force the trigger to occur and log it out or link it to a String Item with the profile that lets you link an event channel to a String Item (normally event channels can only be used to trigger rules).
Yeah I figured.. i did the linking of a string item but just my luck the OpenUV binding seems to output nothing, so my string item was empty and that left me very confused..
The Astro binding is very clear from my perspective:
FYI, you can create a channel trigger event that would trigger when any event is sent to that channel. You can then find out the actual event in the event trigger data.
A hypothetical example here - because digging out a concrete one would take even more time and I don’t have one off the top of my head: a keypad Thing can send a “PIN entered” event with the actual PIN number as the event. You won’t be able to trigger on a “static” event because you’d have to change your rule every time you changed the pin and you may be maintaining thousands of pins for a building security system.
Here’s an example (ruby) code to illustrate
rule "PIN Entered" do
channel "somebinding:thing:pinpad:PINEntered"
run do |event|
pin = event.event
# Lookup the pin in the database
if pin_is_valid(pin)
logger.info "Access granted"
else
logger.warn "Someone entered an invalid PIN: #{pin}"
end
end
end
If on the other hand you only allow ONE particular PIN and you don’t mind using a static hard coded pin, then you can write your rule like this:
rule "PIN Entered" do
channel "somebinding:thing:pinpad:PINEntered", triggered: "1234"
run do
logger.info "Access granted"
end
end
Of course in the case of UVMaxTime you simply disregard the event string, because it’s irrelevant and the binding sends an empty string anyway.