What are your top 3 automations

What bluetooth sensors do you use?

Raspberry Pi 3, Raspberry Pi Zero W, and BT dongles plugged into older Raspberry Pis that donā€™t have BT on the board. These machines are already installed in these locations with other jobs so deploying the BT there is just because of opportunity. Iā€™ve not deployed any specifically to get BT sensing capabilities.

I use sensorReporter or reelyActive to detect the presence of BT devices nearby. Unfortunately, reelyActive only sniffs for broadcast BTLE messages and most devices use a random MAC that cycles frequently so it isnā€™t much good for detecting specific devices (e.g. Richā€™s iPhone is present). sensorReporter is fiddly and needs a lot of tuning to prevent false positives and false negatives.

For now, Iā€™ve managed to get my network based phone detection reliable enough that Iā€™ve actually turned off the BT sensors for now. I will probably go back to reelyActive at some point if I ever have the opportunity to deploy more Pis and what not around the house. I can then use them to keep track of what room, or even what floor our phones are on. I might be able to do something interesting with that informationā€¦

Thanks for the detailed reply. How does the network based phone detection identify which room you are in?

It doesnā€™t. Determining what room my phone is in is a future project that I may never get around to implementing. I just use the network to determine whether one of us is home for presence detection. iPhones are notoriously difficult to detect on the network using simple approaches because they go to sleep when not being used and stop responding to pings. The ne Network binding addresses this by adding in the ability to do an arping. Iā€™ve implemented an older approach that uses hping3 to force the iPhoneā€™s network to wake up and arp to see if it is online. There is also and iCloud integration thread that lets one query the location and other information about the iPhone from Appleā€™s iCloud.

But if you are interested in tracking a phoneā€™s location on a room by room basis using WiFi and have Android based phones, check out FIND (search github and these forums) which uses the signal strength of all the WiFi APs your phone can see to triangulate its position in your house.

I have set a ā€œfixedā€ offset on the Astro Sun Local set#event. Iā€™m using this to turn on lights in the evening.

I want to predict the need to turn on a light based on how bright it is. OK, I could deploy light sensors. So, this is in search of a different (OK, cheapskate) approachā€¦ This falls into the ā€œIā€™m sure it is possible, anything is possibleā€ category. The question is how? And has anybody done it?

Use a local weather conditions to determine the cloud cover and use that to determine if I should turn the lights on earlier than the set#event.

Mike

P.S. My #1 is Nest control & my #2 is lighting control. #3 will come when I master these :wink:

This is essentially what I do. Honestly, Iā€™d recommend investing the $6 in a NodeMCU with a photoresistor. I would say that the cloudy approach is maybe 50% useful. But since you ask, here it is. Note the following:

Iā€™ll let you look at the DPs for the Time of Day stuff.

Iā€™ve created two Groups for each time of day, one Group to contain those lights that should turn on at the start of that time period and another to contain those lights that should turn off at the start of the time period. Iā€™m using Associated Items naming. Iā€™ve also a Group for those lights that should turn on and off when it is cloudy as well as a Group to store the override flags (i.e. when a light is manually turned ON or OFF, do not change that light based on how cloudy it is, just leave it ON or OFF until the next time period).

Group:Switch:OR(ON, OFF) gLights_ON_MORNING    (gLights_ON)
Group:Switch:OR(ON, OFF) gLights_OFF_MORNING   (gLights_OFF)
Group:Switch:OR(ON, OFF) gLights_ON_DAY        (gLights_ON)
Group:Switch:OR(ON, OFF) gLights_OFF_DAY       (gLights_OFF)
Group:Switch:OR(ON, OFF) gLights_ON_AFTERNOON  (gLights_ON)
Group:Switch:OR(ON, OFF) gLights_OFF_AFTERNOON (gLights_OFF)
Group:Switch:OR(ON, OFF) gLights_ON_EVENING    (gLights_ON)
Group:Switch:OR(ON, OFF) gLights_OFF_EVENING   (gLights_OFF)
Group:Switch:OR(ON, OFF) gLights_ON_NIGHT      (gLights_ON)
Group:Switch:OR(ON, OFF) gLights_OFF_NIGHT     (gLights_OFF)
Group:Switch:OR(ON, OFF) gLights_ON_BED        (gLights_ON)
Group:Switch:OR(ON, OFF) gLights_OFF_BED       (gLights_OFF)
Group:Switch:OR(ON, OFF) gLights_ON_WEATHER
Group:Switch:OR(ON, OFF) gLights_WEATHER_OVERRIDE

The following Rule turns on/off the light based on the time of day:

val logName = "lights"

// Theory of operation: Turn off the light that are members of gLights_OFF_<TOD> and
// then turn on the lights that are members of gLights_ON_<TOD>. Reset the overrides.
rule "Set lights based on Time of Day"
when
  Item vTimeOfDay changed
then
  // reset overrides
  gLights_WEATHER_OVERRIDE.postUpdate(OFF)

  val offGroupName = "gLights_OFF_"+vTimeOfDay.state.toString
  val onGroupName = "gLights_ON_"+vTimeOfDay.state.toString

  logInfo(logName, "Turning off lights for " + offGroupName)
  val GroupItem offItems = gLights_OFF.members.filter[ g | g.name == offGroupName ].head as GroupItem
  offItems.members.filter[ l | l.state != OFF ].forEach[ l | l.sendCommand(OFF) ]

  logInfo(logName, "Turning on lights for " + onGroupName)
  val GroupItem onItems = gLights_ON.members.filter[ g| g.name == onGroupName ].head as GroupItem
  onItems.members.filter[ l | l.state != ON].forEach[ l | l.sendCommand(ON) ]

end

Here is the Rule that runs when the isCloudy Item changes. I only adjust the lights based on coudy conditions during the DAY.

// Thoery of operation: If it is day time, turn on/off the weather lights when cloudy conditions
// change. Trigger the rule when it first becomes day so we can apply cloudy to lights then as well.
rule "Turn on lights when it is cloudy"
when
  Item vIsCloudy changed or
  Item vTimeOfDay changed
then
  // We only care about daytime
  if(vTimeOfDay.state != "DAY") return;

  // give the side effects of time of day time to complete
  if(triggeringItem.name == "vTimeOfDay") Thread::sleep(500)

  logInfo(logName, "It is DAY and cloudy changed: " + vIsCloudy.state.toString)

  // Apply the cloudy state to all the lights in the weather group
  gLights_ON_WEATHER.members.forEach[ l |

          val overrideName = l.name+"_Override"
          val override = gLights_WEATHER_OVERRIDE.members.findFirst[ o | o.name == overrideName ] as SwitchItem

          if(override.state != ON && l.state != vIsCloudy.state) l.sendCommand(vIsCloudy.state as OnOffType)

          logInfo(logName, l.name + if(override.state == ON) " is overridden" else " is not overridden")
  ]
end

Notice how I only turn on/off the light if the associated override switch is OFF.

Next we have the rule that detects when there is a manual override on a light:

// Theory of operation: any change in the relevant lights that occur more than five seconds after
// the change to DAY or after a change caused by cloudy is an override
rule "Watch for overrides"
when
  Member of gLights_ON_WEATHER
then
  // wait a minute before reacting after vTimeOfDay changes, ignore all other times of day
  if(vTimeOfDay.state != "DAY" || vTimeOfDay.lastUpdate("mapdb").isAfter(now.minusMinutes(1).millis)) return;

  // Assume any change to a light that occurs more than n seconds after time of day or cloudy is a manual override
  val n = 5
  val causedByClouds = vIsCloudy.lastUpdate("mapdb").isAfter(now.minusSeconds(n).millis)
  val causedByTime = vTimeOfDay.lastUpdate("mapdb").isAfter(now.minusSeconds(n).millis)

  if(!causedByClouds && !causedByTime) {
    logInfo(logName, "Manual light trigger detected, overriding cloudy control for " + triggeringItem.name)
    postUpdate(triggeringItem.name+"_Override", "ON")
  }
end

This rule assumes that any change in state to a member of the weather controlled lights that occurs more than five seconds is a manual override and the override switch is set to ON.

Finally, how is vIsCloudy populated? Like I said before, I use Wunderground. There is a binding now but if you want to use HTTP directly there is a posting Comprehensive Wunderground using HTTP Binding Example that shows that.

Notice, with the above you can have any number of Lights and you can control their behaviors through Group membership alone. If you add or remove Lights or want to change a Lightā€™s behavior all you have to do is change its membership. You never have to touch the Rules.

Finally, I just updated a lot of these rules to take advantage of changes to OH 2.3 (Member of Rule trigger) so there may be a bug that Iā€™ve not seen yet in them. But it has been running for about a day and this part seems to work.

6 Likes

Thanks!

Unbelievably, I can pretty much follow this! Very comprehensive and thorough. I definitely have a lot to learn when it comes to rules. Your structured design ensures proper and consistent behavior. I had already begun to think of modularizing ā€œcommon codeā€. For example, the rules that determine if weā€™re home or not based on location or the state of certain sensors in the house. Your Design Patterns formally codifies what I had in mind.

I do have one quick questionā€¦ what is ā€œmapdbā€ in this ā€œ.lastUpdate(ā€œmapdbā€).isAfter(now.minusMinutes(1).millis)ā€ syntax?

Mike

That makes me happy. :smiley:

https://docs.openhab.org/addons/persistence/mapdb/readme.html

See Design Pattern: Group Based Persistence and https://docs.openhab.org/configuration/persistence.html#persistence-extensions-in-scripts-and-rules

tl;dr, I use MapDB for restoreOnStartup to restore all my Items to whatever state they were in when OH went down or the .items file was saved. And I do so for all of my Items. When you make calls to the persistence methods on an Item, you can specify which persistence engine you want to use to pull the result from. In this case Iā€™m pulling the data from MapDB instead of InfluxDB because I know I store ALL of my Items in MapDB but only those Items I want to chart in InfluxDB. I could set MapDB as my default persistence engine and not pass in the name but I like to be explicit where Iā€™m pulling the data from.

Rich,

By any chance did you post your fan recirculation rule anywhere? I am trying to write a rule to turn on and off my AC fans for 3 minutes every 45 minutes or so and thought why reinvent the wheel if you already posted it somewhere. If not, what would you suggest the best approach might be, Timers? Expire binding? I do have a Recirculation dummy switch setup so that I can turn it off manually on my UI.

Thanks,
Mike

Iā€™ve posted it before somewhere, maybe even above. But my rules work more like a thermostat than what you are describing.

When the main floor and/or the top floor gets warmer than the target temp and warmer than the basement I turn on the fan for 15 minutes (the runtime is controlled by the Nest).

For your use case create a rule with a Cron trigger every 45 minutes. Then create a Switch item linked to your fan and the expire binding set to send command off after three minutes. In the rule send the on command.

The rule will trigger, turn on the fan. Three minutes later the expire binding will turn off the fan. Then 42 minutes later the role will run again.

Thanks for the help. That seems clear enough.

  1. All Of in 15 Sec
    before i leave the house it gives me some time and then all is off

2.Morning , turn on TV and put news ch, Lights, a litle music , and when i leave for work all off again :slight_smile:

  1. Game on
    turn on game(cs), switch PC to headphones, turn off gameing room lights
  1. I use OH to monitor water detectors placed throughout my home to detect leaks in places not easily detected such as by the well pump, water heater, washing machine etc. We live in the country so we have a well pump and a sump pit adjacent to the well pressure tank. I installed a z-wave switch on the well pump and another beside the well pressure tank. I piped in a 120v solenoid valve to the pressure tank and routed the ā€œblow downā€ pipe to the sump pit. If any water detectors sense water my well pump turns off and the switch at the pressure tank turns on, opening the solenoid valve which removes all water pressure in the house. OpenHab reports a text message to my phone to report the incident.

  2. I use a relay available by BRK wired smoke detectors to close a Aeotec z-wave contact, which in turn alerts me via text message if weā€™re not home.

  3. OpenWeatherMap turns our roof/rain gutter heaters on/off if >=15 or <=35 deg. f, using an outdoor z-wave switch.

  1. Sprinkler system based on weather, moisture level, sun, etcā€¦ Saves us tons of money!
  2. Camera system (BlueIris) and OH. Multiple rules based on camera triggers. Amazon packages, front door. Speakers throughout the house speaks if a package has arrived, someone is at the front door, etc.
  3. Security System. Kept most of ADT sensors, replaced brain with a Vista 20P, hooked up to AlarmDecoder and monitored by Eyez-ON. We donā€™t even use the pinpad any more, we do it with DIY keyfobs and fingerprint :slight_smile: Disarms the alarm, unlocks the door. I added a new cool thing too. If EVER i lost my keybob, lost ALL my fingers, I can still issue a command via voice using a super long secret phrase, and the DIY google assistant (Orange Assistant) behind the door will unlock the lock for me.

Can you elaborate more on 1 and 3.
Would love to hear more about the sprinkler system and the FYI finger print hardware.

For #1, I have moisture sensors attached to a pic (atmega328). I added 433mhz transmitter. I didnā€™t go with esp8266 due to battery consumption. This is solar powered so it has to conservative on power. Soil moisture level is transmitted to OH who then decides if the sprinkler needs to turn on. I have it set to 25% moisture. I kept the existing sprinkler ā€œbrainā€ but hooked up to the terminals that turn them on. This way I can control the sprinkler via the ā€œregularā€ way as well as the OH way.

For #3, itā€™s esp8266 based. A fingerprint module is used to capture identity. It also has a 125khz rfid reader on it. The fingerprint reader is just there ā€œjust because I canā€ lol but we find out that we use the key fobs more often because itā€™s quicker. You just tap and thatā€™s it. Once identity is known, the esp will send command to my alarm and not to OH. My alarm panel is driven by a Vista20P connected to an orange pi through the serial port. My OH is connect to the panel through the same orange pi via TCP running alarm decoder code.

The door is locked by a hacked August lock. August locks have no public API so I went ahead and hacked it. I might be publishing this since I have not seen this done before anywhere online. The August lock is simple. Itā€™s driven by a STM32 chip, and simple motors to turn the knob. The hardest part for me was determining when to stop the motor. Well it uses a super tiny LIS3DH accelerometer to know the position of the knob. Its a simple thing but the hardest part is soldering wires on that thing. If the angle is 90 degrees then you know the bolt is in locked position. LIS3DH is smaller than the tip of a pencil eraser!

Thank you. Very interessting. Learned today there are more cracy people out there. We are not alone ā€¦ . ,-)

My automation consists mostly of ZWave and Sonoff devices.
Top three automation things are:

  • Set the heating to ECO mode if nobodyā€™s at home and set it back to normal if somebody arrives at home. Thanks to @rlkoshak for his generic presence detection
  • Dim the light in the living room if weā€™re watching TV (triggered by the input channel of the A/V receiver)
  • Switch on the garden irrigation if the soil moisture is beyond a certain limit. This is currently under ā€œreworkā€. The solar powered arduino is going to be replaced by a solar powered ESP32 since the 433Mhz communication of the arduino caused quite a lot of issues. Gladfully none of them turned my garden into a swamp

I made a new post yesterday and found it merged here. I did provide info on my system and what I do with it. As this thread is more specific, Iā€™ll give my current top uses. My other post has a title on ā€œWhat do you do with Openhabā€ if you want to know about my setup.

  1. I control my fans based on temperature (inside and out), time of day, presence, humidity, and the room being occupied or empty. As the fan noise is annoying, I have it turn off when the room is in use based on lights and not motion. Motion is not reliable as Iā€™m sitting at a computer most of the time and the sensor does not detect me.

  2. Manage family room TV and lights. I have it turn on when I enter the room for the first time that day. I donā€™t want this to happen on later activity. I have a companion rule that works when I leave the house and return. Iā€™ve set up ā€œbreakersā€ in place where I can disable the rules on demand.

  3. Iā€™ve integrated my Openhab with a Harmony hub, Philips Hue bridge, and Google Assistant to allow voice/switch control of lights, TV, audio amplifier, and light scenes. I can use voice or a simple switch to turn on/off my room or even the whole house.

  4. Lastly I use several timers in rules to manage some activities. Iā€™m still learning what methods work best and how to make them work as desired. The first rule is to turn some lights on in a dimmed level when I head off to bed and then turn off shortly after.

As you can see, I use Openhab for home automation and not voice control.

Ron

1 Like

Bindings:

  • Unifi ā€“ 4 devices (3 APā€™s onsite, 1 offsite)
  • WeMo ā€“ 31 devices
  • Onkyo ā€“ 2 devices
  • Nest ā€“ 5 devices (3 AC power, 2 battery)
  • zWave ā€“ 20 devices (only 4 battery operated)
  • Ring ā€“ 1 device
  • Amazon Echo ā€“ 14 devices (one in each room)
  • Sonos ā€“ 15 devices
  • HP Printer ā€“ 1 device
  • MQTT ā€“ Roomba ā€“ 2 devices
  • Chamberlin IQ ā€“ 1 device
  • Ecobee ā€“ 2 devices
  • Open Weather Map
  • Dark Sky Weather
  • HUE ā€“ 32 devices
  • Samsung TV ā€“ 6 devices
  • IPCamera ā€“ 9 devices
  • Bond ā€“ 6 devices
  • LogReader
  • Network
  • Plex ā€“ 12 devices

Overview:

Iā€™m running OH 2.4 with many 2.5 bindings dropped in on a Synology HA pair. I have three Samsung tablets, one on each floor of the house running HabPanel. I have 72 IP wireless based devices connected to 3 Unifi access points, one on each floor of the house. I have 32 HUE (Zigbee) devices going through 2 HUE Bridges on 2 different floors of the house. I have 20 zWave devices connected to a USB bridge on the Synology NAS. This entire setup took me 2 years this upcoming June 2020 with 3k lines of items defined and 27k lines of rules written. I choose to keep all the items and rules in 1 separate file for each which isnā€™t normal from what Iā€™ve read.

I had NO experience with home automation when I started this. I am in the IT field though but not a programmer at heart. I cannot say enough kind words about the OH platform; the community around this platform is fantastic!

Some Rules:

zWave sensors detect humidity on floors, attic and garage which turns on dehumidifiers on via WeMo plug AND turns on ceiling fans via Bond based on where the humidity is reporting.

If Adult phones as a group via Unifi are offline, the house turns down the temperature on 2 different Ecobee thermostats, turns numerous air cleaners via WeMo plugs off, turns lights off that may have been left on.

If wifeā€™s phone via Unifi is offline, turns off her office lights, turns off the master bathroom light and checks to see if the garage door was left open by accident.

Nightly via zWave sensor pointed outside it checks Lux values, a threshold will turn on the outside lights via Wemo Switch, turn on the tree lights via Wemo plug and turn on lights in the bedrooms via WeMo plugs.

When a wake up alarm is setup on the Echo, OH checks to see if itā€™s with in 20, 10, and 5 minutes of reaching the alarm period. OH turns the HUE lamp next to the bed on and raises brightness slight over that period of time. When you cancel the Echo alarm, it automatically shuts the HUE light off.

Based on Lux values via zWave sensor in the house; kitchen and bookshelf above HUE lighting is turned on. Based on the time of day determines the color of the light shown.

Based on Lux values via zWave sensor and HUE motion sensors in certain rooms; room and hallway lights turn on automatically.

When the garage door goes up via Chamberlin IQ, Echo welcomes you home in the garage and gives you the temperature of the house inside. It announces in the house that the garage door is going up. It also turns on the hallway light via WeMo switch and starts Sonos playing in certain rooms. An announcement via Unifi detection that a certain personā€™s phone is detected.

Majority of actions that occur around the house are announced via an Echo.

Movement in front of the house is detected via Ring; it automatically sends adults an email and SMS with a picture and a video MP4 URL to stream.

If the front door, door to garage or patio door are opened via zWave sensor; it lets us know via Echo announcement. If the any of those doors are left open longer than 10 minutes; it automatically turns the 2 Ecobeeā€™s off and air cleaners via WeMo plugs off.

If you want to know what a sensor is reporting; you can ask Echo and it will report it back from OH via Amazon binding (i.e. what is the attic temperature). This rules knows which Echo you were talking into and reports it back to the same Echo device.

Announcement via Amazon if Sonos has started to play outside OR itā€™s too loud outside.

Announcement via WeMo Insight plug when the washing machine is done.

Turning on gym equipment via WeMo plug when the gym light via WeMo switch goes on.

Tell the weather for the day and start playing Sonos music in the master bathroom when the bathroom light via WeMo switch goes on.

Monitoring via zWave devices water possible water leakage areas (i.e. washing machine, sump pump, water heater). Alerting via Amazon announcement, email and SMS.

Via OH CRON rule; turning off stuff at certain times of the night such has lights, tvs, receivers, etc.

In the morning based on HUE motion, start to play Sonos in certain rooms, say the weather, say birthdays and turn on above lighting in kitchen and bookshelf.

Announcement via Amazon when the printer is out of paper, jammed or toner is low.

Tracking the last motion location in the house with all the sensors in every room. Sensors include, HUE motion, zWave Motion and Ecobee remote sensors.

Start to watch a movie in the basement; ask Echo to turn the lights off via WeMo switch. OH then turns off the dehumidifier via WeMo plug, turns off the Ecobee fan, mutes the Onkyo receiver, announces to enjoy the movie and turns the HUE background lights on around area.

With movement detected using HIKVision camers via IPCamera binding; you can change the display on the Habpanel dynamically to the camera dynamically for a set X minutes.

Starting the Roomba vacuums when adults leave the house via MQTT.

Being alerted via email and SMS when the Roomba vacuum is stuck or the bin is full via MQTT.

Monitor internet connectivity via network external probing and disable internet reliant THINGS based on internet being down and announce the outage via Sonos using an audio sink and a MP3 file.

Announce at the home via Amazon when I have arrived at work via Unifi monitoring at the work location.

Announcement via Amazon when the water softener does a cleaning cycle via WeMo Insight plug.

With a tablet in the bedroom; at night turn the tablet on the wall and Ecobee screen to dim. Reverse in the morning.

When the home away switch is ON; automatically turn the lights on around the house at night. In the morning; automatically send an email report on which devices are ON around the house as an audit mechanism.

Announcement via Amazon when the mail has been delivered via zWave sensor.

When you turn on the TV to watch a show; Amazon will automatically announces that it will be shutting off the Sonos around that area.

If a smoke or Co2 alert is detected via Nest detectors; Amazon announces it and OH sends an email and SMS.

If the garage door has been up via Chamberlin IQ for more than 10 or 20 minutes; Amazon announces it in the house.

Numerous announcements occur while Iā€™m at work with an Echo Dot in my office remote from OH. Amazon binding doesnā€™t care where the device is located ā€“ OH can send messages to it.

Next Ideal Step for Me:

I would love to make the house more interactive with questions/answers from Amazon binding. OH predictive asking questions based on sensor values and being able responding to those questions posed to you. As of right now; this is not possible based on the Amazon binding.

Best, Jay

6 Likes