#Using surplus power for electric heater - automation

1 messages · Page 1 of 1 (latest)

spare finch
#

In order to optimize the use of self-generated electricity, I made an automation that turns on an electric heater (bathroom) when there is surplus power: It turns a socket on (which the heater is connected to), waits 15 minutes, and turns the socket off again. This is repeated as long as there is surplus power and the bathroom target temperature is not reached.
But I think my solution is not very elegant:

  • it uses a long wait (15 minutes)
  • it heats at least 15 minutes, even if after 1 minute there's no more surplus power
    Can someone please help me improve this automation along the lines "turn on when conditions are met and keep watching conditions and turn off as soon as not met any more, (for a total maximum duration of x minutes)"?
    What should be kept in mind: The socket/heating can also be switched on/off manually and that surplus-automation shouldn't interfere with manual operation.
jagged ore
#

So this is a little tricky due to the "surplus-automation shouldn't interfere with manual operation" requirement - does that include not turning it on after you've manually turned it off even if there's surplus power and it needs to heat?
Assuming you don't want that and just don't want it to turn it off when you've turned it on manually, I'd probably make a helper input_boolean to store "is running from automation" and just have that as part of the "switch off logic". Something like this:

#
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.grid_export_power
    for:
      hours: 0
      minutes: 1
      seconds: 0
    above: 2000
    id: turn_on
  - platform: numeric_state
    entity_id:
      - sensor.grid_export_power
    for:
      hours: 0
      minutes: 0
      seconds: 30
    below: 10
    id: turn_off
  - platform: numeric_state
    entity_id:
      - sensor.bathroom_temperature_temperature
    above: input_number.day_heat
    id: turn_off
  - platform: state
    entity_id:
      - switch.bathroom_heater
    from: "on"
    to: "off"
    id: switch_off
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - turn_on
        sequence:
          - service: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.automation_heating
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.bathroom_heater
      - conditions:
          - condition: trigger
            id:
              - turn_off
          - condition: state
            entity_id: input_boolean.automation_heating
            state: "on"
        sequence:
          - service: switch.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: switch.bathroom_heater
      - conditions:
          - condition: trigger
            id:
              - switch_off
        sequence:
          - service: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.automation_heating
mode: queued
max: 10
#

This triggers turning on the switch (and input_boolean) when you have more than 2kW excess power for 1 minute
It (tries to) turn off the heater when you have <10W of excess power, or your bathroom temperature is above the limit - if the input boolean isn't on - that means you turned it on manually and it doesn't turn the heater off.
It turns off the input boolean when the heater turns off

spare finch
#

Great. Didn't know about the ids and multiple triggers. I added that automation (changed the entity names of course) and when I look at it after saving, the "sequence: service" was changed to "sequence: action". Suppose that is normal?
Do I need to define the input_boolean.turn_on and turn_off somewhere else or are they automatically instantiated when used in the automation?

jagged ore
#

You need to define the input boolean as a helper

#

And yeah service got renamed - I just haven't updated yet, whoops

spare finch
#

So two input_boolean helpers, "turn_on" and "turn_off"?

#

and also "automation_heating"?

jagged ore
#

No, just one called automation_heating - turn on/off are actions done to it

spare finch
#

ok

#

would you know what that helper is called in the german localization?

jagged ore
#

In English is called toggle in the ui, no clue what it is in German

spare finch
#

Ok it is called Schalter (switch)

#

Thank you very much so far, tomorrow will be sunny so I'll know if it works.

#

I had another automation to turn off the heating after 45 minutes when (manually) turned on. I changed that to check the input_boolean.automation_heating as well as the runtime to make sure this doesn't interfere with the heating_automation above. Does this look ok to you?

#
alias: Heizung Kinder AUS nach 45 Minuten
description: Steckdose für Heizung Kinderbad wird nach 45 Minuten ausgeschaltet.
trigger:
  - platform: device
    type: turned_on
    device_id: 49d91aab14ed9c56bb87a3b422a131d7
    entity_id: 791045d317fc418ad70ddbde701d513a
    domain: switch
    for:
      hours: 0
      minutes: 45
      seconds: 0
condition:
  - condition: state
    entity_id: input_boolean.automation_heating
    state: "off"
action:
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      device_id: 49d91aab14ed9c56bb87a3b422a131d7
mode: single
#

(how do I paste formatted code?)

grand ospreyBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.