Dear all,
I’ve spent some time in reading this post Convert seconds to days, hours, minutes and of course Template Sensor documentation.
Unfortunately I still get error messages when checking my config.
So I assume there is just a typo, wrong " ’ quotes, or indentation, I just can’t find it.
Help is highly appreciated.
Ralf
- platform: fritzbox_netmonitor
host: my.box.ip.addr
name: fritzbox
- platform: template
sensors:
fritzbox_is_linked:
friendly_name: 'Physikalisch verbunden'
value_template: >-
{% if is_state_attr('sensor.fritzbox', 'is_linked', 'True') %}
ja
{% else %}
prüfen
{% endif %}
fritzbox_is_connected:
friendly_name: 'Mit Internet verbunden'
value_template: >-
{% if is_state_attr('sensor.fritzbox', 'is_connected', 'True') %}
ja
{% else %}
prüfen
{% endif %}
fritzbox_wan_access_type:
friendly_name: 'Verbindungsart'
value_template: '{{ states.sensor.fritzbox.attributes["wan_access_type"] }}'
fritzbox_external_ip:
friendly_name: 'Externe IP Adresse'
value_template: '{{ states.sensor.fritzbox.attributes["external_ip"] }}'
fritzbox_uptime:
friendly_name: 'FB-Uptime'
value_template: >-
{% set fbuptime = state_attrib('sensor.fritzbox', 'uptime') | int %}
{% set fbminutes = ((fbuptime % 3600) /60) | int %}
{$ set fbhours = ((fbuptime % 86400) / 3600) | int %}
{% set fbdays = (fbuptime / 86400) | int) %}
{% if fbuptime < 60 %}
unter 1 Minute
{% else %}
{{ fbdays }} d : {{ fbhours }} h : {{ fbminutes }} m
{% endif %}
The sensors fritzbox_is_linked, fritzbox_is_connected, fritzbox_wan_access_type and fritzbox_external_ip are all working fine.
When adding the FB-uptime sensor I get a bunch of error messages:
➜ /workspace hassio ha check
Processing... Done.
Error: Testing configuration at /config
INFO:homeassistant.util.package:Attempting install of fritzconnection==0.8.4
Failed config
sensor.template:
- Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: unexpected ')') for dictionary value @ data['sensors']['fritzbox_uptime']['value_template']. Got "{% set fbuptime = state_attrib('sensor.fritzbox', 'uptime') | int %} {% set fbminutes = ((fbuptime % 3600) /60) | int %} {$ set fbhours = ((fbuptime % 86400) / 3600) | int %} {% set fbdays = (fbuptime / 86400) | int) %} {% if fbuptime < 60 %}\n unter 1 Minute\n{% else %}\n {{ fbdays }} d : {{ fbhours }} h
: {{ fbminutes }} m\n{% endif %}". (See ?, line ?). Please check the docs at https://home-assistant.io/integrations/sensor.template/
- platform: template
sensors: [source /config/configuration.yaml:201]
fritzbox_external_ip: [source /config/configuration.yaml:221]
friendly_name: Externe IP Adresse
value_template: {{ states.sensor.fritzbox.attributes["external_ip"] }}
fritzbox_is_connected: [source /config/configuration.yaml:210]
friendly_name: Mit Internet verbunden
value_template: {% if is_state_attr('sensor.fritzbox', 'is_connected', 'True') %}
ja
{% else %}
prüfen
{% endif %}
fritzbox_is_linked: [source /config/configuration.yaml:202]
friendly_name: Physikalisch verbunden
value_template: {% if is_state_attr('sensor.fritzbox', 'is_linked', 'True') %}
ja
{% else %}
prüfen
{% endif %}
fritzbox_uptime: [source /config/configuration.yaml:224]
friendly_name: FB-Uptime
value_template: {% set fbuptime = state_attrib('sensor.fritzbox', 'uptime') | int %} {% set fbminutes = ((fbuptime % 3600) /60) | int %} {$ set fbhours = ((fbuptime % 86400) / 3600) | int %} {% set fbdays = (fbuptime / 86400) | int) %}
{% if fbuptime < 60 %}
unter 1 Minute
{% else %}
{{ fbdays }} d : {{ fbhours }} h : {{ fbminutes }} m
{% endif %}
fritzbox_wan_access_type: [source /config/configuration.yaml:218]
friendly_name: Verbindungsart
value_template: {{ states.sensor.fritzbox.attributes["wan_access_type"] }}
Successful config (partial)
sensor.template: