cjkrolak / ThermostatSupervisor

supervisor to detect and correct thermostat deviations
MIT License
0 stars 0 forks source link

JSON decode error after latest pyhtcc update #621

Closed cjkrolak closed 1 year ago

cjkrolak commented 1 year ago

still getting json decode errors, may need to re-implement additional logging to understand raw return data that cannot be parsed.


[log_msg]: supervisor runtime parameters:
[log_msg]: thermostat_type=honeywell
[log_msg]: zone=0
[log_msg]: poll_time=600
[log_msg]: connection_time=14400
[log_msg]: tolerance=2
[log_msg]: target_mode=UNKNOWN_MODE
[log_msg]: measurements=10000
polling time set to 10.0 minutes
server re-connect time set to 240.0 minutes
tolerance to set point is set to 2.0°F
2023-04-24 07:32:19: (tstat:honeywell, zone:0, session:7, poll:1) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=42% RH, set point=66.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 07:42:28: (tstat:honeywell, zone:0, session:7, poll:2) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=43% RH, set point=66.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 07:52:37: (tstat:honeywell, zone:0, session:7, poll:3) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=43% RH, set point=66.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 08:02:47: (tstat:honeywell, zone:0, session:7, poll:4) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=44% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 08:12:57: (tstat:honeywell, zone:0, session:7, poll:5) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=44% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
[log_msg]: Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib/python3.9/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.9/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
OSError: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/home/pi/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/lib/python3.9/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.9/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(113, 'No route to host'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/github/ThermostatSupervisor/thermostatsupervisor/honeywell.py", line 660, in refresh_zone_info
    all_zones_info = self.pyhtcc.get_zones_info()
  File "/home/pi/.local/lib/python3.9/site-packages/pyhtcc/pyhtcc.py", line 685, in get_zones_info
    data = self._post_zone_list_data(page_num)
  File "/home/pi/.local/lib/python3.9/site-packages/pyhtcc/pyhtcc.py", line 619, in _post_zone_list_data
    return self._request_json(
  File "/home/pi/.local/lib/python3.9/site-packages/pyhtcc/pyhtcc.py", line 645, in _request_json
    result = self.session.request(
  File "/home/pi/.local/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/requests/adapters.py", line 547, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError(113, 'No route to host'))

[log_msg]: 2023-04-24 08:23:00: exception during refresh_zone_info, on trial 1 of 11, probably a connection issue waiting {retry_delay_sec} seconds and then retrying...
[log_msg]: message text=Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: honeywell zone 0: intermittent connection error during refresh zone
From: cjkrolak2@gmail.com
To: cjkrolak2@gmail.com

refresh_zone_info: trial 2 of 11 at 2023-04-24 08:39:26

email sent from module '<module 'thermostatsupervisor.email_notification' from '/home/pi/github/ThermostatSupervisor/thermostatsupervisor/email_notification.py'>' running on raspberrypi4 (127.0.1.1)
[log_msg]: smtp connection successful
[log_msg]: email account authorization for account cjkrolak2@gmail.com successful
[log_msg]: mail send was successful
[log_msg]: Email sent!
2023-04-24 08:39:33: (tstat:honeywell, zone:0, session:7, poll:6) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=44% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 08:49:43: (tstat:honeywell, zone:0, session:7, poll:7) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=44% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 08:59:52: (tstat:honeywell, zone:0, session:7, poll:8) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=43% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 09:10:04: (tstat:honeywell, zone:0, session:7, poll:9) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=43% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 09:20:13: (tstat:honeywell, zone:0, session:7, poll:10) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=43% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 09:30:23: (tstat:honeywell, zone:0, session:7, poll:11) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=42% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
2023-04-24 09:40:32: (tstat:honeywell, zone:0, session:7, poll:12) HEAT_MODE [following schedule] act temp=68.0°F, act humidity=42% RH, set point=68.0°F, tolerance=2.0°F, override=68.0°F
revert_thermostat_mode: target_mode='UNKNOWN_MODE', doing nothing.
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/home/pi/.local/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/home/pi/.local/lib/python3.9/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)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/pi/github/ThermostatSupervisor/thermostatsupervisor/supervise.py", line 133, in <module>
    exec_supervise(debug=True, argv_list=argv_inputs)
  File "/home/pi/github/ThermostatSupervisor/thermostatsupervisor/supervise.py", line 113, in exec_supervise
    supervisor(api.uip.get_user_inputs(api.uip.parent_keys[0],
  File "/home/pi/github/ThermostatSupervisor/thermostatsupervisor/supervise.py", line 76, in supervisor
    measurement = Zone.supervisor_loop(Thermostat, session_count,
  File "/home/pi/github/ThermostatSupervisor/thermostatsupervisor/thermostat_common.py", line 1041, in supervisor_loop
    self.refresh_zone_info()
  File "/home/pi/github/ThermostatSupervisor/thermostatsupervisor/honeywell.py", line 660, in refresh_zone_info
    all_zones_info = self.pyhtcc.get_zones_info()
  File "/home/pi/.local/lib/python3.9/site-packages/pyhtcc/pyhtcc.py", line 707, in get_zones_info
    more_data = self._get_check_data_session(device_id)
  File "/home/pi/.local/lib/python3.9/site-packages/pyhtcc/pyhtcc.py", line 632, in _get_check_data_session
    return self._request_json(
  File "/home/pi/.local/lib/python3.9/site-packages/pyhtcc/pyhtcc.py", line 656, in _request_json
    result_json = result.json()
  File "/home/pi/.local/lib/python3.9/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
pi@raspberrypi4:~/github/ThermostatSupervisor $ 
cjkrolak commented 1 year ago

this issue is due to the wrong JSONDecodeError exception being caught within pyhtcc, I opened a ticket for fix in that module: https://github.com/csm10495/pyhtcc/issues/12

cjkrolak commented 1 year ago

fixed on 0.1.52

https://github.com/csm10495/pyhtcc/releases/tag/0.1.52