Create a 'Rocker' button to increase/decrease value over MQTT

Hi all,

can anyone point me to an example of how to create a sitemap item with an ‘up/down’ button that triggers one of two MQTT commands (one for up, another for down). It does not need to store a value. It just needs to trigger one or the other command,

I thought setpoint would work, but it always increments/decrements a value, according to events.log.

Thanks!

Unfortunately the only way to do it in Basic or Classic UIs is to use the setpoint on a proxy Number Item and a rule that triggers on updates to that item aand sends the Up and Down as desired.

It won’t look like a toggle but you can also put your MQTT item on the sitemap as a Switch with a MAPPINGS with an Up and Down which will give you two buttons.

I use a complex setup to allow Electricity Meter reading to set -sitemap:

Switch item=MeterM_adjust label=“meter adjust” mappings=[0=“Set Zero”,1=“0.1”,10=“1”,100=“10”,1000=“100”,10000=“1000”,100000=“10,000” ,99999=“Read Mains”, 99998=“Read HW”]
Text item=Meter_adjust_total //to meter
Switch item=Meter_plus icon=“pb” mappings=[OFF=“increase”,ON=“increase”]
Switch item=Meter_minus icon=“pb” mappings=[OFF=“decrease”,ON=“decrease”]

then rules

rule “Set value to send add(+)”

when

Item Meter_plus changed

then

var Number M = Meter_adjust_total.state as DecimalType
var Number MA = MeterM_adjust.state as DecimalType	
var Number NM = M + MA/10.0
var Number MM = MeterM.state as DecimalType
var Number HH = MeterHW.state as DecimalType

if(MA==0){NM=0}
if (MA==99999){NM=MM}
if (MA==99998){NM=HH}

Meter_adjust_total.sendCommand(NM)

end

rule “Set value to send sub (-)”

when

Item Meter_minus changed

then

var Number M = Meter_adjust_total.state as DecimalType
var Number MA = MeterM_adjust.state as DecimalType	
var Number NM = M - MA/10.0
var Number MM = MeterM.state as DecimalType


if(MA==0){NM=0}
if (MA==99999){NM=MM}

Meter_adjust_total.sendCommand(NM)


end