I have the following in my configuration.yaml, used to extract some values from a home battery:
# Sonnen Battery via REST API
- platform: rest
name: JSON sonnen
json_attributes:
- Consumption_W
- GridFeedIn_W
- Production_W
- USOC
- Uac
resource: http://192.168.99.168:8080/api/v1/status
value_template: '{{ value_json.sonnen is defined }}'
- platform: template
sensors:
sonnen_power_consumption:
friendly_name: 'Power Consumption W'
value_template: '{{ states.sensor.json_sonnen.attributes["Consumption_W"] (0) }}'
unit_of_measurement: watt
sonnen_power_supply:
friendly_name: 'Electricity Feed In W'
value_template: '{{ states.sensor.json_sonnen.attributes["GridFeedIn_W"] }}'
unit_of_measurement: watt
sonnen_power_generation:
friendly_name: 'Power Generation W'
value_template: '{{ states.sensor.json_sonnen.attributes["Production_W"] }}'
unit_of_measurement: watt
sonnen_electricity_storage:
friendly_name: 'Remaining Charge %'
value_template: '{{ states.sensor.json_sonnen.attributes["USOC"] }}'
sonnen_alternating_current:
friendly_name: 'UAC'
value_template: '{{ states.sensor.json_sonnen.attributes["Uac"] }}'
unit_of_measurement: volt
Although this is working it does cause a lot of warnings in the logs:
2021-12-28 00:35:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'float' got invalid input 'unknown' when rendering template '-{{ states('sensor.sonnen_power_consumption')|float}}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2022.1
2021-12-28 00:35:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'float' got invalid input 'unknown' when rendering template '-{{ states('sensor.sonnen_power_consumption')|float}}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2022.1
2021-12-28 00:35:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'float' got invalid input 'unknown' when rendering template '-{{ states('sensor.sonnen_power_consumption')|float}}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2022.1
2021-12-28 00:35:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'float' got invalid input 'unknown' when rendering template '-{{ states('sensor.sonnen_power_consumption')|float}}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2022.1
So apparently I need to change this value template in some way to stop the warnings. However I donât know what to change? Has anybody got any advice on this?
Thanks in advance.