Automation ‘expected a dictionary value’

Hello everyone, I got this error

Logger: homeassistant.config
Source: config.py:443 
First occurred: 4:54:54 PM (1 occurrences) 
Last logged: 4:54:54 PM

Invalid config for [automation]: invalid time_pattern value for dictionary value @ data['hours']. Got None. (See /config/configuration.yaml, line 5).

here is my automation.yaml

- id: '1624449501449'
  alias: Watering Automation
  description: water 45 seconds every 2 hours
  trigger:
  - platform: time_pattern
    hours: "{{ states('input_number.Hour') | int }}"
  condition: []
  action:
  - service: script.watering_script
  mode: single

Can you please help me out?
I don’t know what format should I choose for my input_number.Hour…

I don’t believe you can use a template there.

Try this instead:

  trigger:
    - platform: time_pattern
      hours: "*"
      minutes: 0
  condition:
    - condition: template
      value_template: "{{ now().hour % (states('input_number.hour')|int) == 0 }}"

(finished editing now, not having a good day :smiley: )

That will trigger every hour for minimal system load, then only continue if the hour part of the time is divisible by the value of your input_number (which I think must/can be lower case).

thanks a lot for your help. Will the value in the automation be updated automatically once I change the value of the input_number?

Yes you do not need to worry about lagging or delay, it will be almost instantaneous, whenever input value is changed, automation will kick in (at worst a second delay, might depend on home assistant performance)