unixorn/ha-mqtt-discoverable

JSON cannot serialize an EntryInfo containing a datetime

AixNPanes opened this issue · 0 comments

Is your feature request related to a problem? Please describe.
If _state_helper is called on a class which extends EntityInfo which contains a datetime member, the following error results:
TypeError: Object of type datetime is not JSON serializable

Describe the solution you'd like
changing the json.dumps at approximately line 771 in init.py in the write_config method from
config_message = json.dumps(self.generate_config())
to
config_message = json.dumps(self.generate_config(), default=str)
fixes the problem

Describe alternatives you've considered
Changing the EntityInfo to remove or change the datetime, this is not ideal as conversion is required for comparison

Additional context
Add any other context or screenshots about the feature request here.