Is there a way to detect “entity not available” errors?

Sometimes when I get zwave errors, the only solution is to reboot. Is there a way to detect these errors in an automation so I can have the machine reboot?

########################################
zwave_health_check:
  alias: Zwave Health Check

  sequence:
    - condition: template
      value_template: "{{ states.zwave | selectattr('attributes.is_failed', 'defined') | selectattr('attributes.is_failed','==', True ) | list | length >= 1 }}"

    - service: script.notify_all_engines
      data_template:
        title: "ZWAVE Problem"
        who: "john"
        message: >-
          {%- set Zwave_errors = states.zwave | selectattr('attributes.is_failed', 'defined') | selectattr('attributes.is_failed','==', True ) | map(attribute='name') | list | join(', ') -%}
          Zwave Errors in the following devices: {{ Zwave_errors }}
1 Like