|
Post by papa on Jun 3, 2017 20:49:07 GMT
An "Away Mode" for Security & Convenience Updated Dec. 18, 2018
Set a node jumper to indicate "Away Mode," that is, when no one is home. Then when Away Mode is ACTIVE, OpenHAB can simulate home activity for security or convenience. First, you need some thing(s) to be controlled when Away Mode is ACTIVE, like a node whose solid state relay (SSR can turn a light (or other electrical device) on & off. For example, like this, you could have built a Node 05 (your choice as long as it is between 5 & 255; unique; & you are consistent) which can turn an AC appliance on & off via a Solid State Relay (SSR). Also for Node 05, you could have the following entries in the indicated OpenHAB configuration files: .items fileSwitch Act_Node05 { mqtt="<[mosquitto:home/rfm_gw/nb/node05/dev16:state:default::]", mqtt=">[mosquitto:home/rfm_gw/sb/node05/dev16:command:*:default]" }
.sitemap fileSwitch item=Act_Node05 label="Node05 Output"
|
|
|
Post by papa on Jun 3, 2017 20:51:51 GMT
Adding an Away Mode Jumper to a Node Updated Dec. 18, 2018
Next as follows, on any one of your nodes (which might have other sensors & functions), install a SWITCH (actually a jumper) that will signal that Away Mode is on or off. ^^^ See this schematic from here. (Click on the pic for a larger view.) Choose one of the switches in the schematic above to signal Away mode. The following will assume SWITCH3. The "switch" will simply be a jumper wire that can connect D7 to GND & indicate Away mode to the OpenHAB programming. Programming the Node which will have an Away Mode Jumper When you customize the latest choose_nodes sketch, (among any other functions you choose in the DEFINE list), UNcomment (remove "//" from) #DEFINE SWITCH3 (which will use device 45). The following will also use NODEID 33 (your choice as long & its between 5 & 255 & you are consistent). You also need to customize your radio frequency, radio high power setting, & your encryption key. In this post & the next, I've color coded 45 & 33 so you can see where to alter the OpenHAB entries if you use a different switch or node ID.
|
|
|
Post by papa on Jun 3, 2017 21:10:34 GMT
OpenHAB Entries for the Node with an Away Mode Jumper Updated Dec. 16, 2018
.items fileContact Away "Away Mode [MAP(away.map):%s]" <secure> {mqtt="<[mosquitto:home/rfm_gw/nb/node33/dev45:state:CLOSED:ON],<[mosquitto:home/rfm_gw/nb/node33/dev45:state:OPEN:OFF]"} String getAwayState {mqtt="<[mosquitto:home/rfm_gw/sb/node33/dev45:command:*:default]"} Add an away.map file in OpenHAB's transform folder with the following contents: CLOSED=ACTIVE OPEN=NOT ACTIVE undefined=UNKNOWN -=UNKNOWN Download to openHAB2's \conf\icons\classic folder:
secure.svg (4.37 KB) secure-closed.svg (4.26 KB) secure-open.svg (2.42 KB) .sitemap fileText item=Away .rules filerule "Update Away State" when Time cron "0 0/1 * * * ?" then sendCommand(getAwayState, "READ") end rule "Node05 Output ON about 7:30 pm" when Time cron "0 25 19 * * ?" then if (Away.state==CLOSED) { // Schedule a random ON event up to 15 minutes from now createTimer(now.plusMinutes((new java.util.Random).nextInt(15)) ) [| sendCommand(Act_Node02, ON) ] } end rule "Node 05 Output OFF about 8:30pm" when Time cron "0 25 20 * * ?" then if (Away.state==CLOSED) { // Schedule a random ON event up to 15 minutes from now createTimer(now.plusMinutes((new java.util.Random).nextInt(15)) ) [| sendCommand(Act_Node02, OFF) ] } end ============================= (If the Away Mode jumper is in place between D7 & GND on a node, the above 2 rules command the Node 05 relay to pseudo-randomly turn its light on & off near the times indicated in the cron expressions. Rules could be written to control other nodes using the state of the Away jumper.) How will you use Away Mode?
|
|
|
Post by jimkernsjr on Jun 26, 2017 1:25:22 GMT
Some easy automatic ways to do this: -The network binding. Find the IP your smartphone uses (best to assign it a static DHCP entry), and use Online to determine if you are home. Some phones may drop the wifi when the screen sleeps though. See attachments. Item for your items file: Switch ndAndroidPhone "Android Phone" <network> (gOnlineNetDev) {channel="network:device:10_1_1_106:online"} -IFTTT has Geofencing and Openhab has a IFTTT plugin. -Nest Thermostat and RadioThermostat can do it if the app is on your phone. Just mimic your thermostat's away mode. My Radiothermostat has an awesome JSON interface, so I had built a setup to see all it's status. It has an app for my phone that sets it away when I leave my predefined boundry. I just watch my openhab thermostat away item and change my master home away... -Another fun thing to make is a control panel with HABpanel and a cheap android tablet you can pick up for $25: see attachments And some other great geofencing ideas: community.openhab.org/t/best-presence-detection/11966/12Attachments:OpenHABnetwork (35.64 KB)
|
|
|
Post by papa on Jun 26, 2017 1:55:22 GMT
Most might prefer one of the Away modes that you describe, Jim. I tend to keep my phone WiFI off most of the time. & I wanted a way to "hard wire" my Away mode on one of my nodes.
I like the HABpanel on the tablet. I've been meaning to try that some time.
|
|
|
Post by jimkernsjr on Jun 27, 2017 16:21:35 GMT
If you want, I have the JSON widgets for that weather panel you see on the bottom, and python scrips to do that "time to work" panel. If any interest, I can put them on my github, but here is the link where I posted it on this forum: community.openhab.org/t/custom-widget-current-weather/18216/45These guys actually created it but I had a hard time to get it to work correctly with wunderground. You'll need the weather binding working, but you already gave people instruction on how to do it. If they did a good job, they can extend it to this, this just reads from the already installed binding... I like the tablet with the away button myself. My kitchen bar is close to the door and I can tap it on my way out and see what my normally 1 hour journey to work will bring!
|
|
|
Post by papa on Dec 16, 2018 21:25:45 GMT
Away Jumper / Switch on a Gateway
Also UNcomment (remove // from the line's start): #define AwaySwOn a gateway, the jumper goes between Arduino D 6 & GND. For an Away jumper / switch on Gateway One, the items are (changes color-coded): Contact Away "Away Mode [MAP(away.map):%s]" <secure> {mqtt="<[mosquitto:home/rfm_gw/nb/ node01/dev42:state:CLOSED:ON],<[mosquitto:home/rfm_gw/nb/ node01/dev42:state:OPEN:OFF]"} String getAwayState {mqtt="<[mosquitto:home/rfm_gw/sb/node01/dev42:command:*:default]"}
See above posts for OpenHAB programming to control nodes based on the Away mode state.
|
|
|
Post by greginkansas on Dec 16, 2018 23:37:10 GMT
Have a look at this for your tablets. I use it with sitemaps for where they hang in the house.
papa: Thanks for sharing, Greg.
|
|
|
Post by papa on Dec 20, 2019 16:56:29 GMT
Problems & TroubleshootingIf openHAB was rebooted (Windows restart, rules edit, etc), openHAB set Away state to NULL so that rules based on Away=ON or Away=OFF did not trigger. This happened even though I had installed & configured persistence to restore on startup. I created a virtual AwaySw switch on the UI by defining the item, Switch AwaySw Away also was not restored on startup. This thread documents how I worked around the problem.
|
|