Measure the plug-in solar system by OpenHAB

Plug-in solar systems are changing the game for everyday energy enthusiasts. They’re easy to install, wallet-friendly, and a fantastic way to take a stand against climate change—one kilowatt at a time. If you’re ready to produce your own clean energy, a plug-in system is a brilliant first step.

But once you’ve got sunlight streaming into your sockets, you’ll probably want to know just how much energy you’re actually generating. That’s where smart monitoring comes into play.

This blog post is your step-by-step guide to tracking your solar production using openHAB, an open-source automation platform. We’ll walk you through how to measure the kilowatt output of your system so you can make the most of your renewable setup—and maybe geek out a little while you’re at it.

Measure the plug-in solar system by OpenHAB – this is how it could look like:

Measure the plug-in solar system by OpenHAB

Measure the plug-in solar system by OpenHAB

Index Of How To Measure the plug-in solar system by OpenHAB

Background

I am leveraging on:

  • A standard plug-in solar system how you can find it in Amazon, Lowe’s, Home Depot or on other places
  • A MyStrom power switch, that allows to measure the produced energy 
  • An OpenHAB installation

How To Measure the plug-in solar system by OpenHAB 

In order to get there and also have some nice charts we create items (in an items file), the sitemap (in the sitemap file), we leverage on persistence in order to have data stored and available for charts and finally on a rule (in a rule file) to ensure charts work properly.

The content for the items file:

Group gSQLBalkonkraftwerk 

Switch PlugSwitch "Plug" {channel="mystrom:mystromplug:Balkonkraftwerk:switch"}
Number:Temperature PlugTemperature "Temperature: [%.1f °C]" {channel="mystrom:mystromplug:Balkonkraftwerk:temperature"}  
Number:Power PlugPower "Power: [%.1f W]" <solar> (gSQLBalkonkraftwerk) {channel="mystrom:mystromplug:Balkonkraftwerk:power"}

Number Statistiken_PlugPower "Chart Auswahl" <solar> (gSQLBalkonkraftwerk)

Number:Energy PlugEnergyConsumedSinceLastCall "Ws: [%.1f Ws]" {channel="mystrom:mystromplug:Balkonkraftwerk:energy-consumed-since-last-call"} 
Number:Energy PlugEnergyConsumedSinceLastCall_Statistiken "Ws: [%.1f Ws]"

The content for the sitemap file:

sitemap default label="Balkonkraftwerk" {
    Text item=PlugPower icon="solar" {
        Switch item=Statistiken_PlugPower label="Stromproduktion in Watt Statistiken" mappings=[0="4h",1="12h",2="1 Tag",3="3 Tage",4="1 Woche",5="1 Monat",6="4 Monate",7="1 Jahr"]

        Chart item=PlugPower label="Stromproduktion in Watt letzte 4 Stunden"    refresh=300000 service="jdbc" period=4h  visibility=[Statistiken_PlugPower==0] legend=true
        Chart item=PlugPower label="Stromproduktion in Watt letzte 12 Stunden"   refresh=300000 service="jdbc" period=12h visibility=[Statistiken_PlugPower==1] legend=true
        Chart item=PlugPower label="Stromproduktion in Watt letzte 24 Stunden"   refresh=300000 service="jdbc" period=D   visibility=[Statistiken_PlugPower==2] legend=true
        Chart item=PlugPower label="Stromproduktion in Watt letzte 3 Tage"       refresh=300000 service="jdbc" period=3D  visibility=[Statistiken_PlugPower==3] legend=true
        Chart item=PlugPower label="Stromproduktion in Watt letzte Woche"        refresh=300000 service="jdbc" period=W   visibility=[Statistiken_PlugPower==4] legend=true
        Chart item=PlugPower label="Stromproduktion in Watt letzter Monat"       refresh=300000 service="jdbc" period=M   visibility=[Statistiken_PlugPower==5] legend=true
        Chart item=PlugPower label="Stromproduktion in Watt letzte 4 Monate"     refresh=300000 service="jdbc" period=4M  visibility=[Statistiken_PlugPower==6] legend=true
        Chart item=PlugPower label="Stromproduktion in Watt letztes Jahr"        refresh=300000 service="jdbc" period=Y   visibility=[Statistiken_PlugPower==7] legend=true
    }
}

The content for the persistence (in my case jdbc.persist):

Strategies {
    everyMinute : "0 * * * * ?"
    every15min  : "0 0/15 * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
    default = everyChange
}

Items {
    gSQLBalkonkraftwerk* : strategy = everyMinute, every15min
    Statistiken_PlugPower : strategy = everyChange, restoreOnStartup
}

And finally the Rules file:
rule "Set default chart period"
when
    System started
then
    if (Statistiken_PlugPower.state == NULL || Statistiken_PlugPower.state == UNDEF) {
        Statistiken_PlugPower.sendCommand(0)
    }
end

 

Note: you might like to change the names of the items, groups, etc. This I leave up to you, but please ensure that you change it consistently across all files, otherwise this function will not work properly. 

 

Additional Information

If you do not yet have an OpenHAB system, then you might like to leverage on this guidance: Setup a New OpenHAB

Follow me

It would be amazing if you follow my myhowto.blog. To my blog is actually easy! You can leverage on

  • Click to follow me on X
  • Bookmark this page and comeback from time to time

Help and Comments

I am really looking forward for you to contact me if for example you found a better option or other idea then in this how to. Also, please touch base if you found an error or anything not working or if you have something that you would love to be added to the myhowto.blog. Simply click this link to touch base with me.

Linking Or Recommending The How To Or The MyHowTo.blog

I would love to see you are recommending this how to or link it to your website. Also, I would love if you link or recommend the whole myhowto.blog. Please feel free to do so! In case you like to touch base regarding this topic with me, then simply click this link. I look forward!