Hi There,
I’m trying to add a sensor where the output is an invalid json, so I have to manipulate it before use.
I was able to manipulate the data using the Template on Developer Tools, but doesn’t matter how many characters I’m filtering using regex_replace
, however when I try to configure the sensor, I’m receiving the below message from the logs:
2022-07-14 13:03:18 ERROR (MainThread) [homeassistant.util.logging] Exception in message_received when handling msg on 'lollipop/cameraStatus/return': '42["messageReply",{"method":"cameraStatus","id":50,"params":{"appSessionId":"xxxxxxxxxxxx","info":"owner"},"result":{"status":1,"bindSensor":"xx:xx:xx:xx:xx:xx","bindSensorName":"Lollipop-Sensorwwwwr","bindStatus":2,"temp":24.77,"humidity":52.420000000000002,"noise":68.629999999999995,"air":44.0,"wifiSsid":"xxxxxxxx","wifiQuality":73.0,"playingMusic":true,"firmwareVersion":"2021121500-g4c517b2","standby_mode":false,"privacyMode":false}}]'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 47, in wrapper
msg_callback(msg)
File "/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py", line 302, in message_received
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 646, in _async_write_ha_state
self.hass.states.async_set(
File "/usr/src/homeassistant/homeassistant/core.py", line 1438, in async_set
state = State(
File "/usr/src/homeassistant/homeassistant/core.py", line 1099, in __init__
raise InvalidStateError(
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.lollipop_temperature. State max length is 255 characters.
I could understand from the topic Track only json_attributes, truncate value if len > 255 by deftdawg · Pull Request #21556 · home-assistant/core · GitHub the data is discarded, is there any way to avoid it so I can parse my string to json correctly?
kr,
Felipe.