Hey guys,
Situation: I have a heating system that talks with the cloud portal they provide. There are no API/Rest/… services provided; only an ugly UI. I wrote a python script with mechanicalsoup to access this portal; read some values and return them as json. This result looks like:
{"Heizung": {"Aussentemperatur_Aktuell": "4,2 \u00b0C", "Aussentemperatur_Minimum": "2,5 \u00b0C", "Aussentemperatur_Maximum": "17 \u00b0C", "Warmwassertemperatur_Aktuell": "55,5 \u00b0C", "Vorlauftemperatur_Aktuell_HZK1": "29,7 \u00b0C", "Istleistung_Aktuell_WE0": "0 %", "Kesseltemperatur_Aktuell_WE0": "45,1 \u00b0C", "Anlagendruck_VPT_Aktuell_WE0": "1,9 bar", "Weichentemperatur_Aktuell": "53,2 \u00b0C"}}
My main goal now would be to integrate these values into Home Assistant and for that I created the following configuration entry:
sensor
- platform: command_line
name: heating
value_template: '{{ value_json["Heizung"] }}'
json_attributes:
- Aussentemperatur_Aktuell
- Aussentemperatur_Minimum
- Aussentemperatur_Maximum
- Warmwassertemperatur_Aktuell
- Vorlauftemperatur_Aktuell_HZK1
- Istleistung_Aktuell_WE0
- Kesseltemperatur_Aktuell_WE0
- Anlagendruck_VPT_Aktuell_WE0
- Weichentemperatur_Aktuell
command: 'python3 /home/homeassistant/.homeassistant/scripts/wem_status.py'
scan_interval: 600
The script is executed, returns the json but what I get in Home assistant is:
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 408, in _async_add_entity
await entity.async_update_ha_state()
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 275, in async_update_ha_state
self._async_write_ha_state()
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 394, in _async_write_ha_state
self.entity_id, state, attr, self.force_update, self._context
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 988, in async_set
state = State(entity_id, new_state, attributes, last_changed, None, context)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 733, in __init__
).format(entity_id)
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.heating. State max length is 255 characters.
I hope that someone could point me into the right direction.
Thanks!
Dirk