Guide: Script execution from signals

http://karpero.mine.nu/ha

Moderators: Daniel, tom_rosenback, Telldus

Locked
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Guide: Script execution from signals

Post by tom_rosenback »

Many people have asked how they can make for example a door sensor to trigger a device in HA, so now I thought it would be a good time to create a small guide for it. Daniel wrote a short guide inside a topic earlier so I just lifted it out into own topic to make it easier to find.
Daniel wrote:
Telldus script execution: http://developer.telldus.com/blog/2012/ ... om-signals

In short, just put an executable script in /usr/local/share/telldus/scripts/deviceevent and it will be executed every time any device changes status. I have got one that does this:

Code: Select all

#!/bin/bash

echo "--------------------------------------" >> /tmp/tdlog.log
date +"%d %b %T" >> /tmp/tdlog.log
echo "deviceevent" >> /tmp/tdlog.log

echo "Device: ${DEVICEID}" >> /tmp/tdlog.log
echo "Method: ${METHOD}" >> /tmp/tdlog.log

case ${METHOD} in
        1)
                status=1
                ;;
        2)
                status=0
                ;;
esac

echo "Status: ${status}" >> /tmp/tdlog.log

url="http://<my_HA_url>/api.php?do=devices/updateStatus&status=${status}&systempluginname=tdtool&systemdeviceid=${DEVICEID}"

wget -qO- "${url}" &> /dev/null
...which changes status of the devices in HomeAutomation.

/Daniel
There is also other API methods available in HA so if there is something else (eg run a macro) you want to do based on a event just look in the API folder if there is a method for it available.
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
Locked