Hi,
I spent the last weekend setting up OpenHab (
http://www.openhab.org/) with the Almond+ to get some automation going.
Big thanks to user Matt (
http://forum.securifi.com/index.php?action=profile;u=807) - I would not have come this far without his help.
I am running OpenHab on another Linux PC which is on 24/7. I am not sure if you will be able to run it on the actual Almond+, but it will run on a Raspberry Pi (small to medium residential installs)
1. Setting up mochad on the Almond+
In order to be able to toggle any switches on your Almond+ from OpenHab, I am using Matt's mochad tool.
Follow the instructions here
http://forum.securifi.com/index.php/topic,615.msg7006.html#msg7006Verify that your set up works:
# Turn device 1 on
echo "AP 1 on" | nc <almond_ip> 1099
# Turn device 2 off
echo "AP 2 off" | nc <almond_ip> 1099
(replace almond_ip with the IP address of your almond, or add it to the hosts file)
2. Getting OpenHab to set devices
create a new file in $openhab/configurations/cmd
#!/bin/bash
echo "AP $1 $2" | nc almond 1099
We will use this script in the exec binding (make sure you activate exec) for the OpenHab switch item.
Set up a new switch item in OpenHab:
Switch living_floorlamp "Living Room Floor Lamp" <switch> (Lights) { exec=">[OFF:/usr/share/openhab/configurations/cmds/ap 1 off] >[ON:/usr/share/openhab/configurations/cmds/ap 1 on]" }
Reading device status from the Almond+
I am using the /DeviceList.xml on the Almond+ to read the status of any device. This is once again done via an exec binding and a XSL transform. In this example, my motion detector is "Device 3" in DeviceList.xml. I had to set the update interval to a very aggressive 1 second. For other items, like door sensors or power usage on plugin modules, set the timeout a bit higher for performance reasons.
I am interested in anyone who has a more elegant solution to reading and parsing the DeviceList.xml file via OpenHab.
String motion_status "Motion Detected [%s]" { exec="<[ssh root@almond cat /DeviceList.xml:1000:XSLT(motion_status.xsl)]" }
Here is the XSL file:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<xsl:value-of select="/DeviceList/Device[@ID='3']/ValueVariables/LastKnownValue[@Name='STATE']"/>
</xsl:template>
</xsl:stylesheet>
Feel free to ask any questions you have. I was able to integrate my RaspBerry Pi camera with motion-mmal as well.
(edit: spelling)