PV / Solar Excess Optimizer: Auto-control appliances (wallbox, dish washer, heatpump, ...) based on excess solar power

My config is

id: '1685362280575'
alias: Wallbox - Überschussladen
description: ''
use_blueprint:
  path: pv_excess_control.yaml
  input:
    automation_id: wallbox_uberschussladen
    pv_power: sensor.total_dc_power
    export_power: sensor.export_power
    home_battery_level: sensor.battery_level
    min_home_battery_level: 80
    home_battery_capacity: 9.5
    solar_production_forecast: sensor.combined_remaining_solarforecast_production_for_today
    appliance_switch: switch.wallbox
    appliance_switch_interval: 5
    dynamic_current_appliance: true
    appliance_current_set_entity: input_number.wallbox_input_current
    appliance_phases: 3
    actual_power: sensor.wallbox_power_consumption_in_watt
    load_power: sensor.load_power

I understood that appliance_switch has to be an entity which starts or stopps the wallbox and I am not able to configure the “standard” wallbox entity HA gives me. I have an easee wallbox and I cannot configure the easee-wallbox-entity for the appliance_switch.

To give the integration a switch entity I configured a template one:

- platform: template
  switches:
    wallbox:
      value_template: "{{ is_state('sensor.wall_e_status', 'charging') }}"
      turn_on:
        service: easee.action_command
        data:
          device_id: [MYID]
          action_command: start
      turn_off:
        service: easee.action_command
        data:
          device_id: [MYID]
          action_command: stop

At the moment I am writing that I am getting an intuition … It is possible that I have to change the value_template for the status because the integration has 5 or 6 different states?

The instructions state to add the automation ID as the entity and that this is available by clicking the three dots… That’s not possible when you first build an automation, it needs to be saved first.

The current settings screen shows my ID as: automation.excess_solar_optimiser_immersion_switch is this the expected format, or is it without automation.?

Thanks

Nick

When you create your automation, you would give it! a unique name, then copy that name and when you have filled all the relevant information you will hit the save button. A pop up window will appear when that happens you paste the unique name give it a description and hit the rename word at the bottom right of the window. It will automatically save it under the name. Please see below screen shots of one I just setup for the washing machine. Hope this helps your question, its a bit of a learning curve for me too.

automation_entity_id_washing_machine_solar_rename

1 Like

Got it working, it’s great! Thanks

Sounds good…can you please post here what you did to get it working for the benefit of others?

Hi Henrik,

I know this has been mentioned in a few post above.

If you make changes to an automation and they save and run it, the change seems to kill pyscript from running and automation does not run also there are no logs too. The only way to start pyscript and the logs is to restart HA. I noticed that even the cron 0.0.0.0 does not seem to work I simulated this see the below screen shots.

Normally running log.

After simulated change to an automation pyscript stops running and no log

2023-06-03 00_23_10-Logbook – Home Assistant

Cron 0.0.0.0 in pv_excess_control.py fails to restart pyscript or the logs

Only a restart would get pyscript and the logs working

Have you found a workaround for this without having to restart HA?

Observed an issue overnight with the automation which is set to govern the use of our immersion heater.

The automation works well in the day, in that it activates the immersion during excess solar. However, I have an ‘off peak’ automation set to run during the night which also activates the immersion (if required) to take advantage of the low electricity rates.

I can see that HA did activate the immersion overnight, but this automation then immediately turned it off… Is there any way I can work around this?

Thanks

Awesome automation.

I have a problem though. I have set my pool pump to turn on for an hour but I have run-once enabled so it only runs once a day, but it still runs multiple times a day:

What am I missing?

Following up from my post above. I have managed to find a work around, where if a change was made to the existing automation when its saved and run it kills the pyscript from running. It’s taken a while of persisting with this, and I’m sure over a 100 restarts of HA and full reboots with the same amounts of deleting and redoing all the automations.

The very first time you setup an automation, you carry out the OP instructions, you will see the pyscript running every 10 seconds or there abouts. Now here is where it went pear shape, if I need to make a small tweek to one of the automations, make the change, save and run the script, it kills the pyscript from running, even leaving it overnight when the cron runs it still would fail to run. The only way to make it all run is delete all the automations, restart HA and start again.

So the simplest way to make a change to the automation is as follows.

  1. Open the automation.
  2. Click on the 3 dots on the top right.
  3. From the pop up menu “disable” the automation
  4. Make the changes you need.
  5. Hit the “Save” blue button at the bottom right of the page.
  6. Follow step 1 & 2 above
  7. From the pop up menu “Enable” the automation
  8. Dont hit the “Run” button As this will kill pyscript from running.
  9. From the left of the menu bar select “Logbook” you will see that the automation was turned off and turned on and pyscript is happy and running.

Hope this helps all who are having this issue. Just for clarity here is my HA details

Home Assistant 2023.5.4
Supervisor 2023.04.1
Operating System 10.2
Frontend 20230503.3 - latest

Update 15/06/2023
I have just found that whilst this work around does not kill the running pyscript, it accepts the changes in the blueprint but this does not write the changes to pyscript module. So this is what I do now to make changes to an automation.

Disabling/Enabling you blueprint automation works fine. I only find and a few others that making any changes to the blueprint once its running kills pyscript. I now opt to disable the automation, delete it and redo it with the settings I want, save, run the automation and then enable it. Works well for the moment.

Nick,

Not sure why your setup is doing this as I have a couple of automations setup in PV / Solar Excess Optimiser and the same ones setup to run at night when the electricity rates are offpeak they run perfect.

See if there is anything in the logs and manually run the automation and see what happens.

Good Luck

I get it Working by changing the value_template for my wallbox_switch from

value_template: "{{ is_state('sensor.wall_e_status', 'charging') }}"

to

value_template: "{{ states('sensor.wall_e_status') in ['charging', 'awaiting_start'] }}"

The Easee Wallbox goes into state ‘awaiting_start’ while it is doing some load balancing on the 3 phases or while it is waiting for the car.

Can someone help me in understanding what exactly is meant with “Load Power” in the blueprint?
My panels are generating DC into my inverter which sends current to the battery (if the battery is not already fully charged) and converts DC to AC to send it into my “house”.

Is “Load Power” meant as the full load including battery charge (which comes from the panels) and house consumption or is load power meant be to house consumption without the load that goes into the battery?

My battery is only charged using DC from the panels. There will be no charge from the AC side

Hi markusmazurczak,

So my understanding I’ll break this down.

  1. Load Power would be the actual house load.
  2. If you specify the Load Power then you have to also specify the Export Power. (Which is Power you push back to the grid)
  3. If you specify a battery then all your solar would charge the batteries at the maximum setting as well as supplying the Load Power in priority order.
  4. Once your battery if fully charged to the percentage you set it to, power will be then set to the load in priority order and if there is no load (nothing is used in the house) then power will be sent to the grid.

Just a side note, you have a hybrid inverter? if so then the above applies. Batteries are not taken as part of the load. Now if you have a offgrid inverter then the load power includes the battery.

Have a look at what Henrik explains about load power.

Hope this help…

Are you seeing:

file_pv_excess_control_on_time has been triggered by time 2023-06-12T20:14:53.474468 in your log file every 10 seconds or so?

Yes if it running you will see it every 10 seconds

Henrik

I’m new to both solar and home Assistant, so excuse the basic questions.

I have installed your automation and it does seem to be running (every 10 seconds i see it trigger in the logger) however even if I’m exporting 3KW i don’t see the appliance turn on. Is there a way to see what the code is pulling from the sensors, to help debug the system. also i was not sure where and how i enable the logger (which configuration.yaml file do add the statement to) and where will i see the output?

Thanks Spence…

Nick,

Just a thought that struck me…

Are you using the same Automation Entity ID

*PV Excess Optimiser
&
*Off peak heater automation?

Hi Spencer,

I will try my best to assist with your question being a user myself and very happy with the way this is working, till we hear back from Henrik (as he has indicated that he is very busy to me)

  1. This is correct as if you looked in logbook you will notice that it runs every 10 seconds.
  2. Could you please provide what system you have Hybrid or Grid tied? recheck your configurations if possible.
  3. Are there in errors in your full log Settings > System > Logs?
  4. Add this at the bottom of your /config/configuration.yaml file.
pyscript:
  allow_all_imports: true
  hass_is_global: true
  
  logger:
  default: info
  logs:
    custom_components.pyscript.file.pv_excess_control: debug

If everything is configured correctly and running then you will see something like below in your logbook

When pyscript triggers the appliance to control (on)

When pyscript triggers the appliance to control (off)

Thanks for the info

I’ve enabled logging but still don’t see much. its a hybrid growatt inverter with 6.5Kwh battery. I do see this in the system logThis error originated from a custom integration.

Logger: custom_components.pyscript.file.pv_excess_control.on_time
Source: custom_components/pyscript/eval.py:1901
Integration: Pyscript Python scripting (documentation, issues)
First occurred: 9:16:50 AM (39 occurrences)
Last logged: 9:22:30 AM

“Import/Export power” has been defined together with “Home Battery”. This is not intended and will lead to always giving the home battery priority over appliances, regardless of the specified min. battery level.
num=unavailable is not a valid number between 0 and 1000000: could not convert string to float: ‘unavailable’
Could not update Export/PV history!: int() argument must be a string, a bytes-like object or a real number, not ‘NoneType’

but not too sure what i need to change i have looked at the automation and removed the import/export entity from the list however still seeing the error.

Spence