Hello all. Can someone give me some guide or example how to make slider that will work as dimmer for Modbus RTU device ? I build small Arduino Modbus slave that has one register (16bit) that drive PWM output.. as for arduino its simple for me but OH2 config …not
I found on internet example for “Process roller shutter commands” and it works for buttons (depending from button i can send proper value 0 , 127, 245 ect ) - so Modbus cfg is OK
question - how should look “items” file? For now i have :
Dimmer LightControl “Dimmer [%d %%]” {modbus=“slave1:<2:>2”}
And items like on “demo” but i dont see change on RS232 modbus device (like OH dont send frame that change this register )
rule “Dimmed Light”
when
Item LightControl received command
then
if ((receivedCommand==INCREASE) || (receivedCommand==DECREASE)) {
var Number percent = 0
if(LightControl.state instanceof DecimalType) percent = LightControl.state as DecimalType
if(receivedCommand==INCREASE) percent = percent + 5
if(receivedCommand==DECREASE) percent = percent - 5
if(percent<0) percent = 0
if(percent>100) percent = 100
postUpdate(LightControl, percent);
}