[SOLVED] Adding two data from two solar panels together

We have a two installation of solar that I would like to see the total together.

In the update status of both, I want to do a calculation of both to another number

rule “Total Day update time”
Item Patronus_Day_Energy received update
postUpdate(Solar_Day_Energy, Patronus_Day_Energy+3)

I get a message that Patronus_Day_Energy is null

An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null

postUpdate(Solar_Day_Energy, 2+3)

so I know it’s about Patronus_Day_Energy, which I find strange as it’s in an update rule for Patronus_Day_Energy
And I see that that number is not null.

so I assume it’s something else.

I also tried


that says also it’s null.

Definition of Patronus_Day_Energy is Number

If that is an Item, it is most likely its state you are interested in.
But note that itself is a state object; even if that is a Number type Item, it is not exactly a number. You may need to cast it to do arithmetic with it.
(Patronus_Day_Energy.state as Number)

If it’s a quantity type (with units) or its a string type, there will be more work to do.

Trying that out.
What do you mean with "quantity type (with units) " ?
How can I check this?

It’s your Item. How did you define it?
Number is a number type.
But Number:Temperature for example is a quantity type - you cannot add 3, but you could add 3 degrees.

Thanks, that is clear.

As I wrote

Definition of Patronus_Day_Energy is Number
Same is for Solar_Day_Energy

It’s working now.

Ag I was to fast. It works with just adding 5

So the next step was adding the other number from the other solar panel.

And the definition from the other solar is indeed Number:Energy

When I make it Number in the Item defintion.
it gives me 33600 instead of 3.36

I did not manage to turn 33600 to show as 3.36

So my current solution is to load the info into two variables,

One as 33600 that I can do calculations with so I end the correct total
And one I can show, to show the detail in my sitemap.
Not really good.

So I have now two questions:

What is the way to work with Number:Energy and do the calculation
(Probably the bet way)

Or how can I work with Number and then visualize the 33600 as 3,36
(yet then how I get that into grafana correct as 3,36)

Okay, so you have apples and oranges to work with.
I’m not that familiar with doing maths with Quantity Types.

Ideally, you’d work with the QuantityType - it auto deals with units, so whether you start out with 2kW or 2000W and add 50W, the end result is the “same”.

So, if you have the number 3, but you know that represents 3kW, can you load it into a QuantityType variable?
I think this may be as simple as
var myEnergyVariable = new QuantityType (myNumberVariable | “kW”)

Some clues

If you’ve sorted your rule and Items matching, can you post your solution?

Practical examples even just for adding Quantity Types and “normals” are few and far between.

I haven’t yet.
yet I think this will help me figuring this out.

Unfortunately I can only program that during sun hours, so it needs to in a weekend.
Were I usually work on our configuration in the evening

1 Like