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

Error writing config for core.entity_registry (json error in core.entity_registry) #31212

Closed
andker87 opened this issue Jan 27, 2020 · 21 comments
Assignees

Comments

@andker87
Copy link

andker87 commented Jan 27, 2020

Since 0.104.0 at reboot of home assistant these two errors appear in the registry.
I'm using hassio 0.104.3 on rpi3b+ in docker (raspbian)
I didn't find any evident malfunctions, however I can't understand what the generation of this error can be linked to.

Error writing config for core.entity_registry: Object of type set is not JSON serializable

Failed to serialize to JSON: /config/.storage/core.entity_registry
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 57, in save_json
    json_data = json.dumps(data, sort_keys=True, indent=4, cls=encoder)
  File "/usr/local/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/local/lib/python3.7/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/local/lib/python3.7/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/local/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/local/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/local/lib/python3.7/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/local/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/local/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/local/lib/python3.7/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/local/lib/python3.7/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type set is not JSON serializable

UPDATE: the error appears also in 0.105.0 and 0.105.1

@Boogs77
Copy link

Boogs77 commented Jan 31, 2020

Same errore and same configuration

@fudu
Copy link

fudu commented Feb 2, 2020

Same issue, as below.
I'm using 0.104.3 on VM in QNAP virtualization station.
In same time, Xiaomi Aqara multi_sensors name customization do not remain saved.

2020-02-02 15:15:59 ERROR (SyncWorker_0) [homeassistant.util.json] Failed to serialize to JSON: /config/.storage/core.entity_registry
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/util/json.py", line 57, in save_json
json_data = json.dumps(data, sort_keys=True, indent=4, cls=encoder)
File "/usr/local/lib/python3.7/json/init.py", line 238, in dumps
**kw).encode(obj)
File "/usr/local/lib/python3.7/json/encoder.py", line 201, in encode
chunks = list(chunks)
File "/usr/local/lib/python3.7/json/encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/local/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/local/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/local/lib/python3.7/json/encoder.py", line 325, in _iterencode_list
yield from chunks
File "/usr/local/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/local/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/local/lib/python3.7/json/encoder.py", line 438, in _iterencode
o = _default(o)
File "/usr/local/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type set is not JSON serializable
2020-02-02 15:15:59 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.entity_registry: Object of type set is not JSON serializable

@fudu
Copy link

fudu commented Feb 2, 2020

I noticed core.entity_registry last update was on 01/15/20 (0.104.0 release date)

@andker87
Copy link
Author

andker87 commented Feb 3, 2020

the problem seems to be related to the inability to write to the core.entity_registry file
I think this because I tried to manually delete the file and make it re-create it automatically at reboot. Then I customized some entities (changing the name of the entities from sensor.XXXX to sensor.YYYY) and at reboot the changes were not present.

@fudu
Copy link

fudu commented Feb 3, 2020

I didn't change manually the file.
Entities added (with Deconz) until 01/15/2020 are present, after 01/15/2020 are not present and file cannot be modified by Hassio (issue supposed caused by by 0.104 version ...?)

@andker87
Copy link
Author

andker87 commented Feb 6, 2020

I was able to reproduce the error in another context. in the Entity Registry every time I change the name of an entity, the error appears.

update: now on 0.105.0 and 0.105.1

@KC-inDomus

This comment has been minimized.

@andker87 andker87 changed the title json error in core.entity_registry Error writing config for core.entity_registry (json error in core.entity_registry) Feb 6, 2020
@balloob
Copy link
Member

balloob commented Feb 17, 2020

I've opened #31901 which will help us point out what data is incorrect.

@balloob balloob self-assigned this Feb 17, 2020
@balloob
Copy link
Member

balloob commented Feb 17, 2020

Please update to Home Assistant Core 0.105.5 and check your logs. It should now tell you the paths to the data that is incorrect.

@toalex77
Copy link

toalex77 commented Feb 18, 2020

From my log:

2020-02-18 10:29:04 ERROR (SyncWorker_12) [homeassistant.util.json] Failed to serialize to JSON: /etc/hass/.storage/core.entity_registry. Bad data found at $.data.entities[33].capabilities.hvac_modes, $.data.entities[34].capabilities.hvac_modes
2020-02-18 10:29:04 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.entity_registry: Failed to serialize to JSON: /etc/hass/.storage/core.entity_registry. Bad data found at $.data.entities[33].capabilities.hvac_modes, $.data.entities[34].capabilities.hvac_modes

The "bad data", I think, come from an air conditioner through a SmartThings integration.

@fudu
Copy link

fudu commented Feb 18, 2020

The same from Deconz integration

2020-02-18 12:28:35 ERROR (SyncWorker_3) [homeassistant.util.json] Failed to serialize to JSON: /config/.storage/core.entity_registry. Bad data found at $.data.entities[52].capabilities.hvac_modes, $.data.entities[53].capabilities.hvac_modes, $.data.entities[54].capabilities.hvac_modes, $.data.entities[55].capabilities.hvac_modes 2020-02-18 12:28:35 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.entity_registry: Failed to serialize to JSON: /config/.storage/core.entity_registry. Bad data found at $.data.entities[52].capabilities.hvac_modes, $.data.entities[53].capabilities.hvac_modes, $.data.entities[54].capabilities.hvac_modes, $.data.entities[55].capabilities.hvac_modes

@balloob
Copy link
Member

balloob commented Feb 18, 2020

@andrewsayre could you verify that air conditioners do not return a set for hvac modes?

@Kane610 could you verify that Deconz does not return a set for hvac modes?

@Kane610
Copy link
Member

Kane610 commented Feb 18, 2020

@balloob it is only returning data that is from json structures so shouldn't be possible. (I also double checked the code, no sets as far as I can see)

@balloob
Copy link
Member

balloob commented Feb 18, 2020

I guess my updated error message wasn't very helpful :(

@balloob
Copy link
Member

balloob commented Feb 18, 2020

I found the SmartThings Air Conditioner issue and have a fix here #31959

@balloob
Copy link
Member

balloob commented Feb 18, 2020

@fudu could you look in the file <config>/.storage/core.entity_registry and see what integration is responsible for entities 52, 53, 54 and 55? Or maybe at the top of your head you know which integration provides 4 climate entities?

@andker87
Copy link
Author

Same here

Error writing config for core.entity_registry: Failed to serialize to JSON: /config/.storage/core.entity_registry. Bad data found at $.data.entities[150].capabilities.hvac_modes, $.data.entities[151].capabilities.hvac_modes, $.data.entities[152].capabilities.hvac_modes, $.data.entities[153].capabilities.hvac_modes, $.data.entities[154].capabilities.hvac_modes

I don't know where to find which device the number 150 corresponds to, but the entity number is 5 (150-151-152-153-154) and I have 7 tado thermostats (climate.___) and 5 SmartThings air conditioners, so I think it's their fault...

@fudu
Copy link

fudu commented Feb 18, 2020

There aren't data entities 52,53,54,55 in core.entity_registry, but message:

2020-02-18 12:28:35 ERROR (SyncWorker_3) [homeassistant.util.json] Failed to serialize to JSON: /config/.storage/core.entity_registry. Bad data found at $.data.entities[52].capabilities.hvac_modes, $.data.entities[53].capabilities.hvac_modes, $.data.entities[54].capabilities.hvac_modes, $.data.entities[55].capabilities.hvac_modes 2020-02-18 12:28:35 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.entity_registry: Failed to serialize to JSON: /config/.storage/core.entity_registry. Bad data found at $.data.entities[52].capabilities.hvac_modes, $.data.entities[53].capabilities.hvac_modes, $.data.entities[54].capabilities.hvac_modes, $.data.entities[55].capabilities.hvac_modes

appears when I try to personalize (name change...) ANY entities from ANY integration (Deconz, Smartthings, mobile App).

Changes are reverted after HA restart.
This happens from HA v0.104.0: core.entity_registry is untouched from 01/15 (0.104.0 release date)

@fudu
Copy link

fudu commented Feb 18, 2020

actually, i own 4 samsung air conditioners .... probably entities 52,53,54,55 involved ??

There aren't data entities 52,53,54,55 in core.entity_registry, but message:

2020-02-18 12:28:35 ERROR (SyncWorker_3) [homeassistant.util.json] Failed to serialize to JSON: /config/.storage/core.entity_registry. Bad data found at $.data.entities[52].capabilities.hvac_modes, $.data.entities[53].capabilities.hvac_modes, $.data.entities[54].capabilities.hvac_modes, $.data.entities[55].capabilities.hvac_modes 2020-02-18 12:28:35 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.entity_registry: Failed to serialize to JSON: /config/.storage/core.entity_registry. Bad data found at $.data.entities[52].capabilities.hvac_modes, $.data.entities[53].capabilities.hvac_modes, $.data.entities[54].capabilities.hvac_modes, $.data.entities[55].capabilities.hvac_modes

appears when I try to personalize (name change...) ANY entities from ANY integration (Deconz, Smartthings, mobile App).

Changes are reverted after HA restart.
This happens from HA v0.104.0: core.entity_registry is untouched from 01/15 (0.104.0 release date)

actually, i own 4 samsung air conditioners .... probably entities 52,53,54,55 involved ??

@balloob
Copy link
Member

balloob commented Feb 18, 2020

Alright, fix for the Samsung ACs will be in the next release 👍

@balloob balloob closed this as completed Feb 18, 2020
@andker87
Copy link
Author

Solved with 0.106.0, however I had to remove the SmartThings integration and re-enable it. No way to use previous smart-app.
everything seems to be ok

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

7 participants