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?
SELECT mean("battery_charging_current")
FROM "mpp-solar"
WHERE ("command" = 'Inverter1' OR "command" = 'Inverter2')
AND timeFilter
GROUP BY time(__interval) fill(null)
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,
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.
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.
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.