xirixiz / homeassistant-afvalwijzer

Provides sensors for some Dutch waste collectors
MIT License
176 stars 69 forks source link

Automation example in README.md can use an update #290

Closed casakampa closed 3 months ago

casakampa commented 3 months ago

The problem

This piece of the automation can be updated:

    action:
      - service: notify.family
        data:
          title: "Afval"
          message: 'Het is vandaag - {{ now().strftime("%d-%m-%Y") }}. Afvaltype(n): {{ states.sensor.afvalwijzer_tomorrow.state }} wordt opgehaald op: {{ (as_timestamp(now()) + (24*3600)) | timestamp_custom("%d-%m-%Y", True) }}!'
          data:
            actions:
              - action: "MARK_WASTE_MOVED" # The key you are sending for the event
                title: "Afval buiten gezet" # The button title

into

    action:
      - service: notify.family
        data:
          title: "Afval"
          message: 'Het is vandaag - {{ now().strftime("%d-%m-%Y") }}. Afvaltype(n): {{ states('sensor.afvalwijzer_tomorrow') }} wordt opgehaald op: {{ (now() + timedelta(days=1)).strftime("%d-%m-%Y") }}!'
          data:
            actions:
              - action: "MARK_WASTE_MOVED" # The key you are sending for the event
                title: "Afval buiten gezet" # The button title

Version of afvalwijzer integration having the issue?

-

Version of Home Assistant Core having the issue?

-

Anything in the logs that might be useful for us?

No response

Additional information

In the templating docs of Home Assistant, the following is mentioned:

_Avoid using states.sensor.temperature.state, instead use states('sensor.temperature'). It is strongly advised to use the states(), is_state(), state_attr() and is_stateattr() as much as possible, to avoid errors and error message when the entity isn’t ready yet (e.g., during Home Assistant startup).

xirixiz commented 3 months ago

Thanks @casakampa, will update the piece of code!