claudegel / sinope-130

Neviweb130 custom component for Home Assistant to manage devices connected via a GT130 and wifi devices from Sinopé
GNU General Public License v3.0
73 stars 15 forks source link

Index out of range starting with v.1.1.0 #65

Closed ijustlikeit closed 2 years ago

ijustlikeit commented 2 years ago

Logger: homeassistant.components.climate Source: custom_components/neviweb130/climate.py:708 Integration: Climate (documentation, issues) First occurred: 3:34:28 PM (1 occurrences) Last logged: 3:34:28 PM

neviweb130: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 709, in async_device_update await task File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/neviweb130/climate.py", line 708, in update self._hour_energy_kwh_count = device_hourly_stats[0]["counter"] / 1000 IndexError: list index out of range

chdagenais commented 2 years ago

Is that a new device added with no data? should definitely add check 😅

ijustlikeit commented 2 years ago

Device is TH1310WF Smart Wi-Fi floor heating thermostat.

claudegel commented 2 years ago

this is when the device do not respond to Neviweb. HA do not received any response for self._client.get_device_hourly_stats(self._id) Normally you will see that this device is unavailable in HA. Just push the two buttons on your thermostat to reconnect it to the GT130 and restart HA to sold the issue. I'll check if I can catch this to avoid the error message in the log

claudegel commented 2 years ago

I'll open a new branch for this. Could be that Neviweb do not send stats data too often and if we ask for this at every scan_interval we will get the index out of range error because we receive nothing from Neviweb. Check branch index-bug in few minutes

claudegel commented 2 years ago

Sorry check branch index-error.

ijustlikeit commented 2 years ago

Same result Claude ...still "IndexError: list index out of range". I am not using the GT130 device going thru Neviweb method btw.

chdagenais commented 2 years ago

Do you get hourly/daily consumption data on the Neviweb website ?

claudegel commented 2 years ago

Sorry wifi devices do not use GT130. But Neviweb is sending the same data. Could you open Neviweb and check in the debug console to see what neviweb is sending for your thermostat when you look in the stats for your device. I don't have wifi thermostats so I can't check on my side Look for a line like GET https://neviweb.com/api/device/#######/energy/hourly. I need to know if there is period and counter attributes with values

claudegel commented 2 years ago

It's possible that Neviweb is using different attributes for statitic on wifi devices

sicarriere commented 2 years ago

Just to let you know that I’m using WiFi Thermostat (th1123wf) and everything is ok on my side for the energy statistics.

claudegel commented 2 years ago

look for the word history, period and counter. if history is not in the response sent by Neviweb we won't get any stats. stat

claudegel commented 2 years ago

I've added some debug data to see what you get for get_device_monthly_stats, get_device_daily_stats and get_device_hourly_stats. Please restart HA and check in your log for monthly_stats data etc

ijustlikeit commented 2 years ago

From the debug log if I got this right:

{device$id: 236916, unit: "watts",…} device$id: 236916 history: [{period: 0, periodQuality: 0, counter: 194742, counterDate: "2022-02-02T20:03:47-07:00",…},…] unit: "watts"

ijustlikeit commented 2 years ago

This is the "daily":

{device$id: 236916, unit: "watts",…} device$id: 236916 history: [{period: 3279, periodQuality: 1200, counter: 191463, counterDate: "2022-02-02T00:03:39-07:00",…},…] unit: "watts"

ijustlikeit commented 2 years ago

Request Header:

Request URL: https://neviweb.com/api/device/236916/energy/hourly Request Method: GET Status Code: 200 Remote Address: 52.60.238.3:443 Referrer Policy: strict-origin-when-cross-origin

claudegel commented 2 years ago

Do you have hourly stats ? if you have only daily and monthly this is why you get the error for hourly stats. So Neviweb is sending the same attributes history, period and counter. Restart HA with the last update. I've added logging in init.py

claudegel commented 2 years ago

Sorry yes you have both three, hourly, daily and monthly

ijustlikeit commented 2 years ago

Yes hourly, daily and monthly show in the debug log.

ijustlikeit commented 2 years ago

ok will apply your debug statements and restart.

ijustlikeit commented 2 years ago

2022-02-02 21:11:35 DEBUG (SyncWorker_0) [custom_components.neviweb130] Login response: {'user': {'id': xxxx7, 'role': 'owner', 'email': 'xxxxxx', 'locale': 'en', 'format': {'time': '24', 'temperature': 'c'}, 'communications': {'pushNotification': None}, 'initialized': 1}, 'account': {'id': xxx0, 'interface': 'neviweb', 'type': 'free', 'category': None, 'betaLevel': None}, 'iat': 164xxxx495316, 'session': '7171847xxxxxxx236d1ffd61dcf8a45f1e6c7a0bb931', 'refreshToken': 'cea518xxxxxxxxxxxx4b5c1dc368cb19016fb8b8e854677315b593a738f01722636f3cd7'}

2022-02-02 21:11:35 DEBUG (SyncWorker_0) [custom_components.neviweb130] Successfully logged in

2022-02-02 21:11:36 DEBUG (SyncWorker_0) [custom_components.neviweb130] Number of networks found on Neviweb: 1 2022-02-02 21:11:36 DEBUG (SyncWorker_0) [custom_components.neviweb130] Selecting xxxxxxxx network among: [{'id': 3xx30, 'account$id': 2xxx0, 'location$id': None, 'group$id': None, 'name': 'xxxxxy', 'postalCode': 'T6R1T9', 'address': None, 'mode': 'home', 'icon': 1, 'type': None, 'kwhCost': 0.0885, 'deviceListUpdate': '2021-12-01 17:12:45', 'modified': None, 'created': '2021-05-29 21:33:13'}]

2022-02-02 21:11:36 DEBUG (SyncWorker_0) [custom_components.neviweb130] Received gateway data: [{'id': 19xxx63, 'identifier': '246xxxa4', 'name': 'Flextherm FLP55', 'family': '738', 'signature': {'model': 738, 'modelCfg': 0, 'softBuildCfg': 0, 'softVersion': {'major': 2, 'middle': 4, 'minor': 4}, 'hardRev': 0}, 'location$id': 34xx0, 'parentDevice$id': None, 'group$id': 6xx02, 'orderIdx': 0, 'sku': 'FLP55', 'vendor': 'Flextherm', 'url_en': 'https://www.flextherm.com/en/thermostats/concerto-connect', 'url_fr': 'https://www.flextherm.com/fr/thermostats/concerto-connect'}, {'id': 2xx16, 'identifier': 'a4cf1xxcdd0', 'name': 'TH1310WF', 'family': '738-HK', 'signature': {'model': 738, 'modelCfg': 4, 'softBuildCfg': 0, 'softVersion': {'major': 2, 'middle': 4, 'minor': 7}, 'hardRev': 0}, 'location$id': 3xx0, 'parentDevice$id': None, 'group$id': 83114, 'orderIdx': 0, 'sku': 'TH1310WF', 'vendor': 'Sinopé', 'url_en': None, 'url_fr': None}] 2022-02-02 21:11:36 DEBUG (SyncWorker_0) [custom_components.neviweb130] Received signature data: {'signature': {'model': 738, 'modelCfg': 0, 'softBuildCfg': 0, 'softVersion': {'major': 2, 'middle': 4, 'minor': 4}, 'hardRev': 0, 'protocol': 'sinopcom'}} 2022-02-02 21:11:37 DEBUG (SyncWorker_0) [custom_components.neviweb130] Received signature data: {'signature': {'model': 738, 'modelCfg': 4, 'softBuildCfg': 0, 'softVersion': {'major': 2, 'middle': 4, 'minor': 7}, 'hardRev': 0, 'protocol': 'sinopcom'}} 2022-02-02 21:11:37 DEBUG (SyncWorker_0) [custom_components.neviweb130] Setting scan interval to: 0:07:0

2022-02-02 21:11:38 DEBUG (MainThread) [custom_components.neviweb130.climate] Setting up neviweb130 climate Flextherm FLP55: {'id': 19xxx3, 'identifier': '246f28fxxx2a4', 'name': 'Flextherm FLP55', 'family': '738', 'signature': {'model': 738, 'modelCfg': 0, 'softBuildCfg': 0, 'softVersion': {'major': 2, 'middle': 4, 'minor': 4}, 'hardRev': 0, 'protocol': 'sinopcom'}, 'location$id': 34430, 'parentDevice$id': None, 'group$id': 61902, 'orderIdx': 0, 'sku': 'FLP55', 'vendor': 'Flextherm', 'url_en': 'https://www.flextherm.com/en/thermostats/concerto-connect', 'url_fr': 'https://www.flextherm.com/fr/thermostats/concerto-connect'} 2022-02-02 21:11:38 DEBUG (MainThread) [custom_components.neviweb130.climate] Setting up neviweb130 climate TH1310WF: {'id': 236916, 'identifier': 'a4cf12ffxxxcdd0', 'name': 'TH1310WF', 'family': '738-HK', 'signature': {'model': 738, 'modelCfg': 4, 'softBuildCfg': 0, 'softVersion': {'major': 2, 'middle': 4, 'minor': 7}, 'hardRev': 0, 'protocol': 'sinopcom'}, 'location$id': 34430, 'parentDevice$id': None, 'group$id': 83114, 'orderIdx': 0, 'sku': 'TH1310WF', 'vendor': 'Sinopé', 'url_en': None, 'url_fr': None} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_second_display> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_backlight> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_climate_keypad_lock> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_time_format> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_temperature_format> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_setpoint_max> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_setpoint_min> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_floor_air_limit> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_early_start> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_air_floor_mode> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_hvac_dr_options> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=neviweb130, service=set_hvac_dr_setpoint> 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_second_display"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.662322+00:00", "context": {"id": "83477207ffd20c906ab223c9bc115777", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_backlight"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.662703+00:00", "context": {"id": "e698d702767afxxxcdb392e68df49ee2", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_climate_keypad_lock"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.662990+00:00", "context": {"id": "c8517a0682xxb15bc4e6536a4bc79f", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_time_format"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.664341+00:00", "context": {"id": "69ecaccf07e319e945b008abc8d8549d", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_temperature_format"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.665989+00:00", "context": {"id": "b3ee206b9e52592f83782518b2fe5bbd", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_setpoint_max"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.666485+00:00", "context": {"id": "eef96b5e80007cdfcbbabbcd31f42b09", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_setpoint_min"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.666867+00:00", "context": {"id": "600b795164bec2270ccf4d3934979dc9", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_floor_air_limit"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.667496+00:00", "context": {"id": "a7d4e849bceb594a234b439ddd70e5af", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_early_start"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.667816+00:00", "context": {"id": "3f6bc241dd8fb13fa52a2effa538bbfa", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_air_floor_mode"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.668082+00:00", "context": {"id": "a2b9c0bead17c7ebe1b0a970ef0c3d31", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_hvac_dr_options"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.668343+00:00", "context": {"id": "952a0829305a4d0410099d2a1970c6c4", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:38 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [547965095888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_hvac_dr_setpoint"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:38.668804+00:00", "context": {"id": "1c57c37241ac05cb2b30214e913be39d", "parent_id": null, "user_id": null}}} 2022-02-02 21:11:39 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.neviweb130 2022-02-02 21:11:40 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [5479xxx95888] Sending {"id": 6, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "neviweb130", "service": "set_sensor_alert"}, "origin": "LOCAL", "time_fired": "2022-02-03T04:11:39.901210+00:00", "context": {"id": "724ea3dba391a7ae1xxx2e1de63781637", "parent_id": null, "user_id": null}}}

2022-02-02 21:11:41 DEBUG (SyncWorker_4) [custom_components.neviweb130.climate] Updating neviweb130 climate Flextherm FLP55 (2.605 sec): {'roomSetpoint': 23, 'outputPercentDisplay': {'percent': 0, 'sourceType': 'heating'}, 'roomTemperature': {'value': 23.02, 'error': None}, 'roomSetpointMin': 5, 'roomSetpointMax': 36, 'timeFormat': '24h', 'temperatureFormat': 'celsius', 'gfciStatus': 'ok', 'airFloorMode': 'floor', 'auxHeatConfig': 'off', 'loadWattOutput2': 0, 'floorMaxAirTemperature': {'value': None, 'status': 'off'}, 'floorSensorType': '10k', 'floorLimitHigh': {'value': None, 'status': 'off'}, 'floorLimitLow': {'value': None, 'status': 'off'}, 'loadWattOutput1': 432, 'loadWatt': 432, 'wifiRssi': -49, 'keyboardLock': 'unlock', 'config2ndDisplay': 'exteriorTemperature', 'setpointMode': 'manual', 'occupancyMode': 'home', 'backlightAutoDim': 'alwaysOn', 'roomTemperatureDisplay': {'value': 23, 'status': 'on'}, 'earlyStartCfg': 'off', 'roomSetpointAway': 15, 'alertGfci': False} 2022-02-02 21:11:42 DEBUG (SyncWorker_1) [homeassistant.util.json] JSON file not found: /config/custom_components/neviweb130/translations/en.json 2022-02-02 21:11:42 ERROR (MainThread) [homeassistant.components.climate] neviweb130: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 709, in async_device_update await task File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/neviweb130/climate.py", line 706, in update self._hour_energy_kwh_count = device_hourly_stats[0]["counter"] / 1000 IndexError: list index out of range

ijustlikeit commented 2 years ago

Might not know what I'm talking about but could this problem have something to do with the fact that I have two floor heating thermostats such that:

  1. FLP55 flextherm (this one HAS NO statistics) ...doesn't have or show the history in the Neviweb site.
  2. TH1310WF (this one has statistics) and shows the history in Neviweb site.

Don't know if this means anything to you but thought I'd point it out.

ijustlikeit commented 2 years ago

Ok. removed the FLP55 flextherm restarted HA and the TH1310WF works properly by itself. So definitely has something to do with the FLP55 and its inability to handle history statistics by the looks of it.

ijustlikeit commented 2 years ago

I took the FLP55 flextherm cover off and looked at the specs inside the device...it shows it as TH1320WF. Not sure what a model TH1320WF differs but sounds like not same functionality as TH1310WF.

ijustlikeit commented 2 years ago

So it appears that the FLP55 flextherm TH1320WF needs its own special handling separate (from the TH1310WF) and in particular does not seem to use history or capability to provide history.

claudegel commented 2 years ago

Ok so we need to find out a way to differenciate both thermostats. As the FLP55 do not report model TH1320WF the only difference is in the sku. FLP55 report sku: FLP55 and your other thermostat report sku: TH1310WF I'll test a way to extract the sku of each device and let you know today when I have something to test

claudegel commented 2 years ago

OK I've updated the branch so if the sku is FLP55 no stats will be done. I've also added mode debug. Please test

ijustlikeit commented 2 years ago

It is working perfectly. Tested out all functionality and has been operational for several hours with no errors or logging. I would say it is ready for deployment. Thanks for the excellent response and work on this Claude! Pleasure working with you on this.