You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MQTT publications and subscriptions should be bytes objcts. This is easily fixed using string.encode and bytes.decode:
>>>s="\u2103">>>p=ujson.dumps(s).encode() # encode the entire json string>>>pb'"\xe2\x84\x83"'>>>ujson.loads(p.decode('utf8')) # Decode the bytes object from MQTT before running through JSON'\u2103'
example code:
look with mqtt explorer shows
{"unit_of_measurement": "℃", "name": "Outdoor Temperature", "state_topic": "homeassistant/sensor/tempsensor1/outdoor_temperature/state", "device_class": "temperature", "unique_id": "DHT11_outdoor_front_temperature", "value_template": "{{ value | float }}", "device": {"identifiers": "tempsensor1", "manufacturer": "Raspberry Pi", "name": "TempSensor1", "model": "Pi Pico W", "sw_version": "1.0"
The text was updated successfully, but these errors were encountered: