Open FredericMa opened 7 years ago
Hi @FredericMa,
What REST API have you used to change value on the item? POST:/items/{itemname} or PUT:/items/{itemname}/state ? The first one should work(in rules is known as sendCommand), the second one (in rules is known as postUpdate) is not actually implemented by the binding. I don't know if this could be considered an issue or is just a @Tim choice. We have to wait his opinion.
For the second point, as I see in the log, channel is updated correctly and so I think it is just a visualization issue. Have you tried to see the behaviour of that item in a sitemap instead of Control panel inside PaperUI?
Hi @andreacioni,
I used the PUT instead of the POST so indeed, that could explain why it wasn't updated correctly in the binding. But from another point of view. After a restart of OpenHAB the values should be restored by persistence and it looks like that also after a restart the values are also not restored correctly.
Also in my sitemap, the values are visualised as 1000, the same as in the PaperUI.
So I'm asking myself if a binding can restore the state that was saved through persistence services. Do you have any experience with another binding that restore the states of its things? What is your opinion @tobof ?
Hi @andreacioni,
First of all, my appologies for the HUGE delay in my reply but I've been very busy the last few months so I couldn't invest any time anymore in my mysensors setup. Last week I've found time to pick things up again.
So what did I do: Instead of using the Custom Sensor I've switched over to the WaterMeter which contains a VAR1 variable to store the pulse counter and this seems to work correctly except for the restore at startup. When attaching the pulse counter that was previously connected to the CustomSensor to the WaterMeter I also needed to change the datatype of the item to Number whereas it was String before when it was linked to the CustomSensor. Probably this caused the issue of only visualising the state in the paper UI but not reporting it back to the gataway on request or updating it in the UI after receiving the pulse count from the gateway.
Like I mentioned above, the restore at startup is not working. I see that the value is restored in the UI but I think it doesn't propagate to a lower level in order for being reported back to the gateway upon request.
This is ONLY when restarting OpenHAB. To fix this I update the pulsecount again via the REST api of OpenHAB. After doing this the gateway receives the correct pulsecount upon request.
The message I see after a restart is the same as mentioned in earlier posts:
Request received, but variable state is not yet define
My guess is that the state is restored before the binding reconnects to the gateway because I also have seen this message in the logs:
2017-06-07 18:33:56.375 [WARN ] [rs.internal.gateway.MySensorsGateway] - Could not set value to node 0 if not reachable
Is this useful information?
Again, sorry for the big silence from my side!
Greetings, Frederic
@tobof : Do you have any idea what could be wrong? Thanks!
Greetings, Frederic
@FredericMa : Sadly, I've not yet found a workaround. It first came up two years ago: https://groups.google.com/forum/#!msg/openhab2/QbmaSwC59l0/NEJDfNRjAgAJ
The pulse count is stored (and restored through persistence) in the item(s). In the binding we're only dealing with the thing(s), we have no access to the items. To be able to answer requests (and for other useful things) we store the status additionally in the binding (runtime only).
I see two possible ways to workaround this:
1) Implement a persistance for the things of the binding itself. Won't be that hard I suppose, but saving the same value two times does not sound beautiful.
2) You create a rule in OH2 that is executed on startup that gets the value of the item and sends it via command (to itself). This will result in a mysensors message that nobody is waiting for, but also will store the current state in the binding and therefore a request could be answered. Maybe we should use handleUpdate() for that.
What do you think?
Hi @tobof
I checked the thread you've put in your comment. My knowledge about how bindings are implemented and how the communication between items and things works is very low. I should spend some time to figure this all out.
Probably I'm missing something but the first question that comes up in my mind is: Why is the state of a channel known by the binding after doing a sendCommand via the REST api and not at startup by the use of restoreOnStartup so it is restored by persistence? Is the restore on startup a total different mechanism? I would think this also just acts like a postUpdate or sendCommand?
Nevertheless, thanks for your suggestions. It is a trade off between the two options. Both have an advantage and disadvantage.
The advantage is that everything is transparent for the end user and they don't see the "ugly thing" behind it. The disadvantage of course is that we need to store the same value twice like you mentioned.
The advantage is that we don't have the double saving of the same value but the disadvantage is that people need to be aware of the fact that they need to implement a rule if they want to make proper use of the restoreOnStartup functionality.
If I need to make a choice then I would go for option one since it is the easiest to use for the end use.
Thanks a lot!
Greetings, Frederic
Hi,
I'm using MySensors to keep track of my power consumption and therefore I'm also using a CustomSensor to store the pulse count of all sensors (Water, Gas and Power). All my sensors are connected to the gateway (issue that has been solved yesterday). I'm using the refactored binding which was released yesterday.
Config of the CustomSensor:![image](https://cloud.githubusercontent.com/assets/7840263/23451127/e0b6fb68-fe5e-11e6-9464-8592dfc210b4.png)
I noticed that in both directions the pulse counters are not updated. So, to be more precise:
When I update the pulse count (via rest API for example), it is not updated in the binding. For example I've set all pulse counters to 1000 and when I plug in the gateway, the gateway requests the last know pulse count at the MySensors binding. Instead of returning the pulse count of 1000, I see the following error message:![image](https://cloud.githubusercontent.com/assets/7840263/23450886/b30ace52-fe5d-11e6-8bc5-da3ee3c4d758.png)
2017-02-28 19:04:39.255 [WARN ] [rs.internal.gateway.MySensorsGateway] - Request received, but variable state is not yet defined
Even though the pulse counters are set to 1000:Same thing for other way around. I disabled the request for the pulse counters in my sketch so that the gateway can still do its job and starts counting from 0. When receiving the new pulse counts from the gateway I see in the binding that it is receiving the pulse count but in reality the pulse counts still remain at 1000 (screenshot above):
All channels are linked corrrectly. I only see this issue with the CustomSensor. The flowmeter and power things are functioning correctly and are updating it's values correctly (only receive from gateway, nothing is sent from these things).
If I gave a vague description, let me know what I need to clarify more!
Thanks!
Greetings, Frederic