Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError: Extra data: line 7 column 3 (char 64) #364

Closed
ikoz opened this issue Apr 10, 2023 · 4 comments
Closed

JSONDecodeError: Extra data: line 7 column 3 (char 64) #364

ikoz opened this issue Apr 10, 2023 · 4 comments

Comments

@ikoz
Copy link

ikoz commented Apr 10, 2023

Yesterday I noticed my wiser integration was completely disabled in HA, and this is the error.

Wiser hub is connected and works fine using the app. I'm also using opentherm.

Trying to figure out what extra data it gets in the json that it doesnt expect.

Logger: custom_components.wiser.coordinator
Source: custom_components/wiser/coordinator.py:130
Integration: Drayton Wiser Integration for Home Assistant ([documentation](https://github.com/asantaga/wiserHomeAssistantPlatform/blob/master/README.md), [issues](https://github.com/asantaga/wiserHomeAssistantPlatform/issues))
First occurred: 12:22:43 AM (409 occurrences)
Last logged: 9:26:31 AM

Unexpected error fetching wiser (wiser-WiserHeatXXXXXX) data: Extra data: line 7 column 3 (char 64)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/wiser/coordinator.py", line 151, in async_update_data
    raise ex
  File "/config/custom_components/wiser/coordinator.py", line 130, in async_update_data
    await self.wiserhub.read_hub_data()
  File "/usr/local/lib/python3.10/site-packages/aioWiserHeatAPI/wiserhub.py", line 128, in read_hub_data
    await self._build_objects()
  File "/usr/local/lib/python3.10/site-packages/aioWiserHeatAPI/wiserhub.py", line 158, in _build_objects
    await self._wiser_rest_controller._get_extra_config_data()
  File "/usr/local/lib/python3.10/site-packages/aioWiserHeatAPI/rest_controller.py", line 173, in _get_extra_config_data
    await self._extra_config.async_load_config()
  File "/usr/local/lib/python3.10/site-packages/aioWiserHeatAPI/helpers/extra_config.py", line 20, in async_load_config
    self._config = json.loads(contents)
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 7 column 3 (char 64)
@msp1974
Copy link
Collaborator

msp1974 commented Apr 10, 2023

We create a data file in config/.storage with the name of your hub to manage the passive mode settings. It looks like this maybe corrupted for some reason. If you rename it and restart HA then this will recreate a new file.

I'll keep this open to improve error handling and ensure HA starts if this is the case but logs and error.

EDIT: can you also post your file here so i can see what it is complaining about. Thx

@ikoz
Copy link
Author

ikoz commented Apr 10, 2023

Yep this was indeed it. The .storage/wiser_custom_data_wiserheatXXXXXX file had gotten corrupted for some reason and contained invalid json. I fixed the file and now everything loads properly. Thanks!

I didnt keep the exact contents before fixing it but it was similar to the following:

{
  "Rooms": {
    "4": {
      "manual_temp": 17.0
    }
  }
}{
{
      "manual_temp": 30.0
}
}

I think some race condition somewhere may have resulted in writing to this file without proper parsing. Good to know if it happens next time; better logging (e.g. showing the location and/contents of the file in debug logs) would help. Or ignoring the error and loading anyway if this is corrupted.

Note: I'm using the Better Thermostat integration on that room to be able to control temperature using an external temp/humidity sensor instead of a wiser roomstat. I'm not using passive mode, although I may have enabled it and then disabled a week ago or so.

The BT integration creates a fake thermostat that 'targets' the wiser climate entity and controls its setpoint. My guess is that BT changed setpoints or enabled/disabled the entity too quickly and caused this somehow.

Perhaps there's a feature request here, to be able to control rooms that only have iTRVs in them but no roomstats, using external temp sensors (and thus avoid using BT).

@msp1974
Copy link
Collaborator

msp1974 commented Apr 10, 2023

Hmm that file looks very wrong. There should be a room id for each entry. The second manual temp should be same as first one.

Should also have said that this file is also used to store set manual temps as the hub does not keep this setting if room is turned off and then on again. This will only update if room is in heat mode and not auto (which assume yours is based on how you are controlling temps). I'll do some more testing to see if there is a scenario this can happen. Initial testing shows this works as should and doesn't write without a room id.

@msp1974 msp1974 mentioned this issue Apr 14, 2023
@msp1974
Copy link
Collaborator

msp1974 commented Apr 14, 2023

Have (hopefully) improved the error handling for this should it occur again. It will fail to load the file but not prevent the integration loading. It will however raise errors in the log file. This is in v3.3.3 just released.

@msp1974 msp1974 closed this as completed Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants