Dynamic Icons for 2 different Items

so i have a question and wondering if it is possible thought the sitemap, how or if it can be achieved.

This is my current setup

I would like it to look like this…

This is the tricky part…

I would like to have the icon shown to correspond to the switch status of one switch item ( my computer to say if it is on or off)

Switch Presence_Justin_Computer “Justin’s Computer [MAP(active.map):%s]” (gBedroom, gComputers) {channel=“network:pingdevice:Justin_Computer:online”}

Then use another switch mapping as the actual control to wake/shutdown my PC…

Switch MPCONOFF “My PC” (gComputers, gMasterBedroom) [“Switchable”]

Does anyone know if this is possible or how this would be achieved?

You need to use the tag in the item definition:

itemtype itemname "labeltext [stateformat]" <iconname> (group1, group2, ...) ["tag1", "tag2", ...] {bindingconfig}

For your computer use the iconname “switch”
When “ON” it will use the icon “switch-on.svg” and when “OFF” it will use the icon “switch-off”
For the second item use the iconname “switch2”
Create a switch2.svg icon in you /conf/icons/classic folder
Then create two more icons, switch2-on.svg and switch2-off.svg. Edit the icons to look like you want when on and off.

Did I make sense?

Thanks for the reply, but I actually figured it out using rules a completely new item:

If anyone was wondering, this is how I did it… Sorry if it is bad explination…

I created a new item that will be associated with a number, that number in turn will change the icon depending on which state it was selected/in.


2=Turning Off
3=Turning On


Number 		TurnOnOffPC					"My PC"							<computer>	(gComputers, gMasterBedroom)
Switch 		mpcon 						"MyPC On" 						<computer>								{ wol="" }
Switch 		mpcoff 						"My PC Off" 					<computer>								{ channel="exec:command:micropcofft:run" }
Number 		TurnOnOffPC					"My PC"							<computer>	(gComputers, gMasterBedroom)


rule "MyPC New onoff"

when Item TurnOnOffPC received command
then switch (receivedCommand)
	case 3: { mpcon.sendCommand(ON) 
    case 2: { mpcoff.sendCommand(ON) }

rule "TurnOnOffPC ON"

Item Presence_Justin_Computer changed from OFF to ON
then TurnOnOffPC.postUpdate("1")

rule "TurnOnOffPC OFF"
Item Presence_Justin_Computer changed from ON to OFF
then TurnOnOffPC.postUpdate("0")


Switch	item=TurnOnOffPC label="My PC[]" mappings=[3="Wake Up", 2="Shutdown"]

Then I have four icons.


When I change click “Wake up” on the sitemap it changes the Number and icon to “computer-3” then calls my WOL rule/code.

Once my PC is on and is detected by my network the item Presence_Justin_Computer is updated and the rule automatically changes that number to “1” which in turn changes the icon to “computer-1”

Once I click Shut Down it changes the icon to “computer-2” and calls the Shutdown command

Finally when the network cannot ping my pc after my set time it changes the Switch Presence_Justin_Computer to off which changes the icon to “computer-0”

Hope this helps someone one day, took me some brainstorming and a little logic :see_no_evil:!

Also I added another rule to prevent icons from getting stuck in between changing states if i accidentally clicked wake up /shut down when the device was already ON/OFF.

rule "MyPC Revert icon back on"
        Item TurnOnOffPC received command 3
                if (Presence_Justin_Computer.state == ON){

rule "MyPC Revert icon back off"
        Item TurnOnOffPC received command 2
                if (Presence_Justin_Computer.state == OFF){
1 Like