mirror of
				https://github.com/CCOSTAN/Home-AssistantConfig.git
				synced 2025-11-04 04:55:16 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			60 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			YAML
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			YAML
		
	
	
		
			Executable File
		
	
	
	
	
- platform: template
 | 
						|
  sensors:
 | 
						|
    last_boot_templated:
 | 
						|
      entity_id: []
 | 
						|
      value_template: >-
 | 
						|
        {%- set slb = states.sensor.last_boot.state.split(' ') -%}
 | 
						|
        {%- 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
 | 
						|
  resource: https://api.ipify.org/
 | 
						|
  name: External IP
 | 
						|
  value_template: '{{ value }}'
 | 
						|
 | 
						|
#############################################################################################################
 | 
						|
###  This part of the automation is hidden due to the External IP address being exposed  ##
 | 
						|
# - 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 %}"
 | 
						|
#############################################################################################################
 |