Author Topic: OpenHAB controlled by Vera?  (Read 1830 times)

Offline Kmitchel

  • Full Member
  • ***
  • Posts: 166
  • Karma: +1/-2
OpenHAB controlled by Vera?
« on: August 28, 2016, 11:23:45 am »
I was able to get OpenHAB running on my Pi3 and able to control all my GE Link Lights (which currently don't work in Vera).  I have a z-wave stick and would like to be able to migrate all my z-wave devices over to the Pi, but have everything automated using the Vera.

My reason is that I currently use PLEG and iPhone presence detector in Vera for most of my scenes and I wasn't able to find similar bindings in OpenHAB.  I'm also using Crush's Echo bridge which works awesome. 

Has anyone done this with OpenHAB, or do I just need to abandon Vera and only use OpenHAB?


Offline Brientim

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2496
  • Karma: +77/-7
Re: OpenHAB controlled by Vera?
« Reply #1 on: August 29, 2016, 05:30:50 am »
I assume you are aware of the Vera OpenHab bindings , this allow you to retain you extant Vera configuration, but it is reverse to the way you describe what you want to achieve


https://github.com/openhab/openhab/wiki/MiOS-Binding

Offline Kmitchel

  • Full Member
  • ***
  • Posts: 166
  • Karma: +1/-2
Re: OpenHAB controlled by Vera?
« Reply #2 on: August 29, 2016, 08:12:45 am »
Yes, I was aware that it is the opposite of what I am looking for.   ;)

Thanks though!  If I could get Vera Plus (UI7) to recognize my GE Link lights, I would be happy to have it run my HA system.  Unfortunately, it has been broken for a long time with no ETA on when it will be fixed.

Offline RHINESEL

  • Sr. Member
  • ****
  • Posts: 359
  • Karma: +25/-10
Re: OpenHAB controlled by Vera?
« Reply #3 on: August 30, 2016, 11:08:17 pm »
Speaking for myself, it doesn't take long to pick up making rules.  Just search for examples that match what you want to do.  I know just about nothing about programming and yes a rule may not work for a day or two while I figure it out but I'm certainly getting better.  Habmin also has a rule generator.  It puts it in a text file in your rules folder that you can either convert to a .rules file or copy and paste it into your normal rules file(s).

PLEG (which I use on Vera) really just graphically makes rules for you.  There isn't anything you can't do in OpenHab that PLEG will do (not that I know of at least).

There are ways to do presence also.  I don't know exactly as I haven't set it up but there are many posts on the OpenHab forums about people doing it.

I'm moving everything over to my Aeon Labs ZStick with the exception of probably my locks since the ZWave binding isn't officially supporting secure class yet.

Offline Kmitchel

  • Full Member
  • ***
  • Posts: 166
  • Karma: +1/-2
Re: OpenHAB controlled by Vera?
« Reply #4 on: September 03, 2016, 09:45:04 am »
Thanks RHINESEL!

Is it a Binding to create rules?  I've tried to search OpenHAB and Google for creating rules, but I can't find a good tutorial/walkthrough.  Do you have any suggestions?

Thanks in advance!

Offline RHINESEL

  • Sr. Member
  • ****
  • Posts: 359
  • Karma: +25/-10
Re: OpenHAB controlled by Vera?
« Reply #5 on: September 10, 2016, 10:18:44 am »
Thanks RHINESEL!

Is it a Binding to create rules?  I've tried to search OpenHAB and Google for creating rules, but I can't find a good tutorial/walkthrough.  Do you have any suggestions?

Thanks in advance!

Sorry for the late reply, I'm spending less time here now that I'm moving most of my stuff off Vera (leaving only Locks and thermostats until security class and a solid radio thermostat binding is created).

Bindings have nothing to do with rules.

How OpenHab is envisioned is that a OH system is a stand alone system.  It is simply a brain.  People "attach" other items to the OH system.  Say for example, you want to use an LG TV.  A person (remember, opensource... no manufacturer) created the LG TV binding to allow OH to connect to the television.   Vera has it's own binding.  A binding is a way for OH to communicate with the device of your choice.  Think of them as "plug-ins" for Vera.

As for learning rules.... there is no easy process (though the basics isn't that hard.  They pretty much follow a "When.... Then...." formula.  It's just the formatting of the command you need to learn.  There is a sample rules page https://github.com/openhab/openhab/wiki/Samples-Rules but I found most of these are more advanced rules than basic.  I found that simply visiting the forum and reading the posts in the rules sections taught me a lot.

What I did is create a "test" rules file.  I started very easy.  My first rule was when I turn on one outlet, a second would also turn on.  Once I figured that out it was easy to expand upon that.  Turn on a switch, also turn on an outlet.  Make one outlet match the state of another outlet.  These are all very similar.  Next was adding a time component (took a few minutes to understand CRON).  When XXXXXX... turn on XXXXX.  This led me to using the Astro binding (a binding to calculate sun and moon positions) so I could integrate sunset/sunrise into my rules.

The tl:dr version is... start small.  Do something very basic and then it's easy to expand upon that.  If you ever have questions, the people over at OH forums are great with newbies.  My username there is the same as here so feel free to ask anything you need.  I'm still a beginner myself, but we can figure it out together.

Last thing.... if you're relatively new to Linux and programming in general... it takes time.  While I have some problems with Vera itself as a company, setting up OH has given me more respect for the people who created Vera (and other "commercial" systems).  Granted, they can probably do in 10 minutes what it takes hours for me to do.


Offline markoe

  • Full Member
  • ***
  • Posts: 126
  • Karma: +4/-3
Re: OpenHAB controlled by Vera?
« Reply #6 on: May 25, 2017, 03:56:26 am »
So I feel I will also give OH2 a try and start moving forward from vera.

Little bit nervous because my Linux skills and programing skills are at litle rusty.

So I understand it is possible to get vera devices  visible in OH2 but not an other way round. That will lead to the situation that vera will enetually be handling zwave Network.


Offline jswim788

  • Hero Member
  • *****
  • Posts: 550
  • Karma: +30/-2
Re: OpenHAB controlled by Vera?
« Reply #7 on: May 25, 2017, 12:28:35 pm »
So I understand it is possible to get vera devices  visible in OH2 but not an other way round. That will lead to the situation that vera will enetually be handling zwave Network.
openHAB has a REST API, so it is perfectly possible to control it from Vera.  I do exactly that.  But there is no Vera plugin, so this is something you do by writing lua code for anything you want to control specifically.  Note that the Z-wave binding in OH2 is under development and is not quite as mature as the on in Vera, but it is catching up.

OH2 works, but I'm not thrilled with it.  It seems to add complexity where none is needed.  Lua is a simpler language but it gets the job done fairly well.  Go look at the forums and see people struggling with the 'type' of the item.state in the rules.  And the documentation is poor - you'll have to become a reader of the forums to get the information you need (same is true for Vera).  On the other hand, OH2 has a much more active community and there is a lot of development going on, so it may have a better future.

Offline Drex

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Re: OpenHAB controlled by Vera?
« Reply #8 on: December 13, 2017, 02:27:46 pm »
jswim-

can you give some sample code/commands that you control in OH2 with vera?  Just to get an idea of the syntax. Thanks

Offline jswim788

  • Hero Member
  • *****
  • Posts: 550
  • Karma: +30/-2
Re: OpenHAB controlled by Vera?
« Reply #9 on: December 13, 2017, 11:25:55 pm »
Sample below.  Change the IP and port as needed.

Code: [Select]
function setOpenHabItem(item, value)
  local http = require("socket.http")
  local ltn12 = require("ltn12")
  local path = "http://192.168.1.205:8090/rest/items/" .. item
  local payload = value

  luup.log("setOpenHabItem payload is " .. payload)

  local response_body = { }
    local res, code, response_headers, status = http.request
    {
      url = path,
      method = "POST",
      headers =
      {
        ["Content-Type"] = "text/plain",
        ["Content-Length"] = payload:len()
      },
      source = ltn12.source.string(payload),
      sink = ltn12.sink.table(response_body)
    }

end

Offline Drex

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Re: OpenHAB controlled by Vera?
« Reply #10 on: December 14, 2017, 09:43:18 pm »
awesome. thanks.

wish there was more structured documentation.


last question:

if I wanted to 'emulate' or replicate lets say alarm sensor status (door locks, etc), in Vera from a binding (like Omnilink on OH2), as in 'real time', would I assume the logic would go as follows:

in OH2, the respective Alarm switch/contact's state (a 1 or 0) would need to trigger the corresponding virtual switch in Vera through the MIOS binding; every time a door or window is opened, let's say, it would update the corresponding 'device' in Vera.

To arm/disarm the alarm, I would use your syntax above to actually arm or disarm, or change state, etc.  Is that correct?

Thanks for your help-- it's alot easier to understand with 'live' demo code.

-drex



Offline jswim788

  • Hero Member
  • *****
  • Posts: 550
  • Karma: +30/-2
Re: OpenHAB controlled by Vera?
« Reply #11 on: December 15, 2017, 12:12:06 pm »
You don't necessarily need the Mios binding in openHab - here's an example rule I use to shadow an item in a virtual switch on Vera from OH:
Code: [Select]
import java.net.URLEncoder

rule "Front Door Shadow"
when
    Item ZONE1_TRIPPED changed
then
    if(ZONE1_TRIPPED.state == ON)  sendHttpGetRequest("http://127.0.0.1:3480/data_request?id=action&output_format=xml&DeviceNum=40&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1")
    else sendHttpGetRequest("http://127.0.0.1:3480/data_request?id=action&output_format=xml&DeviceNum=40&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0")
end