[Modbus] Coil reset only after item update to ON (OFF excepted) #4745
Comments
Formatted the Current behaviour for better readability ##Item state = OFF, coil = FALSE
2016-11-05 18:00:30.496 [ItemCommandEvent ] - Item 'Swiatlo_Parter_Salon_Sufit' received command ON
2016-11-05 18:00:30.504 [ItemStateChangedEvent ] - Swiatlo_Parter_Salon_Sufit changed from OFF to ON
##item state updated to ON, coil = TRUE
2016-11-05 18:00:35.598 [ItemCommandEvent ] - Item 'Swiatlo_Parter_Salon_Sufit' received command OFF
2016-11-05 18:00:35.611 [ItemStateChangedEvent ] - Swiatlo_Parter_Salon_Sufit changed from ON to OFF
##item state updated to OFF, coil = TRUE
2016-11-05 18:00:41.958 [ItemCommandEvent ] - Item 'Swiatlo_Parter_Salon_Sufit' received command ON
2016-11-05 18:00:41.985 [ItemStateChangedEvent ] - Swiatlo_Parter_Salon_Sufit changed from OFF to ON
2016-11-05 18:00:42.189 [ItemStateChangedEvent ] - Swiatlo_Parter_Salon_Sufit changed from ON to OFF
##item state updated to ON and OFF immediately, coil = FALSE
I also niticed, updating item to ON is toggling coil status:
smarthome:status Swiatlo_Parter_Salon_Sufit ON
##item status = ON, coil = TRUE smarthome:send Swiatlo_Parter_Salon_Sufit ON smarthome:status Swiatlo_Parter_Salon_Sufit OFF
##item status = OFF, coil = FALSE smarthome:send Swiatlo_Parter_Salon_Sufit ON smarthome:status Swiatlo_Parter_Salon_Sufit ON
##item status = ON, coil = TRUE smarthome:send Swiatlo_Parter_Salon_Sufit ON smarthome:status Swiatlo_Parter_Salon_Sufit OFF
##item status = OFF, coil = FALSE |
So if understood correctly, everything goes well except the last piece:
I believe you are expecting not to have the last log line at To further diagnosse what is happening, could you please provide verbose logs? There is guide for openhab1, but not sure how logging is configured in openhab2. Note the Please note that the binding reads from the configured coil number the current status. By default this happens every 200ms. I think this might be "reseting" the state for you, depending how your modbus slave works. |
Well, item status is ON and coil = TRUE, what is correct. I'm not sure how to set DEBUG logging. `openhab> log:list Logger | LevelROOT | DEBUG but still not getting debug log output. I also get in karaf: start: coil = FALSE Keep in mind, when using single coil for reading and writing everything works good. |
@primary1 regarding log configuration in openhab2, I found this community thread. Perhaps this works for you:
Verify using Could you please clarify what do you mean by "coil = TRUE"? Do you mean the actual/true coil value in the modbus slave? What modbus coil you are referring with "coil"? coil number 0 or coil number 11776? I'm sorry I'm still at lost what do you expect to happen and what happens now. |
Yes, "coil = TRUE" is actual coil value in modbus slave device. |
OK, now it starts to make sense. I think the change from 1.8.3 might be #3864? The change was that binding processes openhab commands as-is with no changes. So, when you ask the modbus binding to command coil ON, openHAB modbus binding writes 1. But note that when you ask OFF, the binding writes 0. This is not what you want? |
OK, so everything is clear now. In 1.8.3 to change coil number 0 value, openHAB just set 11776 to TRUE. Am I right? |
No, it should not do that. openHAB modbus binding does not send commands, it only posts state updates. Commands are sent when e.g. clicking in sitemap, or custom rules call In this case, the binding reads the coil 0 status, and sends item status update (in openhab event bus). No coil value is written over modbus. With 1.9.0, no matter what is status of the coil, the behaviour is the same. The binding does receive commands. Those are always processed the same way, the bit (ON/OFF) is written to (write) coil 11776.
I agree, single coil is always simpler to understand. What prevents you from doing this? I'm afraid I still have hard time understanding what you are trying to achieve. What kind of slave device we are talking about? Does that slave force you to have two coils?
OK. I believe this logic is something you have had to implement to the slave?
Actually openHAB 1.9.0 should not read from 11776 since the read coil is 0., not 11776.
Note the link to the github issue though, it relates to the pull request I also referenced above. I believe that piece of text needs updating for the 1.9.0. I hope this clarified something. Best, |
I meant something different: when item state is currrently ON, and I click in sitemap to OFF,
I use Fatek PLC as slave device. Currently I'm using openHAB 1.8.3 with separate coils for reading and writing. I do that, because it's simpler to control PLC outputs via openHAB and PLC itself. To migrate to openHAB 2 I have to change write coils behavior - large piece of ladder program.
I wrote this referring to single coil to read and write. Nevermind. To summarize: modbus binding in openHAB 2 writes "0" or "1" value depending on what commands received. This happend also in single coil and two coils case . You wrote obout it in issue #3684 .
I don't know now if this is bug or proper behavior? |
Ok good I think I understand now. Obviously this is a regression in 1.9.0. I think you have showed that there is a valid use case for the code. I will think about this and reply here. I'm currently thinking if we could implement the transformation support (#4204). I think it would serve your use case as well, you would just map both ON and OFF commands as value 1 on write, right? |
OK, thank you. Well, transformation support could be very useful -it can simplify the configuration. |
Great to hear, I try to find time for this in the coming weeks |
I now published experimental version implementing transformation support in the community forums I appreciate all the feedback! |
It seems that it works correctly. |
Closed via merged PR. |
Hello.
In OpenHAB 2.0.0.4b there is something wrong with modbus binding 1.9.0.b4.
Problem occurs when using separate coils for reading and writing:
When updating item to ON, coil is setting, but after item update to OFF, nothing is happen.
If coil is set, updating item to ON one more time results in coil reset...
In OH 1.8.3 everything works good.
Expected Behavior
item update results in corresponding coil status.
Item update to ON is setting coil,
Item update to OFF is resetting coil.
Current Behavior
##Item state = OFF, coil = FALSE 2016-11-05 18:00:30.496 [ItemCommandEvent ] - Item 'Swiatlo_Parter_Salon_Sufit' received command ON 2016-11-05 18:00:30.504 [ItemStateChangedEvent ] - Swiatlo_Parter_Salon_Sufit changed from OFF to ON ##item state updated to ON, coil = TRUE 2016-11-05 18:00:35.598 [ItemCommandEvent ] - Item 'Swiatlo_Parter_Salon_Sufit' received command OFF 2016-11-05 18:00:35.611 [ItemStateChangedEvent ] - Swiatlo_Parter_Salon_Sufit changed from ON to OFF ##item state updated to OFF, coil = TRUE 2016-11-05 18:00:41.958 [ItemCommandEvent ] - Item 'Swiatlo_Parter_Salon_Sufit' received command ON 2016-11-05 18:00:41.985 [ItemStateChangedEvent ] - Swiatlo_Parter_Salon_Sufit changed from OFF to ON 2016-11-05 18:00:42.189 [ItemStateChangedEvent ] - Swiatlo_Parter_Salon_Sufit changed from ON to OFF ##item state updated to ON and OFF immediately, coil = FALSE
I also niticed, updating item to ON is toggling coil status:
smarthome:status Swiatlo_Parter_Salon_Sufit ON ##item status = ON, coil = TRUE smarthome:send Swiatlo_Parter_Salon_Sufit ON smarthome:status Swiatlo_Parter_Salon_Sufit OFF ##item status = OFF, coil = FALSE smarthome:send Swiatlo_Parter_Salon_Sufit ON smarthome:status Swiatlo_Parter_Salon_Sufit ON ##item status = ON, coil = TRUE smarthome:send Swiatlo_Parter_Salon_Sufit ON smarthome:status Swiatlo_Parter_Salon_Sufit OFF ##item status = OFF, coil = FALSE
Steps to Reproduce (for bugs)
Coil is toggled only whe updating item to ON.
OH logs.zip
Your Environment
Debian Jessie, Java 8 (openJDK)
The text was updated successfully, but these errors were encountered: