homeassistant-apsystems icon indicating copy to clipboard operation
homeassistant-apsystems copied to clipboard

Component Not Starting - Errorcode 500 on Data Pull

Open jimmyray78 opened this issue 4 years ago • 2 comments

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)

jimmyray78 avatar Jun 06 '21 17:06 jimmyray78

@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 avatar Jun 07 '21 02:06 bgbraga

@jimmyray78 the version 1.0.3 solves your problem?

bgbraga avatar Jun 13 '21 21:06 bgbraga