Zero Solar Power Export with ESPEasy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Wiki
Normal user
Posts: 404
Joined: 23 Apr 2018, 17:55
Location: Germany

Zero Solar Power Export with ESPEasy

#1 Post by Wiki » 17 Nov 2022, 12:43

I have a small Solar Voltaik system installed, in Germany called „Balkonkraftwerk“. Means: four solar panels, power production limited to 600 Watt, plugin-installation.

The system has four 410 Watt panels, a Hoymiles HM-1500 inverter, limited to 40% of the theoretical 1500 Watt it could deliver to fullfill the restrictions of german regulations. Because I don’t get anything back for exported power I want to avoid energy export as far as possible. ESPEasy gives me the opportunity to do this pretty easy.

Hardware:
4x410 Watt peak solar panels
1xHoymiles HM-1500 solar inverter, limited to 40%
1xAhoy DTU for getting the data of the inverter into MQTT (1xESP8266, 1x eByte nRF2401+ (https://www.amazon.de/gp/product/B07P8TTHZH), software from here: https://github.com/lumapu/ahoy)
1xESP32 with ESPEasy, compiled from Ath (https://letscontrolit.com/forum/viewtop ... 990#p60990)
1xVolkszaehler https://www.ebay.de/itm/314152997777

The Ahoy DTU sends the data of the inverter every ten seconds into MQTT, configured to a clean MQTT topic /inverter/HM-1500.

The Volkszaehler does the same with the data from the energy counter. The precompiled Tasmota firmware of the Volkszaehler sends the data as a JSON data set configured to Zaehler/SENSOR,{"Time":"2022-11-14T15:24:00","SML":{"Verbrauch":1.474,"Einspeisung":0.770,"Watt":26.000}}. Ath was so kind to build a special version for the ESP32 so I can read the second level of the JSON message using MQTT Import with a JSON attribute e.g. SML.Watt.

Now its very easy to process the informations and adjust the inverter to produce not more energy as I need in my house:

Code: Select all

On Solar3#Watt Do
  TaskValueSet,5,1,[Solar#P_AC]+[Solar3#Watt] //just for the statistics calculating the overall consumption
  Publish domoticz/in,'{"idx":144,"nvalue":0,"svalue":"[Calc#Verbrauch]"}' //sending it to domoticz
  If [Solar3#Watt]>=0 //if import from public net store the consumption to energy counter of Domoticz as consumtion
    Let,1,[Solar3#Verbrauch]*1000
    Publish domoticz/in,'{"idx":150,"nvalue":0,"svalue":"[Solar3#Watt];%v1%"}'
  Else  //if export to public net store it into a seperate energy counter in Domoticz
    Let,1,[Solar3#Einspeisung]*1000
    Let,2,[Solar3#Watt]*-1
    Publish domoticz/in,'{"idx":151,"nvalue":0,"svalue":"%v2%;%v1%"}' 
  EndIf
  If [Solar3#Watt]>6 AND [Solar#Limit]<40 AND [Solar2#U_DC3]>32 AND [Solar#P_AC]>0 AND [Calc#Timer]=0 //the voltage of one of the panels is taken as indicator if the raise of power limit makes sense to avoid sending too often, check if a timer is running
    If [Solar#SolarPowerAuto]=1 //if the automatic inverter limitation is set to „on“
      Let,1,[Calc#Verbrauch]+20 //current needed solar power
      If %v1%<=600  //if the desired limit doesn’t exceed the allowed maximum
         Publish inverter/devcontrol/0/11/0,%v1%
      Else //set to allowed maximum
         Publish inverter/devcontrol/0/11/0,600
      EndIf
      TaskValueSet,5,2,1  //set the remark that a timer is set
      TimerSet,1,30 //set a timer to avoid unnessecary tries of changes of the inverter limit, it takes around thirty seconds for the inverter to react
     EndIf
  ElseIf [Solar3#Watt]<-15 AND [Solar#SolarPowerAuto]=1 And [Calc#Timer]=0 //if too much energy is exported
     Let,1,[Calc#Verbrauch]+20
     Publish inverter/devcontrol/0/11/0,%v1% //reduce the inverter limit accordingly 
     TaskValueSet,5,2,1
     TimerSet,1,30
  EndIf
  Publish domoticz/in,'{"idx":133,"nvalue":0,"svalue":"[Solar2#U_DC1]"}' //fill some fields in Domoticz, in this case the DC voltage of the panels
  Publish domoticz/in,'{"idx":134,"nvalue":0,"svalue":"[Solar2#U_DC3]"}'
  Publish domoticz/in,'{"idx":147,"nvalue":0,"svalue":"[Solar2#U_DC2]"}'
  Publish domoticz/in,'{"idx":148,"nvalue":0,"svalue":"[Solar2#U_DC4]"}'
EndOn
On Solar#SolarPowerAuto Do
  If %eventvalue%=0 //should the inverter limitation to current power consumption switched
    Publish inverter/devcontrol/0/11/0,600 //Publish for Ahoy DTU, fixed limit following regulations
  Else
    TaskValueSet,2,4,1
  EndIf
EndOn
On Rules#Timer=1 Do //If the countdown set for waiting for the limit change of the inverter is over
  TaskValueSet,5,2,0
Endon
...snapshots from the configuration of the MQTT Import tasks will follow......
Last edited by Wiki on 17 Nov 2022, 14:29, edited 2 times in total.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 6902
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Zero Solar Power Export with ESPEasy

#2 Post by TD-er » 17 Nov 2022, 13:16

Hmm, so you're limiting the max. power the inverter is allowed to generate, based on your demands?
Why not trying to 'consume' the excess energy by turning on a larger boiler heater so you actually use and store the energy?

Not sure what the rules and regulations are in .de, but this seems like you're trying to avoid paperwork for donating energy to the grid.

Wiki
Normal user
Posts: 404
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Zero Solar Power Export with ESPEasy

#3 Post by Wiki » 17 Nov 2022, 14:14

The regulation concerning a "Balkonkraftwerk" say: 600W max (!), 4 panels max., no export, if export you will not get paid for (but you are forced to install and pay a two-way-counter(!)). With the pretty old structure of the electric installations in my house its currently not possible to do more. In the future there will be more possible, including a battery for storing the nightly needed energy.

Why did I start the project? At least as a proof of concept, a kind of curiosity and to be prepared for the future. The hardware I needed anyway (Ahoy to limit the inverter following the restrictions, Volkszaehler because I like to know my consumption, ESPEasy to get the data into my Domoticz).

The result: I get the data into my Smarthome environment, am able to trace and adjust my personal power consumption. In parallel I've purchased some small infrared heating panels which will be switched automatically depending on the delivery of solar energy. Boiler heating will be possible in summer with enough sun, but not now.

Beside the desired benefits it is possible to reduce export almost to zero. With the regulation of no payment for exported energy I felt put-on, now I feel better.

And posting it here is just as an example for the easy use of MQTT import using ESPEasy in a lean environment like mine (Smarthome with just Domoticz and mosquitto on a Raspberry).

The promised screenshots:

MQTT Import Task "Solar", as a mixture of JSON parsing Domoticz buttons and clean MQTT read from Ahoy DTU:
Unbenannt.JPG
Unbenannt.JPG (54.85 KiB) Viewed 276 times
Unbenannt1.JPG
Unbenannt1.JPG (83.5 KiB) Viewed 276 times
Unbenann2t.JPG
Unbenann2t.JPG (41.46 KiB) Viewed 276 times
MQTT Import Task "Solar3", JSON parsing,read from Volkszaehler:
Unbenannt3.JPG
Unbenannt3.JPG (49.6 KiB) Viewed 276 times
Unbenannt4.JPG
Unbenannt4.JPG (81.87 KiB) Viewed 276 times
MQTT Import Task "Solar2", clean MQTT topics from Ahoy:
Unbenannt5.JPG
Unbenannt5.JPG (47.55 KiB) Viewed 276 times
Unbenannt6.JPG
Unbenannt6.JPG (75.12 KiB) Viewed 276 times

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Wiki
Normal user
Posts: 404
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Zero Solar Power Export with ESPEasy

#4 Post by Wiki » 17 Nov 2022, 14:38

And the overview page of the tasks:
Unbenannt7.JPG
Unbenannt7.JPG (73.46 KiB) Viewed 272 times

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 6902
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Zero Solar Power Export with ESPEasy

#5 Post by TD-er » 17 Nov 2022, 14:40

It sure is a good use case to show how to act on derived data from other sensors and even platforms.
And if you later plan on turning on appliances to "burn" the energy when available, then adapting it is really easy :)

It was more that I wanted to understand the reasoning behind it.

Wiki
Normal user
Posts: 404
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Zero Solar Power Export with ESPEasy

#6 Post by Wiki » 17 Nov 2022, 14:53

Was pretty interesting how mighty the actual ESPEasy can act in an environment with different platforms.

Up to now the Raspberry has to collect data from different sources and publish them for use in Domoticz. Every time a new data delivery component took place in my home it was a pain in the a## to first analyze the data and then to script in python. Worked, but now with the MQTT import&parsing functionality a solution is only some clicks away. I am so glad with this solution, that I have ordered at once a handful ESP32 mini. Until today the ESP8266 was my favourite, did everything I needed, but now I will expand ;-).

Thank you all for this great stuff!

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

User avatar
Ath
Normal user
Posts: 2115
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Zero Solar Power Export with ESPEasy

#7 Post by Ath » 17 Nov 2022, 15:00

I love this showcase! :D
/Ton

Wiki
Normal user
Posts: 404
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Zero Solar Power Export with ESPEasy

#8 Post by Wiki » 17 Nov 2022, 16:25

Ath wrote: 17 Nov 2022, 15:00 I love this showcase! :D
And THAT makes me happy. At least you made it work in this way.........

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

User avatar
Ath
Normal user
Posts: 2115
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Zero Solar Power Export with ESPEasy

#9 Post by Ath » 17 Nov 2022, 16:40

Wiki wrote: 17 Nov 2022, 16:25 ... At least you made it work in this way.........
It was only about 6 lines of code I had to add ;)
/Ton

Wiki
Normal user
Posts: 404
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Zero Solar Power Export with ESPEasy

#10 Post by Wiki » 17 Nov 2022, 19:03

Ath wrote: 17 Nov 2022, 16:40
Wiki wrote: 17 Nov 2022, 16:25 ... At least you made it work in this way.........
It was only about 6 lines of code I had to add ;)
No!

- reading a post
- identifying the problem and identifying that you are the person who could solve it
- opening whatever programming environment you use
- searching in sources for the correct part (and knowing, which is the correct part)
- adding the six lines of code
- saving&compiling
- zipping and posting of the zipped binary
- adding a comment
- adding a pull request to add the solved problem to the project

That's what you did for minimum.

Taking into account that most of the thousands of ESPEasy users even don't care that they could contribute to this goldworthy project at least with a donated cup of coffee your support is outstanding. Personally you and TD-er have solved my sometimes stupid small problems so repeatedly (and not only mine!), I can't appreciate more.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

User avatar
Ath
Normal user
Posts: 2115
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Zero Solar Power Export with ESPEasy

#11 Post by Ath » 17 Nov 2022, 19:47

Wiki wrote: 17 Nov 2022, 19:03 ...
No!

- ...
:lol: :lol: :lol:

To my defense I want to enter that:
- I wrote large parts of the code in P037 MQTT Import regarding JSON support, filtering and mapping
- Adding all that took staring at the code for many hours, and testing (and crashing) many times
- I really like to work on ESPEasy, learning and solving all those (C++) puzzles while I'm at it

Thanks for expressing your gratitude (also) in words, it's really appreciated :)

And please keep those requests and questions coming 8-)
/Ton

TD-er
Core team member
Posts: 6902
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Zero Solar Power Export with ESPEasy

#12 Post by TD-er » 17 Nov 2022, 21:26

Wiki wrote: 17 Nov 2022, 19:03 [...]
- opening whatever programming environment you use
[...]
Quite sure this part wasn't needed, knowing Ton ;)

Appreciate the compliments and gratitude :)

Wiki
Normal user
Posts: 404
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Zero Solar Power Export with ESPEasy

#13 Post by Wiki » 19 Nov 2022, 13:31

And just to be complete, this is, how my Domoticz room "Solaranlage" now looks like:
Unbenannt8.JPG
Unbenannt8.JPG (181.96 KiB) Viewed 179 times

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests