Newb here, Please help Influx and Grafana

Hello all,

This works:

SELECT mean(“battery_charging_current”) FROM “mpp-solar” WHERE (“command” = ‘Inverter1’) AND timeFilter GROUP BY time(__interval) fill(null)

This too:

SELECT mean(“battery_charging_current”) FROM “mpp-solar” WHERE (“command” = ‘Inverter2’) AND timeFilter GROUP BY time(__interval) fill(null)

This odes not:

SELECT mean(“battery_charging_current”) FROM “mpp-solar” WHERE (“command” = ‘Inverter1’) AND timeFilter GROUP BY time(__interval) fill(null) + SELECT mean(“battery_charging_current”) FROM “mpp-solar” WHERE (“command” = ‘Inverter2’) AND timeFilter GROUP BY time(__interval) fill(null)

Trying to add battery charging currents from two inverters. Is it possible?

Thank you,

try this:

SELECT mean("battery_charging_current") 
FROM "mpp-solar"
WHERE ("command" = 'Inverter1' OR "command" = 'Inverter2') 
   AND timeFilter 
GROUP BY time(__interval) fill(null)

Surely that will give the mean of all charging currents, rather than the sum
of the means from the two inverters?

Suppose inverter1 gives a steady 1 Amp; inverter 2 gives a steady 4 Amps.

The sum of the means is 5 Amps, but the mean of all values is 2.5 Amps.

The multiplying factor will be two, provided you can be confident that each
inverter supplied the same number of samples during the time period.

Antony.

Ey Antony, happy aniversary!!

I think a still dont undersant what dmiic whants

LOL. I am asking question wrong, hence newb(noob)

I would like to add battery charging current data from inverters? Inverter1(battery_charging_current) + Inverter2 (battery_charging_current)

Thanks guys

If you just want to add up the total charging current, what’s wrong with:

select sum(battery_charging_current) from mpp-solar where timeFilter group by time(__interval) fill(null)

?

In other words, use sum() instead of mean(), and don’t care about inverter1 /
inverter2…

Antony.

Each inverter gives different number since they are on different solar arrays.

Thanks

I don’t understand what you are saying here.

Yes, each inverter gives different numbers - I wouldn’t expect two inverters to
have the same output as each other - but why is that a problem?

If you want the total sum of the currents, then simply add up all the sample
values, irrespective of which inverter the sample came from.

Or, if you do not want the total sum of all the currents, please express
different what you do want to calculate.

Regards,

Antony.

Thanks for your patience. I do appreciate it. Let me try explain differently.

Here is query that I wrote and it works very nice. It calculates amperes on 240V North American Standard.

SELECT last(“total_ac_output_apparent_power”) / (last(“l1_ac_output_voltage”) + last(“l2_ac_output_voltage”)) FROM “mpp-solar” WHERE (“command” = ‘Inverter1’) AND $timeFilter GROUP BY time(5s)

Data from each inverter comes from (“command” = ‘Inverter1’) or (“command” = ‘Inverter2’)

Problem is writing a query that contains two commands in it. Is that even possible?

Hopefully this defines problem little bit better. Once again thank you,

Ah.

Your use of the last() function, which I don’t believe you’ve mentioned
previously, does mean that my previous suggestions would not work.

Your first question referred to mean() and your second to sum() (or at least
you said you wanted to add the currents).

Now you say you are using last() and that does make it more difficult to add
data from different queries.

You currently (no pun intended) have the query:

SELECT last(“total_ac_output_apparent_power”) /
(last(“l1_ac_output_voltage”) + last(“l2_ac_output_voltage”))
FROM “mpp-solar”
WHERE (“command” = ‘Inverter1’)
AND $timeFilter GROUP BY time(5s)

To add the two inverter values, how about:

SELECT (SELECT last(“total_ac_output_apparent_power”) /
(last(“l1_ac_output_voltage”) + last(“l2_ac_output_voltage”))
FROM “mpp-solar”
WHERE (“command” = ‘Inverter1’)
AND $timeFilter) +
SELECT last(“total_ac_output_apparent_power”) /
(last(“l1_ac_output_voltage”) + last(“l2_ac_output_voltage”))
FROM “mpp-solar”
WHERE (“command” = ‘Inverter2’)
AND $timeFilter)
GROUP BY time(5s)

Incidentally, I thought 240V was the European / Australasian standard, and
that North America used 110V? However, I think that is incidental to the
question here.

Regards,

Antony.

Thank you. I will try.

Each American home is supplied with 240 Volts standard. All high energy devices in home like AC Hot water heater, stove/oven or clothes drier run on 240 Volts. Low energy devices like TV’s, microwaves, dish washers, toasters and such run on 120 Volts. System is called split phase.
Neighborhood transformer goes from something like 7.8 kV on primary side to 240 volts on secondary side. With secondary side also having a center tap as neutral. So:
L1 to L2 is 240
L1 to N is 120 and
L2 to N is 120

Unfortunately that did not work. So let’s start fresh. Previous posts were examples. I am aware of sum, mean and other stuff.

I have 2 inverters. Both of them are connected on to separate solar arrays and of course will provide different charging currents. So each inverter has its own set of data logs stored inside data base called “home” on Influxdb. Those data logs have same exact data point names such as battery_charging_current, pv_array_power, and so on.

Inverter1 = battery_charging_current
Inverter2 = battery_charging_current

If I am calling data points only from Inverter1 I can then divide, add, subtract or multiply those data points. It works very nice. Same goes for Inverter2.
However if I am calling data point from Inverter1 and I try to multiply it with data point from Inverter2 is when I get stuck and can’t figure out why.

Below is just an example that works just fine:

SELECT last(“total_ac_output_apparent_power”) / (last(“l1_ac_output_voltage”) + last(“l2_ac_output_voltage”)) FROM “mpp-solar” WHERE (“command” = ‘Inverter1’) AND $timeFilter GROUP BY time(5s)

As you can see I am adding and dividing just fine as long as I use either Inverter1 or Inverter2.
What can be done when I have to use data from both inverters in a single query?

Thank you and maybe this is better way of explaining the problem.