How to make a washing machine smart

I need some help in order to smart my washing machine.
I have it plugged in on a smart-socket that reports also energy consumption.
Also I have created a sensor that reports the high tariffs (HT) and the low tariffs (LT) of my energy supplier which I use it to calculate my utility energy costs.
What I want to achieve is when the plug identifies a consumption of >10W (sensor.washing_machine_current_power >10) for more than 10 seconds, and is at the HT period, to turn off the plug ( switch.washing_machine: off ) until the LT period starts.

Need to know what kind of sensor you use to report HT and LT period. Post up what you got so far in your automation.

I am not sure if yours is capable to pickup from power-cuts, mine (Samsung) is overly smart :slight_smile: and will just wait for someone to physically push the start button

it will start from where it stopped, that’s why i say - wait 10sec - so that the cycle starts.
maybe the samsung needs some setting up on how to respond after power cuts.

OK…then why not use the automations GUI? It has the option to built-in delays

this is a custom sensor created based on the following post

From what i understand you just want an automation to turn off/on the smart socket at certain time. why the trouble with tariff sensors and power consumption.

If I’m understanding correctly, the tariff times are not set as a specific time but done according to some overall-energy-use calculations (either by government agency or by power company). So, you have to figure out whether it is a tariff time or not each time you check.
True, you don’t need the power consumption calculation since you can turn the outlet on or off regardless of whether the washer is actually working at the time. The only caveat there is that 10 second delay to make sure it starts the cycle. If it doesn’t do that, it won’t “pick up where it left off” when the power comes back on.

Oki, because the tariff sensor you post up from the other thread is definitely a fix time between 08:00 and 19:00 that why i assume that.

at specific times the cost of electricity is low - this is set and does not have to do with market price or total consumption. so, since my wife is not paying attention on this detail, i have to force the washing machine to operate at the low cost period :wink:

the tarif sensor looks like that as it differs between winter and summer

value_template: >
          {% set tariff = { "HT": 0.1309, "LT": 0.0901 } %}
          {% if (4,1) <= (now().month, now().day) <= (10,31) %}
            {% if ((700 <= (now().hour * 100) + now().minute <= 2300)) %}
                {{ tariff.HT }}
            {% else %}
                {{ tariff.LT }}
            {% endif %}
          {% endif %}
          {% if (11,1) <= (now().month, now().day) <= (12,31) or (1,1) <= (now().month, now().day) <= (3,31) %}
            {% if ((200 <= (now().hour * 100) + now().minute <= 800)) or ((1500 <= (now().hour * 100) + now().minute <= 1700)) %}
                {{ tariff.LT }}
            {% else %}
                {{ tariff.HT }}
            {% endif %}
          {% endif %}

is there a way to define it only ONCE, and use it as reference in the automation?

created the automation below. though I can not find a way to make the 2nd condition work - if the plug is on for less than 30min. the template gives me the error : template value should be a string for dictionary value @ data[‘value_template’]. Got None

alias: Washing Machine SMART
description: 'check if the plug gets >5W for >1m and if in HT and is on for less than 30min, turn off and wait until HT goes to LT, then turn on'
  - platform: numeric_state
    entity_id: sensor.washing_machine_current_power
      hours: 0
      minutes: 1
      seconds: 0
    above: '5'
  - condition: and
      - condition: state
        entity_id: sensor.greek_electricity_tariff
        state: HT
      - condition: template
        value_template: >
          < 30}}"
  - type: turn_off
    device_id: 82eece1e1981ec0aaf7dd846edf78320
    entity_id: switch.washing_machine
    domain: switch
  - wait_for_trigger:
      - platform: state
        entity_id: sensor.greek_electricity_tariff
        from: HT
        to: LT
  - type: turn_on
    device_id: 82eece1e1981ec0aaf7dd846edf78320
    entity_id: switch.washing_machine
    domain: switch
mode: single

See if that work

 - condition: template
        value_template: >
          "{{ ((as_timestamp(now()) - as_timestamp(state_attr('automation.washing_machine_smart', 'last_triggered'))) / 60) < 30 }}"

still getting the ERROR message template value should be a string for dictionary value @ data[‘value_template’]. Got None

Or this format

 - condition: template
   value_template: >
     {{ (as_timestamp(now()) - as_timestamp(states.automation.washing_machine_smart.attributes.last_triggered)) | int < 1800}}

still. no luck …

ohhh ok the syntax seem fine, so the problem lies in the “states.automation.washing_machine_smart.attributes.last_triggered”
it might not pass the test because there isn’t a last_triggered value yet?
look at its attribute it might be “null”

Anyway that condition is never going to be false as it measure time of last trigger of itself. Everytime it trigger the time of last trigger reset to zero. so it can sit there for 30mins or more but that doesn’t mater because when it trigger again and time of last trigger is back to zero that when condition is compare which will always be less then a second.

hi and thanks for you help. that value is not null for sure. I check the result with the template testing in the developer tools.
what I want to achieve is to avoid getting into an issue of starting the washing machine while in LT and then get into the HT period and the automation initiates and stops the washing machine. so if it is already up and running for more than 30min I want this automation to be ignored.
as a alternative I created a switch that is on when the equation is valid, so I include it in my conditions like that but ideally there should be a template there.