aex351 / home-assistant-neerslag-card

Display Buienalarm and/or Buienradar data in a graph for Home Assistant.
29 stars 3 forks source link

HA 2021.10.0 - Template warning: 'round' got invalid input 'None' when rendering template #26

Closed Veldkornet closed 2 years ago

Veldkornet commented 2 years ago

Been getting this warning since updating HA. I guess you need to add a default somewhere in the template as mentioned here, but I wasn’t quite sure where with this one.

2021-10-06 22:44:02 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'round' got invalid input 'None' when rendering template '-c "import requests; import json; import random; dataRequest = requests.get('https://gpsgadget.buienradar.nl/data/raintext?lat={{state_attr("zone.home", "latitude") | round(2)}}&lon={{state_attr("zone.home", "longitude") | round(2)}}&c='+str(random.randint(0,999999999999999)) ).text; dataRequest = dataRequest.replace('\r\n',' '); data = '{\"data\":\"'+dataRequest+'\"}';    print(data);"' but no default was specified. Currently 'round' will return 'None', however this template will fail to render in Home Assistant core 2021.12
2021-10-06 22:44:02 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'round' got invalid input 'None' when rendering template '-c "import requests; import json; import random; dataRequest = requests.get('https://gpsgadget.buienradar.nl/data/raintext?lat={{state_attr("zone.home", "latitude") | round(2)}}&lon={{state_attr("zone.home", "longitude") | round(2)}}&c='+str(random.randint(0,999999999999999)) ).text; dataRequest = dataRequest.replace('\r\n',' '); data = '{\"data\":\"'+dataRequest+'\"}';    print(data);"' but no default was specified. Currently 'round' will return 'None', however this template will fail to render in Home Assistant core 2021.12
aex351 commented 2 years ago

Thanks for the report. Home Assistant version 2021.10 has introduced a breaking change for 'templates': https://www.home-assistant.io/blog/2021/10/06/release-202110/#breaking-changes. Filters now require a default value to be present. This will be enforced from Home Assistant version 2021.12.

To add a default value to the filters you will need to update your template in configuration.yaml.

Change

to

I will update the readme file with the updated template logic.

If possible, use this opportunity to migrate from the Neerslag-Card to the Neerslag-App.

Veldkornet commented 2 years ago

Ah thanks! Indeed I just switched to the Neerslag-App instead :)