Template Error of a simply renamed sensor

Hi, I renamed a sensor this way

corrected_name_for_humidity_garage:
        friendly_name: "Garage"
        unit_of_measurement: "%"
        device_class: humidity
        value_template: '{{ states("sensor.garage_humidity")|round(0) }}'

and I’m getting this error:

TemplateError(‘ValueError: Template error: round got invalid input ‘unavailable’ when rendering template ‘{{ states(“sensor.garage_humidity”)|round(0) }}’ but no default was specified’) while processing template ‘Template<template=({{ states(“sensor.garage_humidity”)|round(0) }}) renders=14>’ for attribute ‘_attr_native_value’ in entity ‘sensor.corrected_name_for_humidity_garage’

Any hints, I don’t get what’s wrong…

As the error says, you haven’t supplied a default for round().

value_template: '{{ states("sensor.garage_humidity")|round(0, default=0) }}'

You could also avoid this error by adding an availability for your sensor.

Thanks, I did it this way (which is almost quite the same):

value_template: '{{ states("sensor.wohnzimmer_humidity")|round(0, default="not available") }}' 

Actually, it’s sufficiently different to the extent it can cause an error.

Your Template Sensor uses the unit_of_measurement option which expects the sensor’s value to be numeric. However, your template can produce “not available” which is non-numeric and will cause an error to be logged.