3 Way state switch request


I’m new to openhab and I did manage to get some stuff working (Philips Hue, Kodi and MTQQ), but I need something that is a bit more advanced and I have no idea how to get this done.

I would like to have a switch with three states (“At home”, “Away” and “Asleep”).
On the detection part I would need “Asleep” to have a priority status over “At home”.

So far I did manage to detect “At home” with the Network Health binding (checking for the IP of my phone).
I also managed to set a switch (Sleep) to on or off depending on my mobile phone charge status (Tasker sends a http request to Openhab whenever it is wirelessly charging during certain hours).

I hope someone has an idea on how to handle this, cause I’m stuck on this.

Thanks for your time.


My first thought is to have two switches–one for home/away and another for asleep/awake. Then you’d just set up your rules accordingly to read the state of each switch via an if() statement and do whatever it is you want it to do.
For instance, you could set up rules that turn on lights when a motion sensor gets triggered. If you’re at home and awake (home.state == ON && asleep.state == OFF), lights come on full brightness. If you’re home and asleep (home.state == ON && asleep.state == ON), lights come on dimly (for the walk down the hall to the bathroom?) And, if you’re not home when the motion gets triggered (home.state == OFF – no need to check asleep/awake state), it sends an alert to your phone, activates an IP camera, etc.

A String item can fulfill the need of an n-way switch. For example.


String HouseMode "House Mode [%s]"


Switch item=HouseMode mappings=[home=Home,away=Away,sleep=Sleep]



rule HouseModeCommand
  Item HouseMode received command
  if (receivedCommand.state == "away") ...

There is something very similar in the Ecobee Examples wiki page.

Thank you both for the reply’s.
I will try out watou’s option first as it seems like the most easy one to maintain.

Yeah, that’s a great option. I wasn’t quite sure it was possible, since I’m rather new to this, myself.

@watou, I took another look at the ecobee examples page, and I’m interested in setting up the ecobee actions. Is there a JAR around that I can put in my addons folder? I couldn’t seem to find it on github, and it looks like it won’t be “official” until OpenHAB 1.8 rolls out…?

@Chad_Hadsell: You can find org.openhab.action.ecobee-1.8.0-SNAPSHOT.jar in distribution-1.8.0-SNAPSHOT-addons.zip. Just put it in your addons folder along with the matching binding JAR from the same .zip file.