-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why are linkeStates (or readAfterStates) or "read-after-write" necessary? #157
Comments
I agree that it may not be a good idea to read-back all published states But the readAfterWrite may be useful for "device config states" that do not have reporting configured (like occupancy timeout on a motion sensor). Reported states will update themself, so there states may show wrong value only for a short time. No need for readAfter. So what I would like to see is something like Correct me if I'm wrong, but the current readAfter/'get' implementation is just triggering the read but does not handle the response? The device response gets handled by the normal "incoming event" routine (through shepherd->fromZigbee)? |
Hi allofmex, The advantage now is, that combining of brightness and state is handled inside ioBroker an no additional read requests are needed; for non-reporting state changes the readAfterWriteStates can be used. My intention was to reduce the amount of requests to the device, so that only relevant requests should be sent; relevant are of course the write requests to the router; and some states which are not reported back per event on changes. But your right: The correct implementation would be to parse the response from shepherd and write them back to ioBroker. But as you mentioned, that needs some codings to parse the response back; therefore the same converter that fpr set could be used. |
Great. Looks like a clean solution. Thank you very much. |
I would also here some comments from @kirovily, @Apollon77 and @arteck before I create a pull request into the dev branch. But even if readAfterWrite is triggered; the response will not be parsed, but hopefully an event will come with the correct value from the device. I think for parsing the response much more effort must be done. Right now it's all something like fire-and-forgert-and-wait-for-the-event. |
As far as I understand, the readAfterWrite response should not be difficult to handle. Callback of zbControl.publish() should report all we need. Should be enough to publish attrData from callback to state (maybe check attrId == writtenId)... |
Very confusing responses. The problem ist that zigbee-shpeherd-converters have the converters to send (toZigbee) and also the converters for event (fromZigbee). The reading of values directly from devices are not supported by the zigbee-shepherd-connverters, cause the data structure between "read" response and an "event" is completly different. |
Yes, thats correct. Setting in this case is functional command-type and the command is 'on' or 'off'. For reading we use foundation type, here the command is 'read' and it response with the (raw) attribute value. For values set by a foundation call, we use 'write' command (like the pirUtoOdelay). A 'read' will have same format as write. We just read and write a value. No conversion needed. I did not thought about this before. So only foundation writes can be read and published without conversion. But maybe this is enough already. The attributes we want to readAfter may be mostly/all? foundations. |
@modmax Initially, reading attributes was conceived exactly as you described like fire-and-forgert-and-wait-for-the-event. |
@allofmex, @kirovilya So I added a method to parse values from the read response; convert them in the value needed by ioBroker and set this value as acknowleged in ioBroker; always depending if it should be a boolean or a number. For the read requests a slight offset (10ms are enough) between write and read must be implemented; had some issues with an OSRAM plug. But also some special response parsing had to be done; i.e. for brightness, cause there the attrData is 25; and this must be converted via a readResponse call of the state The conclusion now is, that readAfterWrite is just needed,for states which must be read after they have been written, cause the "write" does not trigger an event from the device to the zigbee network. At the moment there is just one state with the new "readAfterWriteStates"; the readAfter-States are dropped, cause that lead to heavy load. OSRAM devices are sometimes a little bit slow I think. A write request is done (i.e. brightness to 50%) is done; you can see it in the lamp but the request is not ACKed by the lamp. With the PR I will create right now the Zigbee adapter should emit less read requests than now and become more stable. |
Synchronize states and read values from response #157
This is more a question than an issue.
Also in opposite to issue #135.
I've asked myself, why the linkedStates or readAfterStates are necessary?
Until now they are only necessary to set or retrieve the correct value for "state" (on or off) if the brightness is changed. But does this make sense?
My assumption is, that the request will be fullfilled by a device, if the write reqeuest returns with an ACK; otherwise we cannot determine if the request was done or not. Also it's not very good, that a state change in iobroker is marked as "acknowledged", even if an error occured during the request.
So my decision was to just synchronize states within ioBroker, instead of triggering read requests.
Also the acknowledgments of state changes are done within "publishFromState"; in case of an error the state in iobroker stays as not acknowledged.
So I introduces the leightweight synchronization (to set state "state" to on or off, of brightness write request was ACKed) in my repository. So many READ requests will become obsolete.
For possible "readAfterWrite" needs, like mentioned in issue #135 I added the "readAfterWriteStates" where a read request is triggered after write request, as introduced by @allofmex.
Perhaps i'm completly wrong with my assumption ... i'm not involved in each internal of zcn and shepherd and so on. So this is more a question or discussion than an issue; but for my system it works better ...
but of course I've not tested each router device which may be possible .. and perhaps some devices does not allow a "moveToColorWithOnOff", where the internal state of the lam is also changed on brighness changes.
Best regards
Markus
The text was updated successfully, but these errors were encountered: