jtburgess / indigo-TP-LInk

Indigo Plugin for TP-Link SmartPlugs, powerStrips, dimmer switches, and dimmable bulbs; (coming someday color bulbs)
The Unlicense
2 stars 4 forks source link

Intermittent loss of communication in 0.9.5 #7

Closed jamesholcomb closed 2 years ago

jamesholcomb commented 2 years ago

Every couple of days, the device loses communication to Indigo. To resolve, I have to open Indigo, edit Device and re-check the Enable Indigo Communication checkbox.

Here is a log snapshot that occurs right before losing communication.

2021-07-07 23:09:34.835 DEBUG   Plugin.run: Dining Chandelier: Back in the loop - timer ended
2021-07-07 23:09:34.836 THREADDEBUG Plugin.run: %s: Starting polling loop with interval %s

2021-07-07 23:09:34.871 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"system":{"get_sysinfo":{"sw_ver":"1.5.11 Build 200214 Rel.152651","hw_ver":"1.0","mic_type":"IOT.SMARTPLUGSWITCH","model":"HS220(US)","mac":"68:FF:7B:78:60:1D","dev_name":"Smart Wi-Fi Dimmer","alias":"Dining Room Chandelier","relay_state":0,"brightness":100,"on_time":0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-63,"led_off":0,"longitude_i":-959272,"latitude_i":360272,"hwId":"84DCCF37225C9E55319617F7D5C095BD","fwId":"00000000000000000000000000000000","deviceId":"80066D31000C04C293A02A1507B5430E1B66A551","oemId":"3B13224B2807E0D48A9DD06EBD344CD6","preferred_state":[{"index":0,"brightness":100},{"index":1,"brightness":75},{"index":2,"brightness":50},{"index":3,"brightness":25}],"next_action":{"type":-1},"err_code":0}}})
2021-07-07 23:09:35.011 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"smartlife.iot.dimmer":{"get_dimmer_parameters":{"minThreshold":11,"fadeOnTime":1000,"fadeOffTime":1000,"gentleOnTime":3000,"gentleOffTime":10000,"rampRate":30,"bulb_type":1,"err_code":0}}})
2021-07-07 23:09:35.161 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"smartlife.iot.dimmer":{"get_default_behavior":{"soft_on":{"mode":"last_status"},"hard_on":{"mode":"last_status"},"long_press":{"mode":"instant_on_off"},"double_click":{"mode":"gentle_on_off"},"err_code":0}}})
2021-07-07 23:09:35.162 THREADDEBUG Plugin.run: Dining Chandelier: finished state data collection with {u'system': {u'get_sysinfo': {u'oemId': u'3B13224B2807E0D48A9DD06EBD344CD6', u'mic_type': u'IOT.SMARTPLUGSWITCH', u'dev_name': u'Smart Wi-Fi Dimmer', u'next_action': {u'type': -1}, u'longitude_i': -959272, u'on_time': 0, u'feature': u'TIM', u'fwId': u'00000000000000000000000000000000', u'icon_hash': u'', u'relay_state': 0, u'hw_ver': u'1.0', u'led_off': 0, u'hwId': u'84DCCF37225C9E55319617F7D5C095BD', u'latitude_i': 360272, u'mac': u'68:FF:7B:78:60:1D', u'active_mode': u'none', u'deviceId': u'80066D31000C04C293A02A1507B5430E1B66A551', u'sw_ver': u'1.5.11 Build 200214 Rel.152651', u'updating': 0, u'brightness': 100, u'alias': u'Dining Room Chandelier', u'rssi': -63, u'model': u'HS220(US)', u'preferred_state': [{u'index': 0, u'brightness': 100}, {u'index': 1, u'brightness': 75}, {u'index': 2, u'brightness': 50}, {u'index': 3, u'brightness': 25}], u'err_code': 0}}}
2021-07-07 23:09:35.162 THREADDEBUG Plugin.run: Dining Chandelier: switch state= 0, lastState=0, brightness=100
2021-07-07 23:09:35.162 THREADDEBUG Plugin.run: Dining Chandelier: state= 0, lastState=0 : False
2021-07-07 23:09:35.163 THREADDEBUG Plugin.run: %s is now %s: localOnOff=%s, logOnOff=%s
2021-07-07 23:09:35.163 THREADDEBUG Plugin.run: Polling found %s set to %s
2021-07-07 23:09:35.163 THREADDEBUG Plugin.run: %s, updated state on server to %s (%s, %s)
2021-07-07 23:09:35.163 DEBUG   Plugin.run: Dining Chandelier: finished state update {u'system': {u'get_sysinfo': {u'oemId': u'3B13224B2807E0D48A9DD06EBD344CD6', u'mic_type': u'IOT.SMARTPLUGSWITCH', u'dev_name': u'Smart Wi-Fi Dimmer', u'next_action': {u'type': -1}, u'longitude_i': -959272, u'on_time': 0, u'feature': u'TIM', u'fwId': u'00000000000000000000000000000000', u'icon_hash': u'', u'relay_state': 0, u'hw_ver': u'1.0', u'led_off': 0, u'hwId': u'84DCCF37225C9E55319617F7D5C095BD', u'latitude_i': 360272, u'mac': u'68:FF:7B:78:60:1D', u'active_mode': u'none', u'deviceId': u'80066D31000C04C293A02A1507B5430E1B66A551', u'sw_ver': u'1.5.11 Build 200214 Rel.152651', u'updating': 0, u'brightness': 100, u'alias': u'Dining Room Chandelier', u'rssi': -63, u'model': u'HS220(US)', u'preferred_state': [{u'index': 0, u'brightness': 100}, {u'index': 1, u'brightness': 75}, {u'index': 2, u'brightness': 50}, {u'index': 3, u'brightness': 25}], u'err_code': 0}}}
2021-07-07 23:09:35.163 THREADDEBUG Plugin.run: Dining Chandelier: In the loop - finished data gathering. Will now pause for 5
2021-07-07 23:09:40.241 DEBUG   Plugin.run: Dining Chandelier: Back in the loop - timer ended
2021-07-07 23:09:40.241 THREADDEBUG Plugin.run: %s: Starting polling loop with interval %s

2021-07-07 23:09:40.388 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"system":{"get_sysinfo":{"sw_ver":"1.5.11 Build 200214 Rel.152651","hw_ver":"1.0","mic_type":"IOT.SMARTPLUGSWITCH","model":"HS220(US)","mac":"68:FF:7B:78:60:1D","dev_name":"Smart Wi-Fi Dimmer","alias":"Dining Room Chandelier","relay_state":0,"brightness":100,"on_time":0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-61,"led_off":0,"longitude_i":-959272,"latitude_i":360272,"hwId":"84DCCF37225C9E55319617F7D5C095BD","fwId":"00000000000000000000000000000000","deviceId":"80066D31000C04C293A02A1507B5430E1B66A551","oemId":"3B13224B2807E0D48A9DD06EBD344CD6","preferred_state":[{"index":0,"brightness":100},{"index":1,"brightness":75},{"index":2,"brightness":50},{"index":3,"brightness":25}],"next_action":{"type":-1},"err_code":0}}})
2021-07-07 23:09:40.528 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"smartlife.iot.dimmer":{"get_dimmer_parameters":{"minThreshold":11,"fadeOnTime":1000,"fadeOffTime":1000,"gentleOnTime":3000,"gentleOffTime":10000,"rampRate":30,"bulb_type":1,"err_code":0}}})
2021-07-07 23:09:40.673 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"smartlife.iot.dimmer":{"get_default_behavior":{"soft_on":{"mode":"last_status"},"hard_on":{"mode":"last_status"},"long_press":{"mode":"instant_on_off"},"double_click":{"mode":"gentle_on_off"},"err_code":0}}})
2021-07-07 23:09:40.673 THREADDEBUG Plugin.run: Dining Chandelier: finished state data collection with {u'system': {u'get_sysinfo': {u'oemId': u'3B13224B2807E0D48A9DD06EBD344CD6', u'mic_type': u'IOT.SMARTPLUGSWITCH', u'dev_name': u'Smart Wi-Fi Dimmer', u'next_action': {u'type': -1}, u'longitude_i': -959272, u'on_time': 0, u'feature': u'TIM', u'fwId': u'00000000000000000000000000000000', u'icon_hash': u'', u'relay_state': 0, u'hw_ver': u'1.0', u'led_off': 0, u'hwId': u'84DCCF37225C9E55319617F7D5C095BD', u'latitude_i': 360272, u'mac': u'68:FF:7B:78:60:1D', u'active_mode': u'none', u'deviceId': u'80066D31000C04C293A02A1507B5430E1B66A551', u'sw_ver': u'1.5.11 Build 200214 Rel.152651', u'updating': 0, u'brightness': 100, u'alias': u'Dining Room Chandelier', u'rssi': -61, u'model': u'HS220(US)', u'preferred_state': [{u'index': 0, u'brightness': 100}, {u'index': 1, u'brightness': 75}, {u'index': 2, u'brightness': 50}, {u'index': 3, u'brightness': 25}], u'err_code': 0}}}
2021-07-07 23:09:40.674 THREADDEBUG Plugin.run: Dining Chandelier: switch state= 0, lastState=0, brightness=100
2021-07-07 23:09:40.674 THREADDEBUG Plugin.run: Dining Chandelier: state= 0, lastState=0 : False
2021-07-07 23:09:40.674 THREADDEBUG Plugin.run: %s is now %s: localOnOff=%s, logOnOff=%s
2021-07-07 23:09:40.675 THREADDEBUG Plugin.run: Polling found %s set to %s
2021-07-07 23:09:40.675 THREADDEBUG Plugin.run: %s, updated state on server to %s (%s, %s)
2021-07-07 23:09:40.675 DEBUG   Plugin.run: Dining Chandelier: finished state update {u'system': {u'get_sysinfo': {u'oemId': u'3B13224B2807E0D48A9DD06EBD344CD6', u'mic_type': u'IOT.SMARTPLUGSWITCH', u'dev_name': u'Smart Wi-Fi Dimmer', u'next_action': {u'type': -1}, u'longitude_i': -959272, u'on_time': 0, u'feature': u'TIM', u'fwId': u'00000000000000000000000000000000', u'icon_hash': u'', u'relay_state': 0, u'hw_ver': u'1.0', u'led_off': 0, u'hwId': u'84DCCF37225C9E55319617F7D5C095BD', u'latitude_i': 360272, u'mac': u'68:FF:7B:78:60:1D', u'active_mode': u'none', u'deviceId': u'80066D31000C04C293A02A1507B5430E1B66A551', u'sw_ver': u'1.5.11 Build 200214 Rel.152651', u'updating': 0, u'brightness': 100, u'alias': u'Dining Room Chandelier', u'rssi': -61, u'model': u'HS220(US)', u'preferred_state': [{u'index': 0, u'brightness': 100}, {u'index': 1, u'brightness': 75}, {u'index': 2, u'brightness': 50}, {u'index': 3, u'brightness': 25}], u'err_code': 0}}}
2021-07-07 23:09:40.675 THREADDEBUG Plugin.run: Dining Chandelier: In the loop - finished data gathering. Will now pause for 5
2021-07-07 23:09:45.729 DEBUG   Plugin.run: Dining Chandelier: Back in the loop - timer ended
2021-07-07 23:09:45.729 THREADDEBUG Plugin.run: %s: Starting polling loop with interval %s

2021-07-07 23:09:48.736 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"error": "TP-Link connection timeout"})
2021-07-07 23:09:51.745 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"error": "TP-Link connection timeout"})
2021-07-07 23:09:54.752 THREADDEBUG Plugin.run: Dining Chandelier connection received ({"error": "TP-Link connection timeout"})
2021-07-07 23:09:54.752 ERROR   Plugin.run: Dining Chandelier error getting RelaySwitch data. Is this the right device type?
2021-07-07 23:09:54.752 ERROR   Plugin.run:     error was ''smartlife.iot.dimmer''
2021-07-07 23:09:54.753 ERROR   Plugin.run:     Polling for this device will now shut down.
2021-07-07 23:09:54.757 DEBUG   Plugin.deviceStopComm:  deviceStopComn entered Dining Chandelier, 192.168.0.196
2021-07-07 23:09:54.758 DEBUG   Plugin.deviceStopComm:  deviceStopComn ending Dining Chandelier, 192.168.0.196
2021-07-07 23:09:54.758 INFO    Plugin.stop:    Polling stopped for %s@%s.
jtburgess commented 2 years ago

You found a bug! Everything is working with your device, and then suddenly the device stops responding to polls — It sends 3 requests, and each one times out after 3 seconds. Then it tries to parse the JSON “data” and doesn’t find ‘smartlife.iot.dimmer’ so it gets an exception. That’s a bug, it shouldn’t shut don just because there’s a connection issue.

I separated the timeout errors from the JSON parsing errors. So in the future it will retry 15 times before giving up if you have timeout errors, and it increases the polling interval after 5 errors and again after 10 errors.

I won't be able to test and update GitHub for several days. Stay tuned...

jtburgess commented 2 years ago

This should be fixed in the latest commit - v 0.9.7. Please try it out and let me know if there are issues BEFORE I publish to indigo. Thanks.

jamesholcomb commented 2 years ago
Jul 22, 2021 at 6:17:40 PM
   Stopping plugin TP-Link Devices (pid 71509)
   Stopped plugin TP-Link Devices
   Upgrading plugin TP-Link Devices to newer version 0.9.7 (previous version moved to trash)
   Loading plugin "TP-Link Devices 0.9.7"
   Starting plugin "TP-Link Devices 0.9.7" (pid 94852)
   TP-Link Devices                 Log level set to info
   Started plugin "TP-Link Devices 0.9.7"

Jul 22, 2021 at 6:18:12 PM
   TP-Link Devices                 Polling started for Dining Chandelier@192.168.0.196.
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds
   TP-Link Devices Error           (tpl_relayswitch_poll.py:run:208): Unable to update Dining Chandelier: after 10 attempts. Polling for this device will now shut down. (state value type must be bool, int, real, or string)
   TP-Link Devices                 Polling stopped for Dining Chandelier@192.168.0.196.
jtburgess commented 2 years ago

On it …

-- John

On Jul 22, 2021, at 7:20 PM, James Holcomb @.***> wrote:

 Jul 22, 2021 at 6:17:40 PM Stopping plugin TP-Link Devices (pid 71509) Stopped plugin TP-Link Devices Upgrading plugin TP-Link Devices to newer version 0.9.7 (previous version moved to trash) Loading plugin "TP-Link Devices 0.9.7" Starting plugin "TP-Link Devices 0.9.7" (pid 94852) TP-Link Devices Log level set to info Started plugin "TP-Link Devices 0.9.7"

Jul 22, 2021 at 6:18:12 PM TP-Link Devices Polling started for Dining @. TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:208): Unable to update Dining Chandelier: after 10 attempts. Polling for this device will now shut down. (state value type must be bool, int, real, or string) TP-Link Devices Polling stopped for Dining @. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

jtburgess commented 2 years ago

Ok. I think I found the problem. I just pushed v0.9.7.1. Please give it a try and let me know.

-- John

On Jul 22, 2021, at 7:20 PM, James Holcomb @.***> wrote:

 Jul 22, 2021 at 6:17:40 PM Stopping plugin TP-Link Devices (pid 71509) Stopped plugin TP-Link Devices Upgrading plugin TP-Link Devices to newer version 0.9.7 (previous version moved to trash) Loading plugin "TP-Link Devices 0.9.7" Starting plugin "TP-Link Devices 0.9.7" (pid 94852) TP-Link Devices Log level set to info Started plugin "TP-Link Devices 0.9.7"

Jul 22, 2021 at 6:18:12 PM TP-Link Devices Polling started for Dining @. TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:213): Error attempting to update Dining Chandelier: state value type must be bool, int, real, or string. Will try again in 5 seconds TP-Link Devices Error (tpl_relayswitch_poll.py:run:208): Unable to update Dining Chandelier: after 10 attempts. Polling for this device will now shut down. (state value type must be bool, int, real, or string) TP-Link Devices Polling stopped for Dining @. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

jamesholcomb commented 2 years ago

So far so good...will let it run for a few days then close this issue once confirmed.

jtburgess commented 2 years ago

👍🏻😊

-- John

On Jul 27, 2021, at 3:41 PM, James Holcomb @.***> wrote:

So far so good...will let it run for a few days then close this issue once confirmed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jtburgess/indigo-TP-LInk/issues/7#issuecomment-887783768, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHAHALJTYO7423HPZSNVOD3TZ4DWXANCNFSM5AQFZ7AQ.

jtburgess commented 2 years ago

Is everything still OK? Can I close the issue?

jamesholcomb commented 2 years ago

👍