Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • Announcements

    • Lizzy Trickster

      Latest Stable OpenComputers Version   11/26/16

      The latest released version of OpenComputers is version 1.7.2 for MC 1.7.10, 1.10.2, 1.11.2 & 1.12.2. See more information here! Beta/Dev builds can be found at the Jenkins Build Server (ci.cil.li)
  • 0

Output of Energy storage


Hi there!

I was writing a program which monitors total energy consumption in period of time and I found a problem... None of Energy storages in our modpack (Energy Cell from TE, Capacitor Cell from EnderIO and Energy Cube from Mekanism) isn't sending data about actual energy output, so I've got stuck in my code.

Has anybody a solution to my problem?



Share this post

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0


I hope I interpreted your question correctly. You want to monitor how much energy your base actually consumes, the rf/t that leaves your energy storage device and not the relative difference between input and output, right?

I did some testing and I came up with a solution that give you exactly that, the rf/t output of the storage device (used TE energy cell), now matter how much you input. This will stop the output of the cell for a limited amount of time tho (this is needed to do the calculation), so it's best to put a small energy storage device between the actual energy storage where you do the monitoring and your grid feeding your machines.

Basically what I do is the following:

1. measure the relative energy difference in the device for a given period of time, divided by the amount of ticks waited --> the DIFFERENCE between input and output ( in rf/t)

2. disable the energy output of the device by applying a Redstone signal

3. measure the energy difference again and reenabling the output again (again divided by amount of ticks) --> the TOTAL input (in rf/t)

4. getting the difference between total input and relative change in rf --> the output (in rf/t)

local component = require'component'
local energyCell = component.energy_device
local rs = component.redstone
local side = 4      -- # side where your energy storage device is (relative to redstone i/o)
local wait = .5     -- # time waiting between checking the energy level

function getOutput()
  local init_rf = energyCell.getEnergyStored()  -- # rf base level
  local rel_rf = (energyCell.getEnergyStored() - init_rf) / (wait + .05)  / 20 -- # rf difference
  rs.setOutput(side, 15)
  init_rf = energyCell.getEnergyStored()
  local tot_rf_in = (energyCell.getEnergyStored() - init_rf) / (wait + .05)  / 20  -- # total rf input
  rs.setOutput(side, 0)
  local tot_rf_out = tot_rf_in - rel_rf  -- # total rf output
  return tot_rf_out

-- # apparently it takes one tick to read the rf level in the device, that's why I added .05 seconds
-- # to the time waited in the rf/t calculations
-- # the rf/t values are 100% correct, at least for TE energy cell

you have to set the Redstone behavior to disable output when a Redstone signal is applied

Share this post

Link to post
Share on other sites
  • 0

Hey there! 

Yes, your interpretation is correct. In fact, I've got similar idea. But this solution is not very suitable because it's too much complicated. 

I want to monitor this energy consumption on our server at each user in the town. It'll be not very practical, if I had to build and configure this system 50 or more times. 

Yes, if it'll be a best solution and there will be not a straight way of reading I/O, I'll have to do it. 

I was just surprised that reading I/O is possible for reactors, generators, dynamos etc., but not for energy storages. 

Thanks for help, 


Share this post

Link to post
Share on other sites
  • 0

Ok, so how is your town‘s energy supply set up? Do you have central power generation and then transfer the energy to each base?

If that‘s the case I might have a different approach that would make the setup smaller and more practical.

Share this post

Link to post
Share on other sites
  • 0

Exactly, I have main energy storage (from Draconic Evolution) and then there are cable distribution under the road.

So, what is your more practical solution?

Share this post

Link to post
Share on other sites
  • 0

Well, more practical might be not the best way to put it, but it'll reduce the amount of components you need to hook up to your computer, so reading the energy consumption of a few energy cells or of hundreds doesn't really make a difference. But you need a central place to set this system up and each energy connection cannot connect with others from this point on. It also might require some more coding than using that simple approach.


Basically you have an array of 2 energy cells for each base. The robot will move back and forth placing down the adapter and applying the Redstone signal to toggle the input for a second. Then it will remove the adapter again and moves to the next position. The computer then can read the energy consumption of each energy cell. Of cause this system is kinda complicated and might take some time to be set up, but it would be easy to extend that system. Biggest downside is all the energy lines cannot be interconnected after that point. You would need to run individual power lines to each base or use some means of wireless power transportation. Even though being somewhat strange looking and not that resource efficient in terms of energy cells/ cabling required it's certainly the most "practical" way I can come up with to solve your issue.

Share this post

Link to post
Share on other sites
  • 0

Thanks for an idea. Maybe in the future, I'll use it. But I've figured out the probably simpliest solution.

Basically, at each plot, there'll be a small storage of energy, which I'll have to check each week and via OC measure consumed energy. After measure, I'll charge storage, which owner of the plot will be using for another week...

It's not a central controlled system, but that could be easily done. The most impotrtant thing is, that this is simple. And as once one smart man said; "There is beauty in simplicity."

Anyway, thanks for the help. Really appreciate it.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now