Before updating to zwave js I was able to the number of hardware devices by the following. After updating my zwave networke zwave js I get 0. Can someone point me to how to change this to count zwave js hardware devices. Thanks
count_zwave_devices:
friendly_name: 'ZWave'
icon_template: mdi:z-wave
value_template: >
{%- set domains = ['zwave'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
As far as I know there is no way to do that directly.
But I think you could do that in a bit more round about way:
First you’ll need to make sure that the “node Status” sensor is enabled for all of your entities. It’s a good bit of info to have even outside of this.
then you can use the following to get the count of devices since each device has a node status sensor:
{% for state in states if (state.entity_id.find("node_status") | int>=0) %}
{% if loop.first %}
{{loop.length}}
{% endif %}
{% endfor %}
Now that you’ve got that working there is another form of a template that I’m going to use (credit goes to Rob Colman and Taras as a by-product in another thread):
You can also create a sensor to give you the number of alive nodes out of the total number of nodes:
{% set total = states|selectattr('object_id', 'search', 'node_status')|list|count %}
{% set dead = states|selectattr('object_id', 'search', 'node_status')|selectattr('state', 'in', 'dead, unavailable, unknown') | list | count %}
{{ total - dead }} Alive/{{ total }} Total
it will return a value of something like “27 Alive/29 Total” if you have 2 dead nodes.