Switch with multiple values?

1,058 views
Skip to first unread message

Neil Renaud

unread,
Jul 13, 2014, 5:30:14 PM7/13/14
to ope...@googlegroups.com
Hi,

Has there ever been any thoughts on having a switch that has multiple states i.e. In LightaveRF we have a mood switch that has 5 Moods (and off) on one switch. Pressing the button toggles from mood to mood. I've represented as a Sting but think this would be better as a Switch that has 6 states.

Any comments?

Neil 

Mat Smith

unread,
Jul 13, 2014, 6:07:19 PM7/13/14
to ope...@googlegroups.com
I use Lightwave and I totally agree, this would be so useful

Mark

unread,
Jul 14, 2014, 12:03:40 PM7/14/14
to ope...@googlegroups.com
Are you looking for the Widget, or to have this baked somehow into a Switch Item?

For the visualization, you can use the Selection or Switch component in the .sitemap file:
    
    Selection item=AlarmArea1DetailedArmMode label="Arm State" mappings=[Disarmed="Disarmed", Ready="Ready", NotReady="Not Ready", Armed="Armed", Force="Force", ExitDelay="Exit Delay", EntryDelay="Entry Delay", Stay="Stay", StayInstant="Stay Instant"]

OR

    Switch item=AlarmArea1DetailedArmMode label="Area 1" mappings=[Disarmed="Disarmed", Ready="Ready", NotReady="Not Ready", Armed="Armed", Force="Force", ExitDelay="Exit Delay", EntryDelay="Entry Delay", Stay="Stay", StayInstant="Stay Instant"]


although neither really enforces the domain value on the underlying Item, and the latter style only works (on iPhone) with a smaller number of selections.

Thomas E.-E.

unread,
Jul 14, 2014, 6:37:56 PM7/14/14
to ope...@googlegroups.com
Hi Neil,

i would represent the moods as an item of type "Number". Using the mapping file in order to translate into human readable text is also a good idea.

Best, Thomas E.-E.

Neil Renaud

unread,
Jul 15, 2014, 3:08:19 AM7/15/14
to ope...@googlegroups.com

Hi Thomas/Mark,

Both interesting ideas. I assume the real way to use a mood switch will be to set up rules for them. In that case I assume numbers are better than strings in that case as equality checking will be quicker and also the ability to use less than and greater than in your rules would allow creation of mood2 where it is everything on mood1 plus some extras...

Thanks for the tips, it is early days for my setup so still getting my head round how to connect all the things together.

Neil

--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/s9RyVgXTlFM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Mark

unread,
Jul 15, 2014, 10:58:24 AM7/15/14
to ope...@googlegroups.com
For me, the "values" are ones coming from another HA System that I'm integrating.  They're already coming over as mnemonic strings representing the various (un-ordered) states of an Alarm Panel.

eg. NotReady, EntryDelay, ExitDelay

The string compares you do here will be minor compared to what openHAB is doing internally for you ;)

Mat Smith

unread,
Jul 15, 2014, 12:36:29 PM7/15/14
to ope...@googlegroups.com
Thanks Mark and Thomas, this really helped me. Seems very obvious to use item type "Number"... and it was a mystery to me before now.

I noticed in the UI (iPhone and web app) that if you define a switch in the sitemap (referring either to a switch or a number) it remembers the last state. Of course this could be very useful. But in the case where you press the same command again, it doesn't re-issue the command, but instead it simply deselects the switch in the UI.

For instance I have a single Squeezebox switch with multiple mappings for different actions: play, pause, stop, forward, back. If the last button you pressed was "back" then this stays selected. If you press it again, it doesn't go back again, it deselects the UI button.

This is simply not girlfriend-proof ;)

Is there any way to make the press of a switch UI element (either number or switch item) momentary?

Christoph Wempe

unread,
Jul 15, 2014, 1:23:41 PM7/15/14
to ope...@googlegroups.com

Mat Smith

unread,
Jul 15, 2014, 2:00:46 PM7/15/14
to ope...@googlegroups.com
Hurrah, thanks. 

--

Mat Smith

unread,
Jul 16, 2014, 8:12:35 AM7/16/14
to ope...@googlegroups.com
Hi Neil

Sorry to keep this thread alive when the original question was already answered, but I'm just coming to implementing moods myself. You said you represented as a string, but as far as I can tell the item type "String" isn't supported by the binding. Maybe I'm wrong? I have changed the item definition to this:

String BedroomMoods "Mood" {rfxcom=">3363456.16:LIGHTING5.LIGHTWAVERF:Command" }

and the sitemap:

Switch item=BedroomMoods icon="light-on" mappings=["Group Off"="All Off", "Group Mood 1"="Mood 1"]

Is that what you did? This throws up the following error:

Binding configuration of type 'rfxcom' of item æBedroomMoodsæ could not be parsed correctly.
Invalid item type for value selector 'Command'!
        at org.openhab.binding.rfxcom.internal.RFXComGenericBindingProvider.processBindingConfiguration(RFXComGenericBindingProvider.java:146)

On Sunday, 13 July 2014 22:30:14 UTC+1, Neil Renaud wrote:

Neil Renaud

unread,
Jul 16, 2014, 9:00:56 AM7/16/14
to ope...@googlegroups.com

Hi Mat,

It isn't currently supported that I can see on the openhab master bench. I've changed the code and submitted a pull request once that is merged you can use string but I think I might change it to number as per this thread when I get a chance.

If you are happy compiling yourself you should be able to download from my git repo.

Neil

--

Mat Smith

unread,
Jul 16, 2014, 10:48:40 AM7/16/14
to ope...@googlegroups.com
Hi Neil

Got it. Spent last hour or two trying to compile it myself, failed miserably despite following a number of long tutorials... may just wait until it's merged...

Mat

Mat Smith

unread,
Jul 16, 2014, 3:40:52 PM7/16/14
to ope...@googlegroups.com
Hey again Neil

Don't suppose you would be able to post your compiled rfxcom binding here for me to play with?

Mat

On Wednesday, 16 July 2014 14:00:56 UTC+1, Neil Renaud wrote:

Neil Renaud

unread,
Jul 20, 2014, 3:15:55 AM7/20/14
to ope...@googlegroups.com

Hi,

The original pull request has been accepted but I've just submitted another one changing it to number.

Regards,
Neil

Reply all
Reply to author
Forward
0 new messages