Alert config error - syntax help request

In my configuration.yaml I’ve set up an alert which reminds me to buy ink when any ink cartridge reaches less than 15%… (Epson had a service (called ‘ReadyInk’) that I used to use to actually automatically order ink when it was low, with no human interaction required, from any vendor I preferred, which I loved - but as of March 31 they have shut down the service (I am surprised they would have shut that down))…

Anyway, I have the Epson printer integration in HA, which automatically created 4 ink cartridge sensors. Long story short, since there is no integration for such a service (which would be great), I’ve just decided to set up an alert for ink using the sensors that are now available for each for each ink cartridge…

In developer/templates this works perfectly:

{{ int(states('sensor.epson_wf_3730_series_black_ink')) <= 15 }}

(and currently returns ‘False’)

So with this as my alert, in configuration.yaml:

#
# Printer ink alerts (time to order ink):
#
alert:
  time_to_order_black_702XL_ink:
    name: Time To Order Ink - 702XL Black
    title: Ridgewood Estate Automation at {{ now().strftime('%-I:%M%p').replace('AM','am').replace('PM','pm') }}
    message: Black ink has fallen to {{ states('sensor.epson_wf_3730_series_black_ink') }}%, time to order 702XL Black
    done_message: Black ink has been refilled.
    entity_id: sensor.epson_wf_3730_series_black_ink
    # triggered if Black ink is below 15%
    state: {{ int(states('sensor.epson_wf_3730_series_black_ink')) <= 15 }}
    # Repeating once per day, after day 1:
    repeat: 1440
    skip_first: true
    notifiers:
      - Ridgewood_Estate_Text_Message_ADMIN_ONLY
    can_acknowledge: false

Very similar to many other alerts I already have for open garage door, etc… but I get this error message when checking the config:

Error loading /config/configuration.yaml: invalid key: “OrderedDict([(“int(states(‘sensor.epson_wf_3730_series_black_ink’)) <= 15”, None)])”
in “/config/configuration.yaml”, line 310, column 0

Thoughts - type mismatch of some sort?

Add outer double-quotes to the state template.

    state: "{{ int(states('sensor.epson_wf_3730_series_black_ink')) <= 15 }}"

Perfect! Thank you!

1 Like