bgbraga / homeassistant-apsystems

An APsystems Sensor for Home Assistant
Apache License 2.0
21 stars 13 forks source link

Component Not Starting - Errorcode 500 on Data Pull #2

Open jimmyray78 opened 3 years ago

jimmyray78 commented 3 years ago

Hi there,

During the init of HomeAssistant there seems to be an error thrown (HTTP 500).

2021-06-06 10:02:40 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.apsystems
2021-06-06 10:02:41 DEBUG (MainThread) [custom_components.apsystems.sensor] Sensor is running. Start/Stop time: 2021-06-06 05:14:31.516857-07:00, 2021-06-06 21:23:23.045027-07:00
2021-06-06 10:02:41 DEBUG (MainThread) [custom_components.apsystems.sensor] Sensor is running. Start/Stop time: 2021-06-06 05:14:31.516857-07:00, 2021-06-06 21:23:23.045027-07:00
2021-06-06 10:02:41 DEBUG (MainThread) [custom_components.apsystems.sensor] Sensor is running. Start/Stop time: 2021-06-06 05:14:31.516857-07:00, 2021-06-06 21:23:23.045027-07:00
2021-06-06 10:02:41 DEBUG (MainThread) [custom_components.apsystems.sensor] Sensor is running. Start/Stop time: 2021-06-06 05:14:31.516857-07:00, 2021-06-06 21:23:23.045027-07:00
2021-06-06 10:02:41 DEBUG (MainThread) [custom_components.apsystems.sensor] Sensor is running. Start/Stop time: 2021-06-06 05:14:31.516857-07:00, 2021-06-06 21:23:23.045027-07:00
2021-06-06 10:02:42 DEBUG (MainThread) [custom_components.apsystems.sensor] status code login: 200
2021-06-06 10:02:42 DEBUG (MainThread) [custom_components.apsystems.sensor] post_data:
2021-06-06 10:02:42 DEBUG (MainThread) [custom_components.apsystems.sensor] {'queryDate': '20210606', 'selectedValue': 'XXXX', 'systemId': 'XXXXX'}
2021-06-06 10:02:42 DEBUG (MainThread) [custom_components.apsystems.sensor] starting: 2021-06-06 10:02:42
2021-06-06 10:02:42 DEBUG (MainThread) [custom_components.apsystems.sensor] status code data: 500
2021-06-06 10:02:42 DEBUG (MainThread) [custom_components.apsystems.sensor] <Response [500]>
2021-06-06 10:02:42 ERROR (MainThread) [homeassistant.components.sensor] apsystems: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 432, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 550, in async_device_update
await task
File "/config/custom_components/apsystems/sensor.py", line 143, in async_update
ap_data = await self._fetcher.data()
File "/config/custom_components/apsystems/sensor.py", line 249, in data
await self.run()
File "/config/custom_components/apsystems/sensor.py", line 238, in run
self.cache = result_data.json()
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.8/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
bgbraga commented 3 years ago

@jimmyray78 thanks...

Yeah today I tested the yesterday version and see the APSystems changed the cookie logic from his portal. To have a better component handling it now I'm using a browser logic instead of request API. It will handle cookies in a better way. Available at 1.0.3.

bgbraga commented 3 years ago

@jimmyray78 the version 1.0.3 solves your problem?