I have several sensors based on modbus. I have gotten errors several times in graph rendering like below image, and I guess this is because modbus uses a default value (0) instead of unavailable? Is there any way to avoid such issues?
I found that there is such a thing as an availability_template but I don’t think that works with modbus?.. Also I’ve looked at the lazy_error_count and set that to 1 but that does not seem to work either…
below is my config for my very basic modbus sensors!
- name: H60
type: tcp
host: 192.168.x.x
port: xxx
sensors:
- name: m_0
register_type: input
address: 0
I later use a template to create outdoor and indoor temperature values from m_5 and m_6 which has samt config as m_0.
Here is my template sensor:
- platform: template
sensors:
outdoor_temperature:
unique_id: sensor.h60_outdoor_temperature
unit_of_measurement: °C
value_template: "{{states('sensor.m_5') | float / 10 }}"
availability_template: >
{% if is_state("sensor.m_5", "unavailable") %}
false
{% elif is_state("sensor.m_5", "unknown") %}
false
{% else %}
true
{%- endif %}
indoor_temperature:
unique_id: sensor.h60_indoor_temperature
unit_of_measurement: °C
value_template: "{{states('sensor.m_6') | float / 10 }}"
availability_template: >
{% if is_state("sensor.m_5", "unavailable") %}
false
{% elif is_state("sensor.m_5", "unknown") %}
false
{% else %}
true
{%- endif %}