Is it possible to trigger a notification, based on results from an script? For example, my current setup constists of this:
1. Config on Github, HA runs on clone of it
2. When a new device is connected, create a new commit with the new devices
3. Push that commit to github
Now, my last step can fail, for example, when I’ve added a new commit on Github, but not yet pulled it down on my HA.
I’ve got a simple script for now, that just says git push, I could extend that to take account for this issue.
I’m just wondering if it is possible to capture the results of the shell_command (other than using a dummy sensor which I’d update using the REST API) so I can send myself a notification whenever the action fails?
But no a shell_command is afaik currently a send only so no return value is read. You could also do the error handling in the script that is called by the shell_comand component and send a notification from there… e.g. via REST API and Telegram (WITHOUT dummy sensor :D)
I’ve just added that part with the dummy sensor, since I now know how I would need to do it that way, not to prevent you from answering offcourse
Anyways, I think it’ll be better to use a dummy sensor anyways (if, like you said, there’s no other way), no need to fiddle with REST API’s (other than the one from HA) .
EDIT: I just though about something, couldn’t I use the script to send a custom event using HA REST API, instead of creating a dummy sensor?
That way I could just create an automation that acts on that event. Gotta figure out how/if custom events can be done
That’s pretty much what I was trying to say. I don’t know about events being sent from REST but you could trigger any service for notification from the REST API.
Fiddeling with events seems to be a bit more complicated for me and seems to require tinkering around with python code inside of HA to add handlers for that.
Greetings! I want to use this to trigger sending a notification from Hass in a script of mine.
Now i need to figure out how to include data from the curl aswell. I want to include message and attachment information. Any Ideas how to do this with json and the http api?