Sensor what am i missing

Trying to read AM/PM form NOW()

so after some reading

  - platform: template
    sensors:
      am_pm:
        value_template: >
          {{ now().strftime('%p') }}

:slight_smile:

but in the PM

why does sensor.am_pm not say PM

what did I miss

Your template wont ever update. ( Templates without entities using now() )

You will need to define a time sensor and add that as an entity to your sensor. This will update every minute:

  - platform: template
    sensors:
      am_pm:
        entity_id: sensor.time # required to update now()
        value_template: >
          {{ now().strftime('%p') }}

time sensor:

1 Like

Thanks
must of miss that bit in the readings