Wemo Motion
Posted: Friday 29 July 2016 16:11
Hi, new to the forum, and fairly new to Domoticz.
I have the majority of my home automation set up and working, including Harmony Remotes, Phillips Hue lights, Netatmo weather sensors, and a number of dummy devices doing a lot of cool stuff.
I'm really struggling with the final piece of the jigsaw, and wondered if somebody could offer some assistance.
Using the Wemo shell script from the Wiki, I'm able to control all my Wemo sockets, which is cool.
Additionally on my network, I have Wemo Motion detector. The suggestion the Wiki is to use ouimeaux. Due to the amount of devices on my network, ouimeaux runs dog slow, and times out before seeing all my Wemo devices, so I've gone back to the shell script.
So, this is my logic
I've created a number of shell scripts (I know I could have done most of it in one script, however I was testing each bit as I went)
wemo_motion_main.sh
Calls a shell scripts that gets the state, and calls another script if motion detected, if not, exit
wemo_motion_state.sh
Simply get the state of the motion detector, ON or OFF
wemo_motion_update.sh
Makes the call to Domoticz to switch on and off the switch
wemo_motion_loop.sh
Simple script to loop every 5 seconds(ish)
Now running wemo_motion_loop.sh from the command line works...if I dance around in front of the motion sensor for at least 5 seconds, motion is detected, and the status of the dummy switch gets updated.
So I thought, simple...add a cron job, to run every minute, call wemo_motion_loop.sh and we're sorted.
When I run under cron, the script doesn't work.
I guess I'm being a muppet, and missed something obvious...
Thanks in advance.
I have the majority of my home automation set up and working, including Harmony Remotes, Phillips Hue lights, Netatmo weather sensors, and a number of dummy devices doing a lot of cool stuff.
I'm really struggling with the final piece of the jigsaw, and wondered if somebody could offer some assistance.
Using the Wemo shell script from the Wiki, I'm able to control all my Wemo sockets, which is cool.
Additionally on my network, I have Wemo Motion detector. The suggestion the Wiki is to use ouimeaux. Due to the amount of devices on my network, ouimeaux runs dog slow, and times out before seeing all my Wemo devices, so I've gone back to the shell script.
So, this is my logic
I've created a number of shell scripts (I know I could have done most of it in one script, however I was testing each bit as I went)
wemo_motion_main.sh
Calls a shell scripts that gets the state, and calls another script if motion detected, if not, exit
Code: Select all
#!/bin/bash
status(){
doit=$(/home/pi/domoticz/scripts/wemo/wemo_motion_state.sh)
}
status
echo $doit
if [ "$doit" = "ON" ]
then
echo "Motion Detected"
/home/pi/domoticz/scripts/wemo/wemo_motion_update.sh
else
echo "No Motion Detected"
fi
Simply get the state of the motion detector, ON or OFF
Code: Select all
#!/bin/sh
/home/pi/domoticz/scripts/wemo/wemo_control.sh 10.0.51.183 GETSTATE
wemo_motion_update.sh
Makes the call to Domoticz to switch on and off the switch
Code: Select all
#!/bin/sh
curl "http://xxx:[email protected]:8084/json.htm?type=command¶m=switchlight&idx=255&switchcmd=On"
sleep 2
curl "http://xxx:[email protected]:8084/json.htm?type=command¶m=switchlight&idx=255&switchcmd=Off"
Simple script to loop every 5 seconds(ish)
Code: Select all
#!/bin/sh
max=11
for i in `seq 1 $max`
do
echo "$i"
now=$(date +"%T")
echo $now
./wemo_motion_main.sh
sleep 5
done
So I thought, simple...add a cron job, to run every minute, call wemo_motion_loop.sh and we're sorted.
Code: Select all
*/1 * * * * /home/pi/domoticz/scripts/wemo/wemo_motion_loop.sh
I guess I'm being a muppet, and missed something obvious...
Thanks in advance.