Choose style:

Author Topic: Working OpenHab integration  (Read 17941 times)

0 Members and 1 Guest are viewing this topic.

Offline vansens

  • Backer
  • *
  • Posts: 29
  • Thanks: 0
  • Registered : 02/08/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Working OpenHab integration
« on: September 30, 2014, 03:13:43 pm »
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#msg7006

Verify that your set up works:

Code: [Select]
# 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


Code: [Select]
#!/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:


Code: [Select]
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.


Code: [Select]
String  motion_status   "Motion Detected [%s]"  { exec="<[ssh root@almond cat /DeviceList.xml:1000:XSLT(motion_status.xsl)]" }

Here is the XSL file:


Code: [Select]
<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)
« Last Edit: September 30, 2014, 05:10:37 pm by vansens »

Offline wstocker

  • Backer
  • *
  • Posts: 148
  • Thanks: 0
  • Registered : 02/08/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #1 on: October 01, 2014, 09:26:47 pm »
Cool start, I hope that they implement a notification based system for sensor updates, Polling has very high overhead and is not always reliable for security type configurations.

LGNilsson

  • Guest
Re: Working OpenHab integration
« Reply #2 on: October 01, 2014, 11:04:09 pm »
We got notifications coming in the next release of the Android app, iOS will take a bit longer, but it's coming there too.

Offline pete

  • Moderator
  • *
  • Posts: 316
  • Thanks: 2
  • Registered : 22/07/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #3 on: October 02, 2014, 05:41:20 am »
Great news vansens!

Here I have been also playing with OpenHab. 

A bit differently though installing it on an Intel based Atom touchscreen capacitance tabletop touchscreen tablet.  The tablet is an experiment sort of because I can run Linux, Android or Wintel on it upgrading the EFI boot rom on it.  Only thing is that it has 512Mb of play room.  It does run Ubuntu 14.04 just fine on it.

Here though thinking it would make a nice touchscreen console (7") to the Almond +.

Concurrently also "tinkering" with a direct serial interface from the Almond + to my Leviton OmniPro II combo panel. (well now too X10 and UPB).  This would allow the Almond + to communicate to some other automation stuff non wirelessly (x10 and UPB these days).

The response times for status stuff though is a bit faster using the Almond + serially connected to the Almond +.   The panel itself does talk X-10, UPB, Zigbee and Z-Wave.  Here mostly looking though at the hard wired sensors on the Leviton Panel interfacing to the Almond +.   Said noted I do continue to utilize X10 today and primarily UPB for my light switch interfaces (well the sandbox also has Z-Wave and Zigbee).

[img width= height= alt=" width="250" height="52" class="bbc_img resized]http://forum.securifi.com/Themes/Firox_multicolor_by_SMFSimple/images/logo.png[/img]
Pete
Lockport, IL  USA

Offline matt

  • Backer
  • *
  • Posts: 151
  • Thanks: 1
  • Registered : 26/08/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #4 on: October 02, 2014, 05:44:12 pm »
Cool start, I hope that they implement a notification based system for sensor updates, Polling has very high overhead and is not always reliable for security type configurations.

None of this has to be done with polling. I only recently realized what the SDK's callback function really does, so I'm baking that support into mochad now, so it forwards callbacks to the tcp socket (this sort of thing already happens for X10 RF communication it receives). And OpenHAB has a TCP plugin that can keep a connection open for notifications, and act based on them (I haven't used it personally, but it looks pretty straightforward).

Edit: I should've added that the SDK for some reason only allows one HADevices connection on the A+ at a time though, so it looks like implementing this may make it so that you have to stop mochad if you want to do certain UI interactions on the A+ touchscreen, which is annoying. I've asked about ways around this in the forums, but haven't received a response yet.

Edit2: Okay, well that was easier than I thought. Newest package contains these updates. E.g.:

I turned on an X10 device with an RF remote, then toggled a ZWave switch off/on twice with the A+ app, then typed "AP 1 off" and hit enter, and a few other commands ("AP" and "RF" commands).

Code: [Select]
root@AlmondPlus:~# nc localhost 1099
10/02 18:23:43 Rx RF HouseUnit: J4 Func: On
10/02 18:24:43 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: false
10/02 18:24:47 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: true
10/02 18:24:52 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: false
10/02 18:24:55 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: true
AP 1 off
10/02 18:25:34 BinarySwitch #1 turned off.
10/02 18:25:34 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: false
AP 1 on
10/02 18:25:38 BinarySwitch #1 turned on.
10/02 18:25:38 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: true
RF J4 off
10/02 18:26:10 Tx RF HouseUnit: J4 Func: Off
RF J4 on
10/02 18:26:14 Tx RF HouseUnit: J4 Func: On
« Last Edit: October 02, 2014, 06:38:59 pm by matt »

Offline dbuttke

  • Backer
  • *
  • Posts: 114
  • Thanks: 0
  • Registered : 12/08/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #5 on: October 04, 2014, 09:56:12 am »
Very interested in this!
Can't wait to start trying this when I get some free time.
Good job so far.

Offline vansens

  • Backer
  • *
  • Posts: 29
  • Thanks: 0
  • Registered : 02/08/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #6 on: November 20, 2014, 08:09:45 pm »
Great news vansens!

Here I have been also playing with OpenHab. 


Hey Pete, do you by any change have any motion sensors integrated hooked up to your Almond+ and integrated with OpenHab? I struggle with them quite a lot, as I am not sure which binding the best one is to use here.
Any hints are welcome!

Offline SecureComp

  • Backer
  • *
  • Posts: 541
  • Thanks: 1
  • Registered : 05/08/2014
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #7 on: June 22, 2015, 08:54:41 pm »
None of this has to be done with polling. I only recently realized what the SDK's callback function really does, so I'm baking that support into mochad now, so it forwards callbacks to the tcp socket (this sort of thing already happens for X10 RF communication it receives). And OpenHAB has a TCP plugin that can keep a connection open for notifications, and act based on them (I haven't used it personally, but it looks pretty straightforward).

Edit: I should've added that the SDK for some reason only allows one HADevices connection on the A+ at a time though, so it looks like implementing this may make it so that you have to stop mochad if you want to do certain UI interactions on the A+ touchscreen, which is annoying. I've asked about ways around this in the forums, but haven't received a response yet.

Edit2: Okay, well that was easier than I thought. Newest package contains these updates. E.g.:

I turned on an X10 device with an RF remote, then toggled a ZWave switch off/on twice with the A+ app, then typed "AP 1 off" and hit enter, and a few other commands ("AP" and "RF" commands).

Code: [Select]
root@AlmondPlus:~# nc localhost 1099
10/02 18:23:43 Rx RF HouseUnit: J4 Func: On
10/02 18:24:43 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: false
10/02 18:24:47 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: true
10/02 18:24:52 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: false
10/02 18:24:55 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: true
AP 1 off
10/02 18:25:34 BinarySwitch #1 turned off.
10/02 18:25:34 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: false
AP 1 on
10/02 18:25:38 BinarySwitch #1 turned on.
10/02 18:25:38 AP Device: 1 Name: BinarySwitch #1 Index: SWITCH BINARY, Value: true
RF J4 off
10/02 18:26:10 Tx RF HouseUnit: J4 Func: Off
RF J4 on
10/02 18:26:14 Tx RF HouseUnit: J4 Func: On

I'm just now getting started with the HAB stuff.

I'm reading all devices of a certain type through the callback, not just a single device.

Are you documenting your progress anywhere else?
thanks
Kickstarter Backer
Securifi Wiki Editor and Beta Tester, Not a Securifi employee
Almond+, many sensors, IOS App, Android Apps and Widgets

Offline ThePoorShadow

  • Backer
  • *
  • Posts: 17
  • Thanks: 0
  • Registered : 08/08/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #8 on: June 23, 2015, 05:37:04 am »
Though a bit late, I'm about to enter this quest...
I do have an HP MicroServer (G7) with Openhab already installed, and I'm about to try to integrate both Almond+ and OH (and a few Arduinos).

From 2014 to now... anyone got any update on this? Different approaches?

Regards!

Offline SecureComp

  • Backer
  • *
  • Posts: 541
  • Thanks: 1
  • Registered : 05/08/2014
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #9 on: June 23, 2015, 12:35:06 pm »
Though a bit late, I'm about to enter this quest...
I do have an HP MicroServer (G7) with Openhab already installed, and I'm about to try to integrate both Almond+ and OH (and a few Arduinos).

From 2014 to now... anyone got any update on this? Different approaches?

Regards!

Just getting started as well. Hopefully some others will chime in with updates.
Kickstarter Backer
Securifi Wiki Editor and Beta Tester, Not a Securifi employee
Almond+, many sensors, IOS App, Android Apps and Widgets

Offline d.kiran

  • Backer
  • *
  • Posts: 500
  • Thanks: 0
  • Registered : 11/09/2013
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #10 on: July 05, 2015, 03:51:13 pm »
Hows it going with OpenHAB integration ?

Offline SecureComp

  • Backer
  • *
  • Posts: 541
  • Thanks: 1
  • Registered : 05/08/2014
    YearsYearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #11 on: July 06, 2015, 10:39:09 pm »
I won't be working it until next week at this point but I've gathered all the building blocks and have started loading a few things.
Kickstarter Backer
Securifi Wiki Editor and Beta Tester, Not a Securifi employee
Almond+, many sensors, IOS App, Android Apps and Widgets

Offline almrouter

  • Newbie
  • Posts: 2
  • Thanks: 0
  • Registered : 15/07/2015
    YearsYearsYearsYearsYearsYearsYearsYearsYears
Re: Working OpenHab integration
« Reply #12 on: July 15, 2015, 03:19:17 pm »
None of this has to be done with polling. I only recently realized what the SDK's callback function really does, so I'm baking that support into mochad now, so it forwards callbacks to the tcp socket

Hi,
Would also like to know if anyone else has call back working.  I'm new to Almond, but I've been using OpenHAB.

 

Page created in 0.071 seconds with 24 queries.

bottleneck