2018-01-02 00:00:45 +00:00
|
|
|
- platform: template
|
|
|
|
sensors:
|
2018-12-23 20:44:46 +00:00
|
|
|
last_boot_templated:
|
2019-03-31 21:13:37 +00:00
|
|
|
entity_id: []
|
2018-01-02 00:00:45 +00:00
|
|
|
value_template: >-
|
2018-12-23 20:44:46 +00:00
|
|
|
{%- set slb = states.sensor.last_boot.state.split(' ') -%}
|
2018-01-02 00:00:45 +00:00
|
|
|
{%- set count = slb | length -%}
|
|
|
|
{%- set hms = slb[count - 1] -%}
|
|
|
|
{%- set hms_trimmed = hms.split('.')[0] -%}
|
|
|
|
{%- set hms_split = hms_trimmed.split(':') -%}
|
|
|
|
{%- set hours = hms_split[0] | int -%}
|
|
|
|
{%- set minutes = hms_split[1] | int -%}
|
|
|
|
{%- set seconds = hms_split[2] | int -%}
|
|
|
|
|
|
|
|
{%- if count == 3 -%}
|
|
|
|
{{ slb[0] ~ ' ' ~ slb[1] ~ ' ' }}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if hours > 0 -%}
|
|
|
|
{%- if hours == 1 -%}
|
|
|
|
1 hour
|
|
|
|
{%- else -%}
|
|
|
|
{{ hours }} hours
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if minutes > 0 -%}
|
|
|
|
{%- if hours > 0 -%}
|
|
|
|
{{ ', ' }}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if minutes == 1 -%}
|
|
|
|
1 minute
|
|
|
|
{%- else -%}
|
|
|
|
{{ minutes }} minutes
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if seconds > 0 -%}
|
|
|
|
{%- if hours > 0 or minutes > 0 -%}
|
|
|
|
{{ ', ' }}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- if seconds == 1 -%}
|
|
|
|
1 second
|
|
|
|
{%- else -%}
|
|
|
|
{{ seconds }} seconds
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endif -%}
|
|
|
|
|
|
|
|
- platform: rest
|
|
|
|
scan_interval: 86400
|
2018-10-15 23:23:53 +00:00
|
|
|
resource: https://api.ipify.org/
|
2018-01-02 00:00:45 +00:00
|
|
|
name: External IP
|
2018-07-07 14:23:46 +00:00
|
|
|
value_template: '{{ value }}'
|
2018-01-02 00:00:45 +00:00
|
|
|
|
|
|
|
#############################################################################################################
|
2019-03-31 21:13:37 +00:00
|
|
|
### This part of the automation is hidden due to the External IP address being exposed ##
|
2018-01-02 00:00:45 +00:00
|
|
|
# - platform: template
|
|
|
|
# sensors:
|
|
|
|
# ipchange:
|
|
|
|
# entity_id: sensor.external_ip
|
|
|
|
# value_template: "{%- if is_state('sensor.external_ip', 'xxx.xxx.xxx.xxx') -%} False {%- elif is_state('sensor.external_ip', 'unknown' ) -%} False {%- else -%} True {%- endif %}"
|
|
|
|
#############################################################################################################
|