gieljnssns / buienalarm-sensor-homeassistant

Buienalarm custom_component for Home-Assistant
MIT License
36 stars 6 forks source link

Next Rain Forecast sensor cannot be show as relative time in UI #31

Open metbril opened 2 years ago

metbril commented 2 years ago

The next rain forecast sensor shows a date/time.

To be able to show this as a relative date in the UI, 2 things need to be done:

  1. Update date format to a valid ISO time (including the 'T' between date and time).
  2. Set the device class for the sensor.

A current workaround is to create a template sensor and show that in the UI:

template:
  sensor:
    - name: "Buienalarm Next Rain Forecast Timestamp"
      unique_id: sensor.buienalarm_next_rain_forecast_timestamp
      device_class: timestamp
      icon: mdi:clock
      availability: "{{ states('sensor.buienalarm_next_rain_forecast') is not none }}"
      state: >
        {% set datetime = states('sensor.buienalarm_next_rain_forecast') %}
        {{ (as_datetime(datetime) | as_local) }}