happyleavesaoc / python-orvibo

MIT License
36 stars 20 forks source link

what about retry code to S20? #9

Closed seoyoungjin closed 1 year ago

seoyoungjin commented 7 years ago

I met frequently S20 exception because my switch is too far. I added retry code to s20.py like this.

$ diff ./python-orvibo/orvibo/s20.py ~/s20.py 
200,204c200,209
<         status = self._udp_transact(cmd, self._subscribe_resp)
<         if status is not None:
<             self.last_subscribed = time.time()
<             return status == ON
<         else:
---
>         retryCount = 0
>         status = None
>         while retryCount < 3 and status == None:
>             status = self._udp_transact(cmd, self._subscribe_resp)
>             if status is not None:
>                 self.last_subscribed = time.time()
>                 return status == ON
>             else:
>                 retryCount += 1
>         if status == None:
scrimpys commented 7 years ago

Have been using the above changes for the last 3-4 weeks. Much more stable with less errors being logged. Any chance of getting this change suggestion put into the master branch. Every time I upgrade Home-Assistant it overwrites my changes.

happyleavesaoc commented 7 years ago

_udp_transact already has retries. So this basically triples the retries. Which is ok, but we should just increment RETRIES instead. I'd merge a PR that did that.

scrimpys commented 7 years ago

OK. I guess we just need to increase the retries somewhere. I think with everything on 2.4GHz wifi and other devices using that frequency combined with thick walls my poor little switches get a little lost sometimes.