Displaying Sunset / Sunrise Times not working on Hassio but did on Linux Version

I have just converted to Hassio, I have most of the old config from a Ubuntu install of Home Assistant, however my Sensor for Sunrise / Sunset times are note working any ideas ?

############################################################
##               Sensor Config for Next Sunrise Time Reformatting                 ##
############################################################

  - platform: template
    sensors: 
      nextsunrise:
        friendly_name: 'Next Sun Rise'
        value_template: "{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%-H:%M') }}"
        icon_template: mdi:weather-sunset-up

############################################################
##               Sensor Config for Next Sunset Time Reformatting                  ##
############################################################

  - platform: template
    sensors: 
      nextsunset:
        friendly_name: 'Next Sun Set'
        value_template: "{{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom('%-H:%M') }}"
        icon_template: mdi:weather-sunset-down
1 Like

Ok, you’re also calling platform template twice, so one (or both if you’re calling more elsewhere) are probably being overwritten. Remove the lines ‘platform template’ and ‘sensors’ from the second one.

Hi yes, just doubled checked its in my configuration.yaml

Bugger, edited my last post instead of replying here, sorry, very tired :joy:

@anon43302295 its cool, thanks for helping

- platform: template
  sensors: 
    nextsunrise:
      friendly_name: "Next Sun Rise"
      value_template: "{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%-H:%M') }}"
      icon_template: mdi:weather-sunset-up

    nextsunset:
      friendly_name: "Next Sun Set"
      value_template: "{{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom('%-H:%M') }}"
      icon_template: mdi:weather-sunset-down

still not working lol … its odd it worked before moving to Hassio

1 Like

Do you have any other template sensors in the same file?

@anon43302295 Yeah just moved them into the same section, and restarted still there same, here is my sensors.yaml, im totally lost…

############################################################
##  Sensor Config for Weather Info - Weather Underground  ##
############################################################

- platform: wunderground
  api_key: removed
  monitored_conditions:
    - temp_high_record_c
    - temp_high_1d_c
    - temp_c
    - temp_low_1d_c
    - temp_low_record_c
    - precip_1d
    - precip_1d_mm
    - wind_kph
    - wind_1d_kph
    - UV
    - alerts
    - precip_today_metric

############################################################
##        Sensor Config for Weather Info - Darksky        ##
############################################################

- platform: darksky
  api_key: Removed
  forecast array:
  monitored_conditions:
    - summary
    - icon
    - nearest_storm_distance  
    - precip_type
    - precip_intensity
    - precip_probability
    - temperature
    - apparent_temperature
    - dew_point
    - wind_speed
    - cloud_cover
    - wind_bearing
    - humidity
    - pressure
    - visibility 
    - ozone
    - minutely_summary
    - hourly_summary
    - daily_summary
    - temperature_max
    - temperature_min
    - apparent_temperature_max
    - apparent_temperature_min
    - precip_intensity_max
    - uv_index
  units: uk2

############################################################
##  Sensor Config for DSL Speed Test every 3 Hours        ##
############################################################

- platform: speedtest
  minute: 30
  hour:
    - 1
    - 3
    - 6
    - 9
    - 12
    - 15
    - 18
    - 21
  monitored_conditions:
    - ping
    - download
    - upload

############################################################
##     Sensor Config for Travel Time To / From Work       ##
############################################################

- platform: google_travel_time
  name: Home to Work Journey Time
  api_key: Removed
  origin: zone.home
  destination: removed
  options:
    units: imperial 
      
- platform: google_travel_time
  name: Work to Home Journey Time
  api_key: Removed
  origin: Removed
  destination: zone.home
  options:
    units: imperial  
      
- platform: google_travel_time
  name: Work to Home Journey Time Live Status
  api_key: removed
  origin: removed
  destination: zone.home
  options:
    units: imperial  
  
############################################################
##     Sensor Config for Home Assistant Version           ##
############################################################

- platform: version

############################################################
##       Sensor Config for Evenironmental Seasons         ##
############################################################

- platform: season
  type: astronomical

############################################################
##    Sensor Config for Next Sunrise Time Reformatting    ##
############################################################

- platform: template
  sensors: 
    nextsunrise:
      friendly_name: "Next Sun Rise"
      value_template: "{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%-H:%M') }}"
      icon_template: mdi:weather-sunset-up

    nextsunset:
      friendly_name: "Next Sun Set"
      value_template: "{{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom('%-H:%M') }}"
      icon_template: mdi:weather-sunset-down

    doorbell:
      value_template: >-
        {% if states.binary_sensor.door_window_sensor_158d0001a49988.state == 'on' %}
          Not Ringing
        {% elif states.binary_sensor.door_window_sensor_158d0001a49988.state == 'off' %}
          Ringing
        {% else %}
          n/a
        {% endif %}
    sidegate:
      value_template: >-
        {% if states.binary_sensor.door_window_sensor_158d00019e0551.state == 'on' %}
          off
        {% elif states.binary_sensor.door_window_sensor_158d00019e0551.state == 'off' %}
          on
        {% else %}
          n/a
        {% endif %} 

############################################################
##         Sensor Config for Home Assistant Uptime        ##
############################################################

- platform: uptime

############################################################
##     Sensor Config for Home Assistant Server Health     ##
############################################################
  
- platform: systemmonitor
  resources:
    - type: 'disk_use_percent'
      arg: '/'
    - type: 'disk_free'
      arg: '/'
    - type: memory_free
    - type: load_1m
    - type: load_5m
    - type: load_15m
    - type: processor_use
    - type: last_boot
    - type: since_last_boot
    - type: memory_use_percent

############################################################
##   Sensor Config for Home Assistant Server CPU Speed    ##
############################################################      

- platform: cpuspeed

############################################################
##           Sensor Config for ZoneMinder Events          ##
############################################################  
  
- platform: zoneminder

Any errors in relation to the templates on startup? (Click the ‘i’ on the dev panel and look in the list.)

Hi Mate, no just complains about port 80 for Google Home listening Port.

Do the other sensors in the file work?

Yeah i have all the weather stuff and my state conversions for 2 door sensors I have modded are working fine … just the Sunset and Sunset … hence my confusion lol

What happens when you put the template in the jinja panel? (little black icon that looks like a piece of paper with <> on)

{{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom('%-H:%M') }}
1 Like

Nothing returns…

Weird as it worked on the non Hassio Version of HA

its something hassio does not like about timestamp_custom(’%-H:%M’) part of the code.

When I remove it it returns a long date/time value i think it is

Can’t help you there, I don’t understand that part myself, but at least we’ve narrowed down the cause and hopefully someone else will be able to get that bit fixed up for you :+1:

Thanks for all your help :slight_smile: appreciate it

1 Like

Just fixed it lol, never used the Ninja Page before.

Hassio does not like the - in the code timestamp_custom(’%-H:%M’).

Removed that and now it works, sorry and thanks for you help again…

2 Likes

That would be soooooooooooooo much cooler :sunglasses::sunglasses:

Glad you got sorted :+1:

Cant Type today ether :slight_smile: :slight_smile:

1 Like