Automation for turning the ice maker off when power is below a certain value

Hi, everyone…
I have an ice maker plugged into wall outlet via a smart plug flashed with ESPHome.

The smart plug is capable of measuring power consumption of the ice maker.

The ice maker makes ice until it is full with ice. The time necessary for the ice maker to reach full varies depending on the ambient temperature and the amount of ice left at the time it starts to make ice.

The ice maker consumes about 550~650W when making ice and 2W when idle (not making ice).

Since the ice maker makes quite a noise, I want it to be off during the day and want it to make ice during the night.

The scheduling I want is:

(1) When the power consumption of the ice maker is below 30W (not making ice) at noon, the smart plug is turned off by automation to turn off the ice maker.

(2) When the power consumption of the ice maker is above 30W (making ice) at noon, the automation waits until the power consumption goes below 30W and then smart plug is turned off by automation to turn off the ice maker.

The power consumption eventually comes down to about 2W so it is just matter of time that automation for turning off the smart plug kicks in.

I have tried the automation below but this does not work…I have no idea why it is not working.

alias: Ice maker OFF
description: ""
triggers:
  - trigger: time
    at: "12:00:00"
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
  - condition: state
    entity_id: switch.ice_maker_smart_plug
    state:
      - "on"
actions:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.ice_maker_smart_plug_power
            below: 30
        sequence:
          - delay:
              hours: 0
              minutes: 0
              seconds: 20
              milliseconds: 0
          - action: switch.turn_off
            metadata: {}
            target:
              entity_id: switch.ice_maker_smart_plug
            data: {}
mode: single

Any help would be appreciated.

1 Like

Maybe I have misunderstood something, but I would have made it the other way around.

Trigger when power goes below 30 W. Condition is if time is after 12.

That way, you need no delays or other checks, I think.

1 Like

There’s a lot that isn’t correct here.
An automation does not wait for the consumption to get below 30, at noon if below then it will do things but else it doesn’t do anything until tomorrow.

Conditions can’t be in triggers, and there is no need for the condition to be honest.
If the consumption is above 30 w then I sure hope it’s on.

I would replace the trigger with a template trigger that will trigger when it is past noon and less than 30 w.

{{ now().hour >= 12 and states('sensor.ice_maker_smart_plug_power') | int < 30 }}

So now actions can be delay for 20 seconds and switch off.

1 Like

OK, now I understand the delay. That detail can be added in the trigger: power under 30 W for 20 seconds. Condition: after 12:00. Action: turn off.

No need for template trigger, but that combines the trigger with the condition, except for the 20 seconds delay wich have to be added to the actions in that case.

You can add the delay in the trigger also.

  - trigger: template
    value_template: >-
      {{ now().hour >= 12 and states('sensor.ice_maker_smart_plug_power') | int < 30 }}
    for:
      seconds: 20
1 Like

The ice maker only makes ice, it doesn’t also keep it frozen once it’s made?

1 Like

Some only does the ice and then keep them in a tray. And you’re supposed to put it in the freezer

My ice maker is capable of producing about 50kg of ice per day. However, it is not capable of keeping the ice frozen.
Even though the ice maker is thermally insulated, ice inside the ice maker therefore slowly melts with time. The ice maker keeps on making ice as ice melts away.

Thank you for your suggestion.

I tried your suggestion and it kind of works.

alias: Ice maker OFF
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.ice_maker_smart_plug_power
    below: 30
    for:
      hours: 0
      minutes: 0
      seconds: 20
conditions:
  - condition: time
    after: "12:00:00"
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
    before: "01:59:00"
  - condition: state
    entity_id: switch.ice_maker_smart_plug
    state:
      - "on"
actions:
  - action: switch.turn_off
    metadata: {}
    target:
      entity_id: switch.ice_maker_smart_plug
    data: {}
mode: single

The only problem here is that the trigger only works when the power consumption of the ice maker comes down to less than 30W after 12:00. Basically, the trigger requires change in the power consumption (>30W to <30W) to occur after 12:00.

Let me explain this. There are two cases that may occur at 12:00.

(1) First case: the power consumption of the ice maker is already lower than 30W (already idle) at 12:00.
In this case, the trigger does not work. The trigger only works when the ice maker makes ice one more time (>30W) after 12:00 and then completes making ice (<30W).

(2) Second case: the power consumption of the ice maker is higher than 30W at 12:00 and comes down to less than 30W after some time.
In this case, the trigger works.

I want the trigger to work in both cases. That is, the automation checks the power consumption at 12:00 and if it is already lower than 30W, the automation turns off the switch (immediately or after delay). If the power consumption is higher than 30W at 12:00, the automation waits until the power consumption comes down to less than 30W, and then turns off the switch (immediately or after delay).

any ideas?

I think I figured this out.

The automation checks the power consumption every 30 seconds after 12:00 and turns off the switch (after delay) when the power consumption is <30W.

alias: Ice maker OFF
description: ""
triggers:
  - trigger: time_pattern
    seconds: /30
conditions:
  - condition: time
    after: "12:00:00"
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
    before: "13:00:00"
    enabled: true
  - condition: state
    entity_id: switch.ice_maker_smart_plug
    state:
      - "on"
  - condition: numeric_state
    entity_id: sensor.ice_maker_smart_plug_power
    below: 30
actions:
  - sequence:
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
      - action: switch.turn_off
        metadata: {}
        target:
          entity_id: switch.ice_maker_smart_plug
        data: {}
mode: single

No… if you don’t want to use the template method then at least don’t use a time trigger.
That is just loading your system for no reason.

Remove the time trigger and replace it with a numeric trigger on below 30.
Re-add the time trigger you had at 12:00.
Keep all the conditions you have.

Templates that use now() re-run once per minute according to HA documentation.
If i change my automation to check every minute instead of 30 seconds, wouldn’t it be the same as using template in view of loading the system?

I would do it like this, which I think fulfills the requirements you have written in this thread.

alias: Ice maker OFF
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.ice_maker_smart_plug_power
    below: 30
    for:
      hours: 0
      minutes: 0
      seconds: 20
  - trigger: time
    at: "12:00:00"
conditions:
  - condition: time
    after: "12:00:00"
  - condition: numeric_state
    entity_id: sensor.ice_maker_smart_plug_power
    below: 30
actions:
  - action: switch.turn_off
    metadata: {}
    target:
      entity_id: switch.ice_maker_smart_plug
    data: {}
mode: single

Explanation:

  • Triggers for both 12 o’clock and when the power dips under 30 W
  • Conditions checks that it is after 12 o’clock and that the power is under 30 W (both must be true, and needs to be checked because of the two triggers)
  • If triggered and conditions passes, the ice maker turns off.

This way we do not need to trigger to check every now and then, which is unnecessary and wasteful. We know what will be our triggers, and nothing else matters.