Hello
I need something like a switch with 3 states: on / off / auto
Does something like this exist?
background: i want a lamp to be on, off or controlled by another light sensor (auto mode)
Hello
I need something like a switch with 3 states: on / off / auto
Does something like this exist?
background: i want a lamp to be on, off or controlled by another light sensor (auto mode)
You can use normal Switches with a Mapping.
I am not at my pc at the moment but it should look like this.
Switch mapping=[on=“On”, auto=“Auto”, off=“Off”]
Take a look at the wiki entry on sitemaps.
Keep in Mind: You will have to use a String Item for this (Switch Item is ON or OFF (or uninitialized))
Or you use a Number Item and set up a Mapping like Switch MySwitch mapping=[1=“On”, 2=“Auto”, 0=“Off”], depends on how you bind the item to your Hardware…
There are no trinary switches in OH so you will have to implement some of this yourself. @patrickse and @Udo_Hartmann have already suggested answers to part of the problem.
There are three parts to this.
Sitemap:
As @patrickse suggests, you will need to add your Item as a Switch with a Mapping on your sitemap to give you the three buttons on your UI.
Item:
As @Udo_Hartmann suggests, you will need to make your Item be a String or a Number as Switches cannot have three states.
Rule:
You need a rule set up that triggers on changes to the Item and when it switches to ON it sends a command to your lamp Item to switch ON, when OFF it sends the command to the lamp Item to OFF. You also need in your rule that processes updates to your light sensor an if statement that checks whether the Item is AUTO.
Are there any plans to implement this natively in OH? That is a very common requirement in control software
There really at no plans in OH. Everything in OH is accomplished by volunteer effort. no one has volunteered to implement this in the green years since this thread was last replied to. But if a volunteer decides to implement it then it will happen
As it is, this is pretty trivial to do without a native Item to do it It’s just configuring how it’s displayed really. Everything else is something you’d have to do anyway.
I was able to accomplish something similar using the approach in the link below. You will need to adjust the rules to meet your needs.
HTH
Jim
Thanks, but it is not the rules which bother me - it is more the UI I am having an issue with.
A three state toggle list item is what I am looking for really.
I am a software developer for more than 30 years now, but I cannot or do not want to design UI elements - especially in a language I am not used to and where I do not know all implications of a setting like in CSS.
There is one in the marketplace, but with a red warning. “Just use for debugging or if you are the owner “
If you both could describe your use cases a bit more detailled, we could tell you how they can be solved in openHAB. e.g. the best way to both control a “multi-state” device and have it in a UI would be to use “ENUM”-lists as you would use in programming. This would be like Patrick suggested a string item with an mapping. You then combine the mapping in the UI to visualize or change it via a widget (like this one: Simple Selection Widget up to 11 buttons (or more))
That is built into the UI.
For sitemaps use a Switch element with mappings.Sitemaps | openHAB
For MainUI set command options on the Item’s State Description metadata and that should be enough to tell it to present a selection to you instead of a binary toggle.
If you don’t like trigger defaults, you’ll have to did into the code and create a custom widget, which unless you have a very specific design is more just configuration than coding css and the like.
Thank you for the hint.
But my impression was that sitemaps are out and habpanel is in?
I switched over to habpanel years ago,
Last time I was using sitemapsppp was with version 2, I think.
(Using openhab since 2016 I think)
I want to control certain devices (groups of devices).
They can be always off, always on, or switched by a rule (auto)
The suggested switch, I use already, but it is too prominent for the use case I have (using too much space).
Having a three state toggle switch would be convenient.
HABPanel is out, replaced by MainUI. There hasn’t been an update to HABPanel in half a decade I think.
Sitemaps will always be supported.