Still issueā¦
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:71
Integration: template (documentation, issues)
First occurred: 3:39:15 PM (20 occurrences)
Last logged: 3:47:46 PM
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% set level = 100 * states('sensor.prncyanlvl') | float %} {% set states = states('sensor.prncyancap') | float %} {{ level / states | round(1) }}")' for attribute '_state' in entity 'sensor.cyan_toner_level'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% set level = 100 * states('sensor.prnmagentalvl') | float %} {% set states = states('sensor.prnmagentacap') | float %} {{ level / states | round(1) }}")' for attribute '_state' in entity 'sensor.magenta_toner_level'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% set level = 100 * states('sensor.prnyellowlvl') | float %} {% set states = states('sensor.prnyellowcap') | float %} {{ level / states | round(1) }}")' for attribute '_state' in entity 'sensor.yellow_toner_level'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% set level = 100 * states('sensor.prnblacklvl') | float %} {% set states = states('sensor.prnblackcap') | float %} {{ level / states | round(1) }}")' for attribute '_state' in entity 'sensor.black_toner_level'
this is in now:
- platform: template
sensors:
cyan_toner_level:
friendly_name: 'Cyan Toner Level'
unit_of_measurement: '%'
value_template: >
{% set level = 100 * states('sensor.prncyanlvl') | float %}
{% set states = states('sensor.prncyancap') | float %}
{{ level / states | round(1) }}
availability_template: "{{ states('sensor.prncyancap') not in ['0', 'unavailable', 'unknown', 'none'] }}"
#availability_template: "{{ states('sensor.prncyancap') | float > 0 }}"
#value_template: '{{ (((states.sensor.prncyanlvl.state | float) / (states.sensor.prncyancap.state | float)) * 100) | round(1) }}'
#value_template: "{{ ( states('sensor.prncyanlvl')|float / (states('sensor.prncyancap')|float * 100) )|round(1) }}"
magenta_toner_level:
friendly_name: 'Magenta Toner Level'
unit_of_measurement: '%'
value_template: >
{% set level = 100 * states('sensor.prnmagentalvl') | float %}
{% set states = states('sensor.prnmagentacap') | float %}
{{ level / states | round(1) }}
availability_template: "{{ states('sensor.prnmagentacap') not in ['0', 'unavailable', 'unknown', 'none'] }}"
#availability_template: "{{ states('sensor.prnmagentacap') | float > 0 }}"
#value_template: '{{ (((states.sensor.prnmagentalvl.state | float) / (states.sensor.prnmagentacap.state | float)) * 100) | round(1) }}'
#value_template: "{{ ( states('sensor.prnmagentalvl')|float / (states('sensor.prnmagentacap')|float * 100) )|round(1) }}"
#value_template: "{{ '{:.1%}'.format( states('sensor.prnmagentalvl')|float / (states('sensor.prnmagentacap')|float * 100) ) }}"
yellow_toner_level:
friendly_name: 'Yellow Toner Level'
unit_of_measurement: '%'
value_template: >
{% set level = 100 * states('sensor.prnyellowlvl') | float %}
{% set states = states('sensor.prnyellowcap') | float %}
{{ level / states | round(1) }}
availability_template: "{{ states('sensor.prnyellowcap') not in ['0', 'unavailable', 'unknown', 'none'] }}"
#availability_template: "{{ states('sensor.prnyellowcap') | float > 0 }}"
#value_template: '{{ (((states.sensor.prnyellowlvl.state | float) / (states.sensor.prnyellowcap.state | float)) * 100) | round(1) }}'
black_toner_level:
friendly_name: 'Black Toner Level'
unit_of_measurement: '%'
value_template: >
{% set level = 100 * states('sensor.prnblacklvl') | float %}
{% set states = states('sensor.prnblackcap') | float %}
{{ level / states | round(1) }}
availability_template: "{{ states('sensor.prnblackcap') not in ['0', 'unavailable', 'unknown', 'none'] }}"
#availability_template: "{{ states('sensor.prnblackcap') | float > 0 }}"
#value_template: '{{ (((states.sensor.prnblacklvl.state | float) / (states.sensor.prnblackcap.state | float)) * 100) | round(1) }}'
Sorry I do not know āhow to do the not dividing by 0 in yamlāā¦
EDIT:
and this is the error:
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:71
Integration: template (documentation, issues)
First occurred: 4:19:19 PM (13 occurrences)
Last logged: 4:22:39 PM
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% set level = 100 * states('sensor.prnyellowlvl') | float %} {% set states = states('sensor.prnyellowcap') | float %} {{ '0' if level == '0' or states == '0' else level / states | round(1) }}")' for attribute '_state' in entity 'sensor.yellow_toner_level'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% set level = 100 * states('sensor.prncyanlvl') | float %} {% set states = states('sensor.prncyancap') | float %} {{ '0' if level == '0' or states == '0' else level / states | round(1) }}")' for attribute '_state' in entity 'sensor.cyan_toner_level'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% set level = 100 * states('sensor.prnmagentalvl') | float %} {% set states = states('sensor.prnmagentacap') | float %} {{ '0' if level == '0' or states == '0' else level / states | round(1) }}")' for attribute '_state' in entity 'sensor.magenta_toner_level'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{% set level = 100 * states('sensor.prnblacklvl') | float %} {% set states = states('sensor.prnblackcap') | float %} {{ '0' if level == '0' or states == '0' else level / states | round(1) }}")' for attribute '_state' in entity 'sensor.black_toner_level'
when I use this:
- platform: template
sensors:
cyan_toner_level:
friendly_name: 'Cyan Toner Level'
unit_of_measurement: '%'
value_template: >
{% set level = 100 * states('sensor.prncyanlvl') | float %}
{% set states = states('sensor.prncyancap') | float %}
{{ '0' if level == '0' or states == '0' else level / states | round(1) }}
availability_template: "{{ states('sensor.prncyancap') not in ['0', 'unavailable', 'unknown', 'none'] }}"
#availability_template: "{{ states('sensor.prncyancap') | float > 0 }}"
#value_template: '{{ (((states.sensor.prncyanlvl.state | float) / (states.sensor.prncyancap.state | float)) * 100) | round(1) }}'
#value_template: "{{ ( states('sensor.prncyanlvl')|float / (states('sensor.prncyancap')|float * 100) )|round(1) }}"
magenta_toner_level:
friendly_name: 'Magenta Toner Level'
unit_of_measurement: '%'
value_template: >
{% set level = 100 * states('sensor.prnmagentalvl') | float %}
{% set states = states('sensor.prnmagentacap') | float %}
{{ '0' if level == '0' or states == '0' else level / states | round(1) }}
availability_template: "{{ states('sensor.prnmagentacap') not in ['0', 'unavailable', 'unknown', 'none'] }}"
#availability_template: "{{ states('sensor.prnmagentacap') | float > 0 }}"
#value_template: '{{ (((states.sensor.prnmagentalvl.state | float) / (states.sensor.prnmagentacap.state | float)) * 100) | round(1) }}'
#value_template: "{{ ( states('sensor.prnmagentalvl')|float / (states('sensor.prnmagentacap')|float * 100) )|round(1) }}"
#value_template: "{{ '{:.1%}'.format( states('sensor.prnmagentalvl')|float / (states('sensor.prnmagentacap')|float * 100) ) }}"
yellow_toner_level:
friendly_name: 'Yellow Toner Level'
unit_of_measurement: '%'
value_template: >
{% set level = 100 * states('sensor.prnyellowlvl') | float %}
{% set states = states('sensor.prnyellowcap') | float %}
{{ '0' if level == '0' or states == '0' else level / states | round(1) }}
availability_template: "{{ states('sensor.prnyellowcap') not in ['0', 'unavailable', 'unknown', 'none'] }}"
#availability_template: "{{ states('sensor.prnyellowcap') | float > 0 }}"
#value_template: '{{ (((states.sensor.prnyellowlvl.state | float) / (states.sensor.prnyellowcap.state | float)) * 100) | round(1) }}'
black_toner_level:
friendly_name: 'Black Toner Level'
unit_of_measurement: '%'
value_template: >
{% set level = 100 * states('sensor.prnblacklvl') | float %}
{% set states = states('sensor.prnblackcap') | float %}
{{ '0' if level == '0' or states == '0' else level / states | round(1) }}
availability_template: "{{ states('sensor.prnblackcap') not in ['0', 'unavailable', 'unknown', 'none'] }}"
#availability_template: "{{ states('sensor.prnblackcap') | float > 0 }}"
#value_template: '{{ (((states.sensor.prnblacklvl.state | float) / (states.sensor.prnblackcap.state | float)) * 100) | round(1) }}'