Heyhey
When my alarmo alarm is triggered I want to send a message via Telegram every 40 seconds and make my cars horn honk until I press a button inside this message. (building this is no problem).
But for this I cant use the alarmo integrated messaging function (or am I wrong),
I have to start a script. But I dont find a way to pass on the sensor that triggered the alarm.
I want to have this information to tell me inside the message which device did trigger the alarm.
And if its a camera, I want a snapshot to be sent (no problem either - if I know which camera).
Here is my attempt so far. (Because I never worked with variables I also added “title” and “message” to see if this works.
Alarmo:
- service: script.aaalarmo_test
entity_id: script.aaalarmo_test
data:
title: das ist der Titel
message: das ist die Nachricht
sensor: {{open_sensors}}
- service: script.aaalarmo_test
entity_id: script.aaalarmo_test
data:
title: das ist der Titel
message: das ist die Nachricht
sensor: "{{open_sensors}}"
I have a slightly different scenario which now works but it was a struggle to get it that way. In my case I have many automations callng the same script, each passing three entities as variables to the same generic script. Not sure it that would work the same way for a script passing entities to another script, (rather than an automation passing entities to a script) but maybe my code would help below:
This is a basement automation from motion sensed - it calls the script (only if the person had not manually turned the light off within the last 5 minutes) to turn on a timer for a light with a specified duration and timer (also passing to it whether or not the automation is enabled - to minimize code duplication). Note the ‘action’ section at the end of the automation:
(The input number for the timer duiration is a slider on my dashboard, and the input select for whether or not the automation is enabled has two values “Enabled” and “Disabled” and is also shown in the dashboard.) As you can imagine there are other automations to makew everything work seamlessly, such as the timer being (re)started with the new duration when the slider is moved (but only if the timer is active), turning the lights on when the timer is started, turening it off when the timer finishes or is cancelled, saving the exact time the switch was last manually turned off when that occurs, etc. My my, what a tangled web we weave!
@Sir_Goodenough : See Post 2 and 3.
Adding quotes doesnt change anything.
Im not sure if open_sensors contains anything, or if those wildcards in alarmo are only possible in the message section, but not in the action.
Maybe thats the question here.
title: das ist der Titel
message: das ist die Nachricht
sensor: '{{open_sensors}}'
Without quotes in the alarmo run script section it sais:
title: das ist der Titel
message: das ist die Nachricht
sensor:
'[object Object]': null
I wonder why the text “open_sensors” doesnt show up in my telegram message (even if it ofcourse wouldnt help anything).
Does this mean its not possible to give the triggering device to a script?
This would mean Alarmo is completely useless for me - cant imagine that.
The automation (I assume that is what it it is) that is running the service call to the script needs to have that variable declared and loaded with your data. If not, it is just null, as you are seeing.
I know. But the documentation sais {{open_sensors}} can be used as wildcard and holds all active sensors.
But it also sais:
The alarmo notifications editor contains some wildcards which can be used to provide adaptive info to your push message. By adding the wildcard in a message (including the brackets) it will be automatically be replaced by the applicable text.
But im not using the notifications editor here, but the actions editor.
In my eyes the question of questions is if its possible to use wildcards within the alarmo actions.
In the case we are talking about (unless I missed something else in the conversation) I do not think data is being sent, it is an instance of the object (entity) itself that is passed.
Well for completing this, I think I have learned how it should work (if alarmo would pass any data).
Setting the selector inside my script to device (not to text).
And passing the data WITHOUT quotes ( data: sensor: {{open_sensors}} ), as I dont send any text to my script, but a device.
Anyway it doesnt work, so it looks like there is nothing passed to my script - as @KruseLuds assumes.
So this costum integration isnt my choice for this task.
But good thing is, I learned much about scripts and fields and passing (different) data (types) to this script. So Ill be able to delete many (really many) redundant code within my whole instalation.
And Im going to create 2 automations for alarm (inside and outside).
As trigger I use all my sensors and call the “detectionscript” and pass it
a boolean (to determine if a camera detects sth. or another device)
the detecting entity - or its name (to tell the user what device triggered the alarm)
the camera device itself - to take a snapshot and append it to the message
So 2 automations and 2 scripts (for handling inside alarm different to outside alarm) should be all I need. And maybe some logic to arm / disarm and to arm after a certain time (to dont trigger the alarm while leaving). And Im done.
This should be something im able to do now.
So thanks to all for your help here - even if it ends up in a different result than expected :o)
I fear that the open_sensor wildcard is not available in the actions setup.
One thing you could try is move the entity to the data part of the action - I have been caught by this a number of times …
If that also doesn’t work (for the above reason), then the solution is simple : just realize that these open_sensors are a state attribute of the main alarmo state, from which you can access them at all times …