A switch displaying state on sitemap

Gday,

I have now got owntracks, MQTT and a couple of nice geofences working really well. (thanks Markus & Daniel!)

Down the track I would like to use the switch values in rules but I havn’t figured out rules just yet.

In the mean time I have displayed on the sitemap,
Switch item=PresenceGW label="Is GW @ home?" icon="switch"

This works well but I would rather display the state of the switch (on or off or some other text) rather than a switch that can be changed on the on the sitemap.

Could someone point me in the right direction?

Cheers,
George

1 Like

If the item is not ‘user interactive’, then why define it as a Switch? Surely a String is what you’re looking for (“Home”, “Away”, etc).

Also, you can use mappings=[] in your sitemap and map custom strings, e.g.:

Number item=HVAC_COOL_MODE mappings=[0="[ON]", 1="[AUTO]", 2="[OFF]"]

Cheers,

Pel

In your sitemap, you can render a Switch item as plain text:

Text item=PresenceGW label="Is GW @ home? [MAP(NoOFFYesON.map):%s]"

NoOFFYesON.map:

OFF=No
ON=Yes
-=Unknown

watou & pelnet,

Thanks for that, all good.

It is early days but I am quite enjoying my journey with openHAB, it is easy to see some amazing possibilities. I still know very little about MQTT but that seems like really powerful way to do stuff.

For me I think the next things to understand a bit more is how to configure the sitmap better (is there a place with a heap of examples separate from the demo?), then try a little with rules (same thing is there a place with examples for dummies like me?). I think I might get started with zwave and do a little reading from mysensors.org.

Thanks again.

Cheers,
George

1 Like

I guess this sounds a bit like a canned response, but have you taken a good look at the wiki?

As far as sitemaps are concerned, the demo sitemap does a reasonable job of showing off the core functionality. The layout, frames etc are up to you.
Rules can be a little daunting at first, but after you’ve seen some of the more sophisticated rules on the wiki, the easier stuff is a piece of cake. As you can tell, there is also a community here, ready to get you on the right path. :wink:

Cheers,

Pel

Thanks for that.

I am embarking on trying to understand rules today, I read a little about habmin 2. Would it be best to try to stick to the designer or try habmin2 with the graphical rule editor?

Cheers,
George

Good question. I tried the designer once, but only after writing loads of rules by hand and was rather disappointed. Personally, I would recommend you do it the ‘plain text’ way, and once you’re comfortable with that, then give the GUIs another shot. On the other hand, Habmin2 really looks capable and impressive…

If you get stuck somewhere, let me know, and I’ll see whether I can be of assistance.

Cheers,

Pel