Stories of openHAB conversion, co-existence & augmentation

I have done almost no effort since the begginning of 2015 !
Efforts of the last week:

  • I uninstalled my Freebox Vera plugin and even unplugged the Freebox binding in OpenHAB because I don’t really need it. I replaced one required feature of my Vera plugin (reachable statte of network devices) by the network health binding.
  • I uninstalled my DLNA Vera plugin because I don’t really need it now.
  • I enhanced one TTS messages (weather message)
  • I start playing with the openHAB voice control.
  • I moved to your last binding version and switched my rule code to use your new send MiOS action.

My next steps will still be more setup and rules enhancement than binding development/enhancement:

  • install a Qubino Z-Wave device to control one electric radiator
  • install 2 smoke sensors in my house and control them with my RFXtrx
  • move from my RFXtrx Vera plugin to the RFXCom openHAB binding
  • add more TTS messages in my home automation system
  • enhance my openHAB voice control rule
  • think about how I could use my hue lights to provide information

I still have wishes to make development efforts but that is not yet my priority. I could start by adding few features to the Freebox binding. It should be easy and so a good entry point to binding develoment. The next big step could be to try creating a new binding for my Powermax Pro alarm system but I am not yet sure to be able to do it !

@lolodomo,
Well, you’ve made more progress than me!

I did, however, completely cutover to using @watou’s openHAB Nest Binding this morning, and turned off/de-installed his MiOS Nest Binding. There were definitely a few Rule authoring tricks to navigate in that process.

Next on the list for today is to cutover my top-5 frequently triggered Scenes, and augment the openHAB Example Wiki pages with the specifics of those scenes (to help others along the trail)

I cut over most of my automation to openhab. The only thing Vera runs is my zwave network and the DSC plugin. I translated my ISY plugin over to node.js communicates over mqtt and integrates well with openhab.

  • Garrett

Hey Garrett,
Very interested in hearing the stories of your translation as well. Most Rules are easy to convert, but I’ve found that some need a l more attention to convert due to subtlety in the Rule syntax or, due to some of the quirks of the system (eg. “Unititialized” states etc)

Right now I’m imagining a “MiOS Examples” Wiki page similar in style to the one that @watou created, but with specific sections for the following (with fully worked examples):

a) Augmentation
openHAB Rules that “add” to existing MiOS Scenes. This could be stuff like TTS, Charting, Historic data access (etc) where you take advantage of functionality on openHAB, but largely leave Vera alone.

b) Co-existence
Replacing MiOS Scenes with openHAB Rules, but keeping the Devices. This would likely be the biggest category, given the strength of Vera’s Z-Wave engine (for now)

c) Replacement
These are already coming through, with examples like SEG Data Publication, and @watou’s openHAB Nest Binding (I ended up just converting stuff over wholesale)

Overall goal is to simplify the setup for people wanting/researching transition options, so they don’t try to boil the ocean up front.

Anyhow, definitely interested in getting your input and write-ups into this. Some stuff is easier than others, but it sounds like you’ve also eliminated things like the Web PowerSwitch which I really want to hear about :wink:

In my case, I was able to delete all my Vera scenes and replace them by openHAB rules.
What is still in Vera:

  • of course my Z-Wave devices => no plan to change that
  • RFXtrx control => should try the RFXCOM binding
  • Sonos control => should try the Sonos binding but I must keep the Sonos plugin at least for TTS.
  • Alarm control => should keep the Vera plugin as no openHAB binding exists today for that alarm.

One difficulty with OH rules is that we have no real idea what we can do and what we can’t. I have not found a list of available classes for example. We have only code examples.

In Vera it is easier, we know that we have to respect lua syntax and we have the lua library + the specific luup calls.

[quote=“lolodomo, post:6, topic:186434”]One difficulty with OH rules is that we have no real idea what we can do and what we can’t. I have not found a list of available classes for example. We have only code examples.

In Vera it is easier, we know that we have to respect lua syntax and we have the lua library + the specific luup calls.[/quote]

and that’s a lot of why I want to get examples up there. It’s a lot of trial-and-error unless you have something to copy (similar to using the Luup extensions)

The biggest challenge (to me) is that the are references to it being XTend like, but really it’s just XText based (and so is XTend). There are functional differences, so some constructs don’t work if you follow the XTend examples found on the net…

ie. Similar, yet different

I was wrangling with filters yesterday, for example, and it took a bunch of experimentation.

Anyhow, a bunch of real-world examples should suffice for most, avoiding the need to document the can’s-n-cant’s of the actual language (since they’ll presumably be mostly represented by the real-world use-cases)

A few of my starter/simpler rules are now listed in:
MiOS Binding Example · openhab/openhab1-addons Wiki · GitHub

I’ll add more when I get cycles, but feel free to augment the list as needed.

I was under the impression that Richard was porting PLEG?
Garrett… Are you making Authomation compatible with OH?

I’m sure Richard will update folks on his existing Forum thread when that changes. The last post seems to be from a few months back.

In the meantime, for those adventuresome folks, there’s a lot of stuff that can be readily converted over (co-existed, etc) and it’s not hard once they there are examples to follow. Just like Vera 4-6+ yrs back, it took longer to get the first ones “done” so others had an easier time to follow along 8)

All,

Just wanted to add a thank you, to all who have been contributing to the project here (guessed, lolodomo, gdupray, garrettwp…). I would never have tried to make the jump from Vera to OpenHAB. Vera felt severely limited and slow, but with a PI2 and OpenHAB and the great conversion tool (thanks again guessed) home automation is fun again and feels more like something that has a future.

I will try to contribute something going forward, but expect to go back to lurking for a bit :wink:

I wholeheartedly support an examples page and thanks again.

[quote=“guessed, post:8, topic:186434”]A few of my starter/simpler rules are now listed in:
MiOS Binding Example · openhab/openhab1-addons Wiki · GitHub

I’ll add more when I get cycles, but feel free to augment the list as needed.[/quote]

Ok, I added a bunch more as I’m hand-transcribing my declarative & Lua-based MiOS Rules, including:

[ul][li]Turning Lights ON with Motion events, and automatically OFF after a period[/li]
[li]As per above, but with parts of the Rule executing only at Night Time[/li]
[li]The SmartEnergyGroups/SEG replacement Rule for the MiOS Lua code that did the same[/li]
[li]Disabling/Enabling Nest when Windows are opened/closed (resp)[/li]
[li]Augmenting MiOS Alarm events with openHAB TTS Functionality.[/li][/ul]

These types of Scenes are fairly common on MiOS systems, so people should be able to pickup a few parts for their own use.

I’m specifically interested in hearing feedback (and optimizations) as to how these compare from folks who’ve already written/converted their MiOS Scenes completely to openHAB Rules.

The one issue I’m aware of is that many of the rules won’t survive a reboot and/or restart. Luckily, my Odroid hasn’t rebooted in weeks, and it only restarts when I make a hard reconfiguration of openHAB. I also have fallback Scenes & Rules that shut stuff down daily “just in case”.

The one issue I'm aware of is that many of the rules won't survive a reboot and/or restart.

This, user timers, and sequence expressions are my primary focus on PLEG in OpenHAB.

[quote=“guessed, post:8, topic:186434”]A few of my starter/simpler rules are now listed in:
https://github.com/openhab/openhab/wiki/MiOS-Binding-Example[/quote]

Turning Lights ON with Motion events, and automatically OFF after a period

Here is my own rule that works well with the Fibaro (eye) motion sensor and Vera UI5 (1.5.672). The delay is setup as a parameter of the Fibaro Z-Wave device. As a bonus, the light is switched ON only if the Fibaro detects a minimum light level.

rule "D?tection mouvement chambre" when Item DetecteurChambre changed then if (previousState.toString == "CLOSED" && DetecteurChambre.state.toString == "OPEN") { var Number luminosite = LuminositeChambre.state as DecimalType if (luminosite < 30) { LampeChambre.sendCommand(ON) } } else if (previousState.toString == "OPEN" && DetecteurChambre.state.toString == "CLOSED") { LampeChambre.sendCommand(OFF) } end

I first used your solution but it was not working as well.

PS: I discovered with your example the possibility to call kTimer.reschedule. In my case, I was first killing the timer and then crating again. Your solution looks better.

Just updated the examples that were using using [tt]Timer.reschedule(…)[/tt].

If you’re using this in your rules, then you’ll want to use the Lock objects from:
Taking Rules to New Heights · openhab/openhab1-addons Wiki · GitHub

These Locks have been integrated into my MiOS Examples, for the simpler cases.

Without them, you can get 2x (or more) timers created, and the last-one-wins. The first one carries on, and eventually does whatever it was going to do… In my case, it turns off the TV somewhat unexpectedly, since I have a rule that keeps the TV on if it continues to see motion in a room

I went back to the original model, and updated the examples as such. I don’t think [tt]Timer.reschedule[/tt] works correctly on a Timer that’s already completed. I ran a bunch of experiments last night and, as far as I can tell, it doesn’t re-trigger correctly IF the original Timer has already ended.

Hi guessed,

I think there’s a typo in the night-time script, you have:

if (kTimer == null) {
        kTimer.cancel
        logInfo("house-kitchen", "Kitchen-Motion Timer Cancel")
    }

which gives in the logs:

Error during the execution of rule 'Hall Motion': cannot invoke method public abstract boolean org.openhab.model.script.actions.Timer.cancel() on null

changing the if statement to if (kTimer == null), solves the problem, although it doesn’t seem to allow the timer to cancel and extend?

Also, an additional question - I’m slowly (painfully) trying to migrate to openHab and have moved a timer and have tried my milight rules - anyone else tried milight, as I’m having no end of problems?

Cheers
James

Thanks for the catch! The online version has now been corrected. I made a transcription error on my part as I publish simpler versions of my live rules.

Also, an additional question - I'm slowly (painfully) trying to migrate to openHab and have moved a timer and have tried my milight rules - anyone else tried milight, as I'm having no end of problems?

I can’t tell if you’re having issues with a new openHAB-based Binding, or with the rules that are driving it. Either way, it would pay to open up a thread on the openHAB Google groups, since you’ll get a wider set of eyes on it.

That said, if it’s a “before-and-after” type scenario, we might also be able to do it here also, esp if the issue is Rule syntax/semantics. I’m hoping we can get more examples published, since there are a lot of nuances to writing Rules (and having them actually work as expected 8) )

Thanks for the catch!
No problem.
I'm hoping we can get more examples published, since there are a lot of nuances to writing Rules (and having them actually work as expected 8) )

That would be great, the learning curve is greater than I expected; even after being put off by the level of complexity before. It’s the not knowing whether it’s a problem with the binding, the rule or something else.

Here’s a simple one, I’ve got the following rule (log statement removed):

rule "Lounge Lights Off"
	when
		Time cron "0 50/1 21 ? * MON-THU,SUN" or
		Time cron "0 0/1 22-23,0-4 ? * MON-THU,SUN" or
		Time cron "0 45/1 22 ? * FRI-SAT" or
		Time cron "0 0/1 23,0-4 ? * FRI-SAT"
	then
	
	if (Network_TV.state == OFF && Network_Amp.state == OFF)
	{
		sendCommand(Light_GF_LoungeLamps, OFF)
	}
end

For some reason, it will run when I’ve saved the rule and it gets reloaded, but the following day, it never restarts and I’m at a loss as to why! (I’ll post to google groups too).

One further thing, I’ve ommitted this section from the example:

if (KitchenMotionZoneArmed.state != ON) {
        logInfo("house-kitchen", "Kitchen-Motion Not Armed, skipping")
        return void
}

As of yesterday, whenever I restart the rule, the motion sensor is set to not armed for some reason - I’ve never knowingly disarmed it.

Cheers
James