[SOLVED] How to receive the status of an item dimmer via MODBUS?

I’m trying to use this item:
Dimmer LED "Lemp" {modbus=">[slave1:0],<[slave2:0]", autoupdate="false"}
but status of dimmer didnt receive?

Could you explain how to receive status, please?
Thank you for your answer.

Looks like you are trying to use Modbus version 1.x binding.

It’s obsolete, there is a version 2.x now, but you can use 1.x still if you want to to. DO NOT mix methods between the two versions, they are quite different set ups.

Make sure you have installed the binding.

You will need to edit modbus.cfg with details of your modbus slave device, pathway, ID, polling frequency, etc.

You will need to specify which register types and addresses to read.

1 Like

Thank you so much for the response.

/etc/openhab2/services/modbus.cfg

poll=1000

modbus:serial.slave1.connection=/dev/ttyUSB0:9600:8:none:1:rtu:200:1000:none:none
modbus:serial.slave1.id=1
modbus:serial.slave1.start=4
modbus:serial.slave1.length=2
modbus:serial.slave1.type=holding

modbus:serial.slave2.connection=/dev/ttyUSB0:9600:8:none:1:rtu:200:1000:none:none
modbus:serial.slave2.id=1
modbus:serial.slave2.start=2
modbus:serial.slave2.length=2
modbus:serial.slave2.type=input 

/etc/openhab2/items/lamp.items

Dimmer LED        ""     {modbus=">[slave1:0],<[slave2:0]", autoupdate="false"}
Number LEDNumber  "[%d]" {modbus="slave2:0"}

/etc/openhab2/sitemaps/lamp.sitemap

sitemap default label=“” {
Frame label=“” {
Slider item=LED icon=“lightbulb”
Text item=LEDNumber
}
}

The text item receives the status of dimmer.
The slider item didn’t receive the status of dimmer but send only.
Is it possible to send and receive the status of dimmer into slider item?

How can you tell? You haven’t given it a format in your Item definition, like the [%d] in the Item that works.

Have a look in events.log for clues about that Item getting updated.

openHAB dimmers.only accept values 0-100, so modbus derived values like 255 might get ignored. You could use a transform to scale if that is what is going on.

1 Like

Thank you for the response.
The dimmer send value between 0 and 100.
Is it posible to change the position of slide bar via received dimmer status?

Yes, the Slider starts off at the existing value in BasicUI.

ClassicUI rendering of Slider widget is a bit pants, it is like a Setpoint with up/down buttons.

1 Like

This rule didn’t change the position of slide bar nor an icon lamp turn on or off but sent to dimmer value.

rule “Dimmer”
when Item LEDNumber changed
then
LED.sendCommand(LEDNumber.state.toString())
if(LEDNumber.state==0){
LED.sendCommand(OFF)
}
logDebug(“dimmer”,LEDNumber.state.toString())
end

How to show the icon lamp “turn off” when dimmer value 0?

The rule is likely to get confusing, because both the Items involved are linked to your modbus device and should be getting updated independently.

The UI takes no notice of any commands that rules send.
The thing that counts here is state updates.
Of course, you’d expect a command to eventually result in a state update, but perhaps you should make sure and check events.log

The logDebug() in your rule is probably useless, it will tell you the “old” state before the command takes effect. Rules do not stop and wait for commands to action.

UIs can sometimes be a bit lazy about refreshing, especially if the sitemap has errors.
Try refreshing your browser.

You need a set of dynamic icons.
It’s described in the docs

There is a dimmer example.

I believe the default iconset includes a set named “light” that should do.
As you have defined your Items in an xxx.items file, you would need to add <light> to the Item definition.

1 Like