Files
Home-AssistantConfig/packages/Network_monitor
2017-03-29 20:05:41 +00:00

35 lines
1.4 KiB
Plaintext
Executable File

################################################################
## Packages / Network Devices
################################################################
{% set group = states.group.network_devices -%}
{%- set templateGroup = 'network_devices_template' -%}
{%- set entities = group.attributes.entity_id -%}
group:
{{ group.entity_id.split('.')[1] }}:
name: "{{ group.name }}"
# This is invalid for the group component: hidden: true
entities:
{% for entity_id in entities -%}
- {{ entity_id }}
{% endfor %}
{{ templateGroup }}:
name: "{{ group.name }}"
entities:
{% for entity_id in entities -%}
- {{ ('sensor.' ~ entity_id.split('.')[1] ~ '_template') if entity_id.split('.')[0] == 'device_tracker' else entity_id }}
{% endfor %}
{%- set newline = joiner("\n ") %}
sensor:
- platform: template
sensors:
{% for entity_id in entities if entity_id.split('.')[0] == 'device_tracker' -%}
{{ newline() }}
{%- set entity = states[entity_id.split('.')[0]][entity_id.split('.')[1]] -%}
{{- entity_id.split('.')[1] }}_template:
friendly_name: "{{ entity.name }}"
value_template: "{{ '{{' }} 'online' if is_state('{{ entity_id }}', 'home') else 'offline' {{ '}}' }}"
icon_template: "{{ '{{' }} 'mdi:check-circle' if is_state('{{ entity_id }}', 'home') else 'mdi:alert-circle' {{ '}}' }}"
{% endfor %}