[SOLVED] Make a item show Online instead of a switch

Hi All.
i have a question . I use network binding. on 2.5m4
on the site map i have switches that show the status of my system. but now i am trying to have them rater say Online or Offline.(did search but could not realy see anything.

here are some of my files.
Items :

Switch  Allen                       "Allen"                             (System)    {channel="network:pingdevice:Allen:online"}
String  Allen_Online                "Allen Online"
Switch  Aletchia                    "Aletchia"                          (System)    {channel="network:pingdevice:Aletchia:online"}
Switch  Kodi                        "Kodi"                              (System)    {channel="network:pingdevice:Kodi:online"}

Site map :

Frame label="Online - Live" {
         Default   item=Allen                        label="Allen Iphone"                icon="apple"
         Default   item=Allen_Online                 label="Allen Iphone"                icon="apple"
         Default   item=Aletchia                     label="Aletchia Iphone"             icon="apple"

Rule : (first try)

rule "Allen Online"
when
	Item Allen changed from OFF to ON
then
	// do something
   Allen_Online.postUpdate(Online)	
end

Am i in the right direction or way off ?

Look at Mappings here.

Switch item=<itemname> [label="<labelname>"] [icon="<iconname>"] [mappings="<mapping definition>"]

Since you want to post a string you should use

Allen_Online.postUpdate("Online")	

You might also want to change the item definition to

String  Allen_Online                "Allen [%s]"

so that the name stays, but the status string can change from “Online” to “Offline”.

1 Like

Simply don’t use Default but Text plus mapping in your label:

./items/the.items:

Switch  Allen    "Allen [MAP(online.map):%s]"    <apple> (System) {channel="network:pingdevice:Allen:online"}
Switch  Aletchia "Aletchia [MAP(online.map):%s]" <apple> (System) {channel="network:pingdevice:Aletchia:online"}
Switch  Kodi     "Kodi [MAP(online.map):%s]"     <tv>    (System) {channel="network:pingdevice:Kodi:online"}

./sitemaps/my.sitemap:

Frame label="Online - Live" {
         Text item=Allen
         Text item=Aletchia
         Text item=Kodi

./transformations/online.map:

ON=Online
OFF=Offline
-=-
NULL=-

No rule at all.
Please do NOT set a label in the sitemap at all (or use the same as in items, as this is the key feature)

3 Likes