Problem with simple On/Off automation

I have a Samsung fridge that is having problems with the ice maker overfilling the bucket and clogging things up. Short of spending several hundred dollars to have the ice maker replaced, I thought I would try an Automation to turn Off the ice maker after it has been On for 4 hours. I thought I had it working but History indicates not as intended.

The SmartThings integration provides an entity switch for the Ice Maker. Via HA I can turn it On & Off and the Fridge responds correctly to those HA commands.

Looking at history activity, it appears the Automation to turn Off only works when manually commanded On via HA.

If the ice maker is Off, and I activate the ice maker at the fridge by pressing the ice dispenser to fill a glass, the state of ice maker goes back to On in HA and at the fridge panel, but the automation does not turn it off automatically after 4 hours.

How can I make the desired automation to work as intended?

Thanks.

Hi,

Please share your automation in YAML

alias: Ice maker
description: When Ice Maker is on for 4 hours turn it off
triggers:

  • trigger: state
    entity_id:
    • switch.refrigerator_cubed_ice
      to:
    • “on”
      for:
      hours: 4
      minutes: 0
      seconds: 0
      conditions:
      actions:
  • action: switch.turn_off
    metadata: {}
    target:
    entity_id: switch.refrigerator_cubed_ice
    data: {}
    mode: restart

Does the automation work if you set the time to, for example, 25 seconds?

Four hours is quite a long time. The automation will reset the timer every time your fridge (integration) reconnects. Is the state of your trigger stable?

Does manually triggering the action in the automation work?

Please post the YAML with the below function: