Hi!
I’m writing an integration in which I’m trying to parse a state change from a motion detector.
The state comes in from zigbee in beautiful JSON like this:
{"illuminance":4,"linkquality":42,"occupancy":true,"battery":100,"voltage":3005}
Which I could parse easily like this:
state = json.loads(json_state)
LOG.info(state["occupancy"])
Unfortunately something happens on the way and when the state reaches my EVENT_STATE_CHANGED event handler it looks like this:
<state sensor.0x00158d0002fd567c_battery=100; illuminance=4, linkquality=42, occupancy=True, battery=100, voltage=3005, unit_of_measurement=%, friendly_name=0x00158d0002fd567c_battery, device_class=battery @ 2019-09-24T23:43:28.253193-04:00>
It seems to resemble HTML to some degree?
How can I parse it so I can access the values in the state elegantly?
I couldn’t find anything in the documentation (which is partly broken by the way, ERR_TOO_MANY_REDIRECTS):
Thank you for your support!