Flukso To Pvoutput - (bypassing the flukso server) - Script Discussion

All the important stuff is at this link - GitHub - B-Mqn/FluksoToPvoutput: Send Flukso data to Pvoutout

Hey guys took me ages to get this going. I added alot of extra features from what I was going to do but I think they were needed as I found out when applying this to my parents system.

follow the link, follow the readme and see how you go.
I created the readme, and then followed it to apply the script to my parents PI and everything worked as should so I feel like it wont be too hard to implement.

This is still very untested and I don’t actually know a bar of python code but its there and its working.
if you have any issues, post them here and we can try and work through them.

Let me know how you go! I’m very interested to see how many people are using it and if it all goes well.

I thought i was ready to release over 12 hours ago but after testing on my parents system I noticed an issue handling multiple sensors

EDIT: This now allows for gauge and counter sensor types
bare in mind this is only setup to use the /gauge/ side of the sensors so probably wont work for water/gas etc as i think they use the /counter/ side (yes I have water meters that run through this flukso too but wasn’t a priority)

Edit: New Script Uploaded!
I also have a new script on the way… I ended up creating one for the counter part of the sensor
to do my water usage.
and that seemed to work ok so then combined them together… testing stage atm. I do have an issue trying to use counter for power sensors (wh). but the gauge side works and does what’s required anyway so not too stressed.
rules seems to work as expected. I think I had a few little issues with the rules in the current script.
also some more features like aligning it to the 5 minute hourly so you can see the updates soon after the time changes xx:00, xx:05, xx:10,xx:15, etc rather than 5 minute interval that could be at xx:07 or xx:08 etc.

V3.1 and v3.2 are up.

3.1 located in the patch-1 branch
has rules working properly and fixed backlog data

3.2 located in the patch-2 branch
has added net metering. Currently untested


Since the flukso site came back online I didn’t bother doing any more but the data still doesn’t seem to be getting updated. So have started work on the counter side as a seperate script and hopefully combine them when all is good.

Seems to be working OK at the moment with my testing

Hi B-Man,

I am over the moon, I followed your instructions and I am now running your Phython script on a RasberryPi 4, it WORKS !!!.

I have a question, in your section where you define the custom rules,
how would you add a rule that changes V2 based on it’s value, see below.

if V2 < 50
V2 = 0

Thanks again for sharing your solution and putting in so much time to develop your idea and script, I really appreciate it.


I have noticed a few rule issues so it might not work.

I’m trying to combine the counter and gauge scripts together now but hit a few road blocks…
ill try and sort that out and then fix the rules and upload the new script to replace.

try this and see if it works… the rules seem backwards to how pvoutput would do it and also how i would deem an excel/vba code would work. I don’t use python at all so not sure if its just the way python does things or not…

"v2": "0 if v2 > 50 else v2",

Good morning.
I cannot, after having had problems with Flukso but now solved, apply the rules for solar production and consumption.
The rules have always been these: “if(power < 74) power = 0; else if(power >= 74) power -= 74; power *= 0.98” but now it no longer brings me zero power.


rules work differently to pvoutput as power isn’t assigned to anything…
im going to assume power is v4?

The rules have always been these: “if(power < 74) power = 0; else if(power >= 74) power-= 74; power *= 0.98” but now it no longer brings me zero power.

custom rules would be something like this, I don’t know if you want to check its greater than 74 first or times it by 0.98 first… the top rule gets actioned first

Edit. just looked at the pvoutput help for rules. power seems to be all power values so the code might need to be copied and repeated for v2 (solar) aswell.

"v4": "0 if v4 < 74 else v4 - 74",
"v4": "v4 * 0.98",
1 Like

This does not work:

“v2”: “0 if v2 < 50 else v2”,

This works:

“v2”: “v2 - 50”,

I will keep trying to get the if statement to work within the CUSTOM_RULES

I aprreciate your feed back.

The scripts are now working great, I have taken the next step and created two services for my two flukso units and all is working well.

Thanks Again

Your rule just minuses 50 off of the value…
I thought you were wanting it round it down to 0 if less than 50?

I don’t know how that version of the script handles rules.
I have done alot of changes since releasing it. And added a debug log file so I can see what the rules are doing properly now.

I did notice after I released it there were a few rule issues so possibly can’t handle if statements in the rules.

The new version in testing works how I sent it to you.
I will upload it to github when it’s done atleast 24 hrs straight without issues and I work out how to utilise github properly.

Although have noticed the align to 5 min intervals keeps slipping by about 1.25 seconds every 5 min interval

Yes I do want to round it down to 0 using the “IF” statement, the -50 was just a test to show other mathmatical operations work.

I suspect the scripting does not support the IF statment in the area I am trying to use it. I will continue testing to see if I can get the IF statement to work and let you know if I have any success.

Your updated script sounds interresting, so will look out for it when you release it.

Over all I am still very happy how this solution is working, this extra effort is just fine tunning to make it even better.


A bit of background:

This is an overview of my power monitoring setup. I have a Grid Connected PV system in addition to an Off Grid system, I an using a Flukso V2 on the Grid coonect system and a Flukso V3 on the Off Grid system. I may reverse these if I cannot get the IF statement to work in the pythom script for the V2 Flukso. The V3 Flukso can detect the direction of power flow so the IF statment is not required in its script.


sounds like I need a v3 flukso as I need a device that can detect the flow of power! its been doing my head in trying to create a net value using the inverter and consumption and align them etc etc…

ps. love how organised your documentation is for everything!

Thank you.
What I am saying is that it has always worked in pvoutput, pvoutput ‘does not know’ that we have changed the way we send data.

pvoutput knew it was receiving it via api so handles it differently… @bankstownbloke might be able to assist if it should still deal with it correctly or not?

Updated new version - GitHub - B-Mqn/FluksoToPvoutput: Send Flukso data to Pvoutout
This runs a new name and files so will need to follow the readme section from “How to Install” step 6 and down. If not running the script currently just start from the start.

  • Fixed rules and allowed more options with allowing IF rules (@cwjames & @ciarly)
  • Aligned with 5 min hourly intervals
  • Added gauge and counter sensor types so water/gas should work aswell now
  • And lots of bugfixes.

Old version is under V1 Branch if something does go wrong and want to go back to the other version… don’t forget to disable/remove the previous services.

If the other version is running fine then no real need to update.

Let me know how you go!

I updated my two python scripts (Flukso V2 & Flukso V3) to your latest version above.

I really like the feature you added to provide the Debug Log File, it makes fault finding so much better as you can see what’s going on, well done !

I have had mixed results with the IF statements;

The rule below works as you can see from the debug file below.

# Add more rules as needed, (values update after each rule so you can use an updated value from one rule for the next rule) (the rules run from top to bottom).
“v4”: “v4 + v2 if v2 < 50 else v4”,
“v2”: “0 if v2 < 50 else v2”,

2024-06-11 18:50:00 - Initial payload: {‘d’: ‘20240611’, ‘t’: ‘18:50’, ‘v1’: 0, ‘v2’: 45, ‘v3’: 0, ‘v4’: 1394, ‘v5’: 0, ‘v6’: 0, ‘v7’: 0, ‘v8’: 0, ‘v9’: 0, ‘v10’: 0, ‘v11’: 0, ‘v12’: 0}
2024-06-11 18:50:00 - Adjusted payload: {‘d’: ‘20240611’, ‘t’: ‘18:50’, ‘v1’: 0, ‘v2’: 0, ‘v3’: 0, ‘v4’: 1439, ‘v5’: 0, ‘v6’: 0, ‘v7’: 0, ‘v8’: 0, ‘v9’: 0, ‘v10’: 0, ‘v11’: 0, ‘v12’: 0}
2024-06-11 18:50:01 - Sent data to PVOutput: 200 OK 200: Added Status
2024-06-11 18:50:01 - Payload: {‘d’: ‘20240611’, ‘t’: ‘18:50’, ‘v2’: 0, ‘v4’: 1439}

However if I add a second rule to v2 & v4, no matter what order I place them I get mixed results with the IF statements
“v4”: “v4 * 0.84”,
“v2”: “v2 * 0.84”,
The scripts appears not to do two operations on either v2 or v4.

I even tried combining the operations in the one statement like below, just on the else side
“v4”: “v4 + v2 if v2 < 50 else v4 * 0.84”,
“v2”: “0 if v2 < 50 else v2 * 0.84”,
but no joy.

Will continue trying to see if I can get the second operation to work.

In short I like your second script, if I cant reduce the value, I can always change the config in the Flukso version 2 to lower it’s v2 & v4 values by lowering the NOMINAL voltage, will check that option out as well.

Thanks Again - The script is GREAT !!

thanks for some trouble shooting.

I did try every which way to change rules and they all seemed to work… and it should update them so applying another rule should apply it over the top again… will look into it i must have missed this…

if you aren’t using the extended data values could you assign v2 to say v12 instead at the sensor
and then

“v12”: “v12 * 0.84”,
“v2”: “0 if v12 < 50 else v12”,

or vice versa and see if that works just to get you out of trouble?

i know these rules all work as expected

 "v8": "v7 + 100",			#assuming v7 = 0 then v8 = 100
 "v9": "v8 + 100", 			#v8 = 100 from above rule so v9 = 200
 "v10": "v9 + 100",         # 300
 "v11": "v10 + 100",       # 400
 "v12": "v11 + 100",       # 500

and I thought this set of rules worked too maybe the second one worked and I didnt realise the top one hadn’t applied…

 "v4": "v4 * 0.75",
 "v4": "0 if v4 < 50 else v4",

this rule worked for me… took me some adjusting to get it to actually do both sides of it as turning my light switch on was only about 20w so that was the easiest thing to flip and check but with other things like fridge etc turning on or off i was always a fraction out :roll_eyes:

"v4": "0 if v4 < 466 else v4 * 0.5",

so would this work for you?
“v4”: “(v4 * 0.84) + v2 if v2 < 50 else v4 * 0.84”, # (might need brackets)?
“v4”: “v4 * 0.84 + v2 if v2 < 50 else v4 * 0.84”,
“v2”: “0 if v2 < 50 else v2 * 0.84”,

it combines it into one rule…

seems that double rules for double values doesn’t work… will need to look into that

Thanks you have given me some ideas to try - I will let you jnow how I go.

This works, (added the brackets on the left of the IF, have to verify the else is ok when the sun comes up tomorrow.

# Add more rules as needed, (values update after each rule so you can use an updated value from one rule for the next rule) (the rules run from top to bottom).
“v11”: “v11 * 0.84”,
“v12”: “v12 * 0.84”,
“v4”: “(v11 + v12) if v2 < 50 else v12”,
“v2”: “0 if v2 < 50 else v11”,

2024-06-11 21:20:00 - Initial payload: {‘d’: ‘20240611’, ‘t’: ‘21:20’, ‘v1’: 0, ‘v2’: 45, ‘v3’: 0, ‘v4’: 777, ‘v5’: 0, ‘v6’: 0, ‘v7’: 0, ‘v8’: 0, ‘v9’: 0, ‘v10’: 0, ‘v11’: 45, ‘v12’: 777}
2024-06-11 21:20:00 - Adjusted payload: {‘d’: ‘20240611’, ‘t’: ‘21:20’, ‘v1’: 0, ‘v2’: 0, ‘v3’: 0, ‘v4’: 690.4799999999999, ‘v5’: 0, ‘v6’: 0, ‘v7’: 0, ‘v8’: 0, ‘v9’: 0, ‘v10’: 0, ‘v11’: 37.8, ‘v12’: 652.68}
2024-06-11 21:20:01 - Sent data to PVOutput: 200 OK 200: Added Status
2024-06-11 21:20:01 - Payload: {‘d’: ‘20240611’, ‘t’: ‘21:20’, ‘v2’: 0, ‘v4’: 690.4799999999999, ‘v11’: 37.8, ‘v12’: 652.68}

Now that I know the brackets my be required on complex expression to the left of the IF, will try simplifying the script not using v11 & v12, althou there are some advantages in doing so.

Thanks Again - slowly getting there…

I don’t think the brackets are solving the issue but will definately need to test all options.
I have a similar issue and wondered why something didn’t work. It’s the same as your system with 2x v4 rules.