Switch with item value

Hi,

can I somehow have a button to control a pump (switch on/off) and display the value of a temp sensor?

I can do both as separate items but my dashboard is getting flooded with things.

I found one custom widget but this does not work as I would have expected it.

Thanks
SJ

There is a cheat way with sitemaps, it might provide inspiration for a habpanel method.

Create a dummy String type Item.
Be sure to set autoupdate=“false” to separate command from state.
postUpdate your sensor reading to that - as a string, though.
Put it in your sitemap with mappings

Switch item=myString "sensor [%s]" mappings=[ON="ON", OFF="OFF"]

which will produce on/off buttons.
What they won’t do is light up to show the switch state.
When you poke a button, a string “ON”/“OFF” is sent that you listen for with a rule and sendCommand real ON/OFF to your real switch.

There is a further cheat though

Switch item=myString "sensor [%s]" mappings=[ON="OFF"] visibility=[yourswitch!=ON]
Switch item=myString "sensor [%s]" mappings=[OFF="ON"] visibility=[yourswitch==ON]

which should show just one button labelled with current switch state, when you poke it, it will toggle.

1 Like

Thanks for your reply. Need to check if this can be adapted to HabPanel.