scottyphillips / pychonet

A simple to use library for interfacing with the ECHONETlite protocol
GNU General Public License v3.0
20 stars 17 forks source link

Added SingleFunctionLighting (0x02, 0x91) #56

Closed xen2 closed 1 year ago

xen2 commented 1 year ago

Add support SingleFunctionLighting (as used by Advance Link Plus Wireless adapter WTY2001).

Note: in practice, when changing two lights very quickly (sending two message for change before first message came back), it seems setMessage returns false. https://github.com/scottyphillips/pychonet/blob/master/pychonet/EchonetInstance.py#L66

I could think of several options to fix it:

  1. For/While loop with retry count inside setMessage in pychonet
  2. For/While loop with retry count on echonetlite_homeassistant side
  3. Add a lock inside setMessage (I am not sure about the exact scope for such a lock, is it a limitation per host/system in which case the lock should be per host/system? is it only for this specific hardware device WTY2001 or a general ECHONET lite restriction?)

For now I did the fix 1, and it works fine. I think I saw you did a similar fix for getting property map already?

nao-pon commented 1 year ago

@xen2 If you manipulate two lights quickly, does the state of the device match the content of the response? If it matches, there is a high possibility that it is a limitation of the device specifications.

Incorporating a retry function will cause a drop in response in the event of a true error, so careful consideration is required.

nao-pon commented 1 year ago

After carefully reading the ECHONET Lite specifications, it states that when making consecutive requests to a device, wait for a response before making the next request. It seems that the controller design should conform to that.

nao-pon commented 1 year ago

@xen2 I'm working on a fix for a problem with making back-to-back requests. Could you try the modified code for #58?