Great Tip from @gabrielemariotti to clean up Template Sensors across the board. #529

This commit is contained in:
ccostan 2019-03-31 17:13:37 -04:00
parent 13a33ecc57
commit 55f75950b0
9 changed files with 34 additions and 14 deletions

View File

@ -17,6 +17,7 @@ sensor:
sensors:
low_battery:
friendly_name: 'Low Battery'
entity_id: []
value_template: >
{%- set threshold = 15 -%}
{%- set domains = ['light', 'switch', 'sensor', 'zwave', 'lock', 'binary_sensor'] -%}

View File

@ -25,15 +25,19 @@ sensor:
sensors:
small_garage_status:
friendly_name: 'State of the door'
entity_id: []
value_template: '{{ states.cover.small_garage.state }}'
small_garage_time_in_state:
friendly_name: 'Time Since Change'
entity_id: []
value_template: '{{ states.cover.small_garage.attributes["time_in_state"] }}'
small_garage_wifi_signal_strength:
entity_id: []
friendly_name: 'WiFi strength'
value_template: '{{ states.cover.small_garage.attributes["wifi_signal_strength"] }}'
unit_of_measurement: 'dB'
small_garage_reflection_rate:
entity_id: []
friendly_name: 'Reflection Rate'
value_template: '{{ states.cover.small_garage.attributes["sensor_reflection_rate"] }}'
@ -47,15 +51,19 @@ sensor:
sensors:
large_garage_status:
friendly_name: 'State of the door'
entity_id: []
value_template: '{{ states.cover.large_garage.state }}'
large_garage_time_in_state:
friendly_name: 'Time Since Change'
entity_id: []
value_template: '{{ states.cover.large_garage.attributes["time_in_state"] }}'
large_garage_wifi_signal_strength:
entity_id: []
friendly_name: 'WiFi strength'
value_template: '{{ states.cover.large_garage.attributes["wifi_signal_strength"] }}'
unit_of_measurement: 'dB'
large_garage_reflection_rate:
entity_id: []
friendly_name: 'Reflection Rate'
value_template: '{{ states.cover.large_garage.attributes["sensor_reflection_rate"] }}'

View File

@ -20,6 +20,7 @@ sensor:
sensors:
neato_status:
friendly_name: 'Neato Status'
entity_id: []
value_template: '{{states.vacuum.carloneato.attributes["status"]}}'
group:

View File

@ -10,6 +10,7 @@ sensor:
sensors:
network:
friendly_name: 'Network Monitor'
entity_id: []
value_template: >
{%- set domains = ['device_tracker'] -%}
{%- for domain in domains -%}
@ -39,6 +40,7 @@ sensor:
sensors:
network_detail:
friendly_name: 'Network Monitor Detail'
entity_id: []
value_template: >
{%- set domains = ['device_tracker'] -%}
{%- for domain in domains -%}

View File

@ -25,6 +25,7 @@ sensor:
sensors:
carlopihole:
friendly_name: 'Carlo-PiHole'
entity_id: []
value_template: "{{ 'Online' if is_state('device_tracker.carlopihole', 'home') else 'Offline' }}"
# Pi-Hole switch

View File

@ -4,11 +4,11 @@
homeassistant:
customize_glob:
"sensor.floorplan_*":
hidden: True
homebridge_hidden: True
"sensor.clock_*":
hidden: True
homebridge_hidden: True
#---Sensor for Time and Date.-----------------------------
@ -18,20 +18,21 @@ sensor:
sensors:
floorplan_date:
friendly_name: 'Date'
entity_id: []
value_template: >-
{{now().strftime("%A")}}, {{now().strftime("%B")}} {{now().strftime("%d")}}
- platform: template
scan_interval: 60
sensors:
floorplan_time:
friendly_name: 'Time'
entity_id: []
value_template: >-
{{now().strftime("%-I")}}:{{now().strftime("%M")}} {{now().strftime("%p")}}
- platform: template
sensors:
clock_time:
friendly_name: 'Clock Time'
entity_id: []
value_template: >-
{{now().strftime("%-I")}}:{{now().strftime("%M")}}
@ -40,21 +41,16 @@ sensor:
sensors:
clock_am_pm:
friendly_name: 'AM/PM'
entity_id: []
value_template: >-
{{now().strftime("%p")}}
- platform: template
scan_interval: 30000
sensors:
clock_day:
friendly_name: 'Day'
entity_id: []
value_template: >-
{{now().strftime("%A")}}
- platform: template
scan_interval: 30000
sensors:
clock_date:
friendly_name: 'Clock Date'
entity_id: []
value_template: >-
{{now().strftime("%B")}} {{now().strftime("%d")}} {{now().year}}

View File

@ -90,6 +90,7 @@ sensor:
sensors:
sensor_count:
friendly_name: 'Number of Sensors'
entity_id: []
value_template: >
{%- set domains = ['sensor'] -%}
{%- for domain in domains -%}
@ -101,6 +102,7 @@ sensor:
{%- endfor -%}
automation_count:
friendly_name: 'Number of Automations'
entity_id: []
value_template: >
{%- set domains = ['automation'] -%}
{%- for domain in domains -%}
@ -112,6 +114,7 @@ sensor:
{%- endfor -%}
script_count:
friendly_name: 'Number of Scripts'
entity_id: []
value_template: >
{%- set domains = ['script'] -%}
{%- for domain in domains -%}
@ -123,6 +126,7 @@ sensor:
{%- endfor -%}
binary_sensor_count:
friendly_name: 'Number of Binary Sensors'
entity_id: []
value_template: >
{%- set domains = ['binary_sensor'] -%}
{%- for domain in domains -%}
@ -134,6 +138,7 @@ sensor:
{%- endfor -%}
tracker_count:
friendly_name: 'Number of Devices'
entity_id: []
value_template: >
{%- set domains = ['device_tracker'] -%}
{%- for domain in domains -%}
@ -145,6 +150,7 @@ sensor:
{%- endfor -%}
lights_count:
friendly_name: 'Number of Lights'
entity_id: []
value_template: >
{%- set domains = ['light'] -%}
{%- for domain in domains -%}
@ -156,6 +162,7 @@ sensor:
{%- endfor -%}
protect_count:
friendly_name: 'Number of Smoke Detectors'
entity_id: []
value_template: >
{% if states('group.protects') == 'on' %}
{% for e in states.group.protects.attributes.entity_id if states(e) == 'on' %}
@ -168,6 +175,7 @@ sensor:
{% endif %}
camera_count:
friendly_name: 'Number of online Cameras'
entity_id: []
value_template: >
{%- set domains = ['camera'] -%}
{%- for domain in domains -%}

View File

@ -17,9 +17,11 @@
- platform: template
sensors:
upstairs_away_mode:
entity_id: []
value_template: "{{ is_state_attr('climate.upstairs', 'away_mode', 'on') }}"
- platform: template
sensors:
downstairs_away_mode:
entity_id: []
value_template: "{{ is_state_attr('climate.downstairs', 'away_mode', 'on') }}"

View File

@ -1,6 +1,7 @@
- platform: template
sensors:
last_boot_templated:
entity_id: []
value_template: >-
{%- set slb = states.sensor.last_boot.state.split(' ') -%}
{%- set count = slb | length -%}
@ -49,7 +50,7 @@
value_template: '{{ value }}'
#############################################################################################################
### This part of the automation is hidden due to the IP address exposed ##
### This part of the automation is hidden due to the External IP address being exposed ##
# - platform: template
# sensors:
# ipchange: