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

Just a side note, you will see this error overnight sometimes, don’t worry if you do as its looking for these values to run the automation, but obviously no solar is available.

As Henrik has mentioned you can set another automation to turn water heater on or off at sunset / sunrise, time based automation or a switch on your dashboard so you can manually control it. 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.

Nice though, but, no, seperate IDs for each automation

My solution to the “it might not work if I re-enable it” problem - hope this helps anyone …

alias: Turn on PV Charger Automation
description: ""
trigger:
  - platform: state
    entity_id:
      - schedule.force_charge
    to: "off"
condition: []
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: update.pyscript_update
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - service: automation.turn_on
    data: {}
    target:
      entity_id: automation.pv_car_charger
mode: single

This is so interesting that you are experiencing this.

What happens if you manually disable it at sunset and see if the off peak water heater automation fires up?

Hi Neil,

Thanks for sharing.

Can you please elaborate a little bit more on what this automation is supposed to do and how and when is it called or enabled?

Well, for me it simply re-enables the automation after a “force charge” for the EV (i.e. dumping the battery into the car if I know there’s going to be enough solar in the day to charge it back up). If I left the PV automation on it would turn off the charger at 6am…

To ensure my ‘off peak’ automation fires through the night I found that disabling the Excess PV automation at the start of the off peak period and re-enabling it again afterwards gives me the desired effect

That is good you have a work around and its working. Thanks for updating.

Thanks Neil for the explanation, I was looking at it and tried to do a workaround to restart the pyscript when it fails, but so far not had much luck.

That is good you have a work around and its working. Thanks for updating.

1 Like

@InventoCasa Yesterday was a really sunny day and I was producing around 5Kw, with a full battery and exporting around 4Kw to the grid but the system still did not turn on the water heater. I checked the sensors and all the values looked be correct to make the system turn on. Here is my config do you have any suggestions?

@spencerralph you have to take a look at your Home Assistant logs / the Home Assistant logfile. If you setup the script according to instructions, there should be a lot of debug logs from the script which will tell you why your water heater is not being switched on.

just wondered if the logging is set up correctly here is my configuration.yaml file
Screenshot 2023-06-16 at 10.43.06

as im not seeing info in the log every time the script run

@spencerralph no, indentation is wrong, also the logger key must not be under the pyscript key. Please follow the instructions in the first post.

Whilst the indentation is not correct. So sorry Henrik & Spencer, about the position of the logger key. That was how I have it in my setup, on a steep learning curve on this one for sure.

Logging is now working: so here is the output: as you can see the log is indicating that there is not enough power any help would be great.

And here is are the figures from my invertor as these are what im using to trigger the automation.

Your export is in KW … that’s the problem. It is expecting watts - so 3920W not 3.92KW.

Covert all the power variables to W and it should work perfectly.

Spencer,

If you look at your image, the power is in kW, what the script wants is the entity id in W.

I dont have a hybrid inverter but have a growatt offgrid inverter, that has the sensors for both kW and W so you will have to look and pick the correct one, or you will have to create a helper to convert from kW to W

If you dont have the option in the inverter itseIf to choose the sensor that gives you W, then look at this link how you can convert it Convert kW tot Watt - Configuration - Home Assistant Community (home-assistant.io)

Looked and all my sensors are in KW, so the conversion may be the only why forward, One QQ would the Conversion method change all my sensors to Watts, i just wanted to change the ones i use for the script

Ok then you have to look at the option mentioned. No it will create new sensor’s for the script.

Just be careful when altering your config.yaml file.

So let’s look at the following.

  1. Does your /config/configuration.yaml file have this line?
sensor: !include sensors.yaml
  1. If you do see the above line then check if you have a file called.

sensors.yaml

  1. If the above file is there then at the bottom of the sensors.yaml file add the following.
### Making new sensor kW to W - Solar   
  - platform: template
    sensors:
      solar_in_watts:
        friendly_name: "Solar Power In Watt"
        unit_of_measurement: "W"
        value_template: "{{ states('sensor.nwctcjc06d_all_pv_wattage')|float * 1000 }}"
  1. Double check the indentations and if your value template sensor above is correct.
  2. Once you save it go to > Developer Tools > Click on CHECK CONFIGURATION you should not get any errors, if you do go back to the file and recheck, double check and correct.
  3. Restart HA
  4. Goto Settings > Devices & Services > Entities > in the search bar copy and paste this without the
    quotes “sensor.solar_in_watts” you will see the sensor has been created select it and you will now
    see that your kW is displayed in W
    8.This is the sensor sensor.solar_in_watts you will now use in the Script for PV Power.
  5. Create the other 2 sensors too for your Script

Good Luck