I’m new, only started this OpenHAB Raspberry PI thing about 2 weeks ago. However, so far, I have managed to install a number of Switches and my Honeywell thermostat into items, interface those items so they show as devices in Alexa, and write a couple of very primitive rules in the rules cfg file (i.e. cron and Astro sunset).
This post and my goal is open and close my garage door.
In a previous life, I installed a Z-Wave Plug-In Outlet in the garage. Using other Z-Wave software, I created a Scene that turned on the Plug-In outlet and then immediately turn off the power. Next, I plugged a Relay circuit into the outlet. When the relay saw power it closed the contacts, when power was immediately removed, the contacts opened. Then I wired this momentary closed/open circuit to the garage door switch. Thus the momentary closed circuit triggered the door to open if it was close or close if it was open.
OpenHAB is a bit different from my previously Z-Wave GUI software and I need some basic direction or point me to the proper readings so I can create a similar Rule.
2 Questions
Frist question, when writing an openHAB Rule what would be an appropriate ‘WHEN’ trigger. I only want to manually call this rule. A fixed time/CRON would not work in this case, nor would an ASTRO Sunset help me out here. So, what can I use for the WHEN Trigger?
Second (and final question), What Tag do I need to enter in a Rule so Alexa will discover the rule? Can I use the same [LIGHTING] tag I used with my light switches?
Thanks for your time read this as I made a short story long.
rule "Indoor Holiday Mode On"
when
Time cron "0 0 6 1/1 * ? *"
then
logInfo("sunriseholiday.rules", "The Indoor Holiday rule has triggered ON")
if (VIR_IN_HolidaySwitch.state == ON)
{
HolidayRemote1.sendCommand(ON)
HolidayRemote2.sendCommand(ON)
}
end
Of course that rule could be triggered like this as well:
rule "Indoor Holiday Mode On"
when
Item VIR_IN_HolidaySwitch changed to ON
then
logInfo("sunriseholiday.rules", "The Indoor Holiday rule has triggered ON")
THANK YOU Squid & opus. I appreciate your reply’s.
I had never thought about a Virtual Switch. The second you mentioned it, It was like a light bulb going off.
if (VIR_IN_GarageDoorSwitch.state == ON)
Is there any type of wait command or loop I can create to give a second or two between sending an ON and an OFF?
then
…
{
GarageOC.sendCommand(ON)
GarageOC.sendCommand(OFF)
}
EXPIRE 10 — Is it a second parameter that needs to be passed?
Or should I add a time+10 seconds for the EXPIRE?
Also, I thought about this right as I hit the reply button.
Should I add a change state parameter to the Virtual switch? for example;
VIR_IN_GarageDoorSwitch.state == OFF
Switch Switch_GarageS “Garage Door Switch” [“Lighting”] {channel=“zwave:device:c4664bf8:node8:switch_binary”, expire=“10s,command=OFF”}
The rule now looks like this;
rule “Trigger Garage Door”
when
Item VIR_IN_GarageDoorSwitch changed to ON
then
{
Switch_GarageS.sendCommand(ON)
VIR_IN_GarageDoorSwitch.state == OFF
logInfo(“Trigger Garage Door.rules”, “Garage Door rule has triggered”)
}
end
Now after savng the files, reboot the RaspberryPI and I ask Alexa to search for new devices she does NOT find Switch_GarageS.
If however, I remove the expire syntax Alexa has no problem at all seeing Switch_GarageS
What’s going on?
Could Alexa not accept the expire binding?
I would also suggest removing the “ON” from your when statement:
when
Item VIR_IN_GarageDoorSwitch changed
This way, the rule will trigger whenever you toggle your virtual switch, and you can use it to represent whether your garage door is open or closed in your sitemap. You can then use map transformation to translate ON into “Open” and OFF into “Closed” (or the other way around).
Good Day folks,
Thanks for all your help. I did not mean to leave anyone hanging yesterday when I did not respond, but I have been working on trying to find what is going on.
It appears I have, or had, multiple problems. One the most stupid was I kept enabling EXPIRE through the PaperUI GUI. Then to make sure I did not have any bad information in the buffers, I would reboot the Raspberry-PI and try to figure out why EXPIRE was not working and not installed. All I want to say now is EXPIRE is now edited into my Binding line.
The next problem, I came across was an old implementation. I had previously mention I used other zwave software prior to openHAB. Will I had setup ‘Routines’ in my Alexa mobile app. Those old routines were getting the way as I tried to get the garage door to open/close. They were calling for switches that had been renamed in the process of changing to openHAB. Guess what, the Routines are gone now.
I have not gotten the Garage Door to open and close through openHAB/Alexa, but I think I am closer.
Thanks for EVERYONE’s suggestions. I experimented with each and every one of the ideas and those definitely helped me to teach this old dog new tricks and narrow down my multiple problems.
I will update when I have more to add. I am really hoping it is good news!
Thx
Bill