Unable to Automate turning a Switch Off after set period

I’m am trying to get an automation working to automatically turn a switch off, after a period of time, regardless of whether it was switched on manually or via an automation.

This is the code that I am using.

- id: rich_electric_blanket_auto_off
  alias: Turn off Electric Blanket Rich after two hours
  description: Automatically turns off Rich's electric blanket two hours after being
    turned on.
  trigger:
  - platform: state
    entity_id: switch.electric_blanket_rich
    from: 'Off'
    to: 'On'
    for: 02:00:00
  condition: []
  action:
  - service: switch.turn_off
    target:
      entity_id: switch.electric_blanket_rich
  mode: single

I’ve tried splitting out the for like below, but that didn’t make any difference.

    for: 
       hours: 2
       minutes: 0
       seconds: 0

Any suggestions on what could be causing the issues? The configuration tool shows no issues etc, and there in nothing in the logs to indicate any issues.

Thanks!

  trigger:
  - platform: state
    entity_id: switch.electric_blanket_rich
    from: 'off'
    to: 'on'
    for: 02:00:00

Lower case on and off.

Doh!

Thanks very much. That worked perfectly.