Input on-time question

Can anyone help me to understand this feed processor better please.  I have an input feed that varies between 0 and 1.  I wish to calculate the number of hours in a day that the feed was set to 1.  The documentation says that the on-time processor is used to calculate the number of hours a pump was on each day, but it seems to be calculating the number of seconds?  Is there something I am missing please?

calypso_rae's picture

Re: Input on-time question

Is your "input feed" restricted to the values 0 and 1, or can it have in-between values such as 0.123?

Which documentation are you referring to?

Converting from seconds to hours is no problem ...

engeeaitch's picture

Re: Input on-time question

Hi - My input is either 0 or 1.  It reflects the state of the boiler (on or off).  I send an update to emoncms every 10 minutes, and whenever the state changes.

I was reading this documentation: http://emoncms.org/site/docs/inputprocessing

The documentation suggests that input on-time measures the time that the value is high (which I assume means non-zero)? I did try multiplying the input by 0.00027777 (1/3600) but it didn't seem to make any difference.

I would like to be able to have a chart that shows the number of hours each day that the boiler is switched on.

Thanks for any help.

calypso_rae's picture

Re: Input on-time question

OK, I think I now understand what you're wanting to do, but I have never made any use of emoncms. 

I feel sure that someone else will be able to help ...

Robert Wall's picture

Re: Input on-time question

I've just been looking at it, and it seems that the "input on-time" process doesn't behave the same way as the rest, i.e. it leaves its input available to the next process rather than making its output available. I've changed line 426 in process_model.php to "return $ontime;"

 

In Inputs, I have:

 

and in Feeds, I get this:

 

I don't know why it was done that way, maybe Trystan had good reason or maybe it was just that this situation was not envisaged. In fairness, the documentation doesn't say "Result is passed back for further processing by the next processor in the input processing list." so the original behaviour is technically correct.

[N.B. Changed only in my local copy! ]

engeeaitch's picture

Re: Input on-time question

Hi - many thanks for your suggestion.  I have now looked at process_model.php, and have a better idea of what is going on.  I made the change you suggested (to line 446 in the latest version).

However, I think that there is a problem with the logic (ignoring that it measures the time in seconds), but I can't see an obvious solution.  I will try to explain with an example:

17:00  Boiler is off.   on-time = 0

17:10 Boiler is off.  on-time = 0

17:18 Boiler is on.  on-time = 8*60 seconds

17:19 Boiler is off.  on-time = 8*60 seconds

So even though the boiler is only on for one minute, the input processor calculates this as 8 minutes.  I think the logic needs to know the last input value, (rather than the current input value) but I can't see a way to easily get this.  Any ideas?

Robert Wall's picture

Re: Input on-time question

I think your problem is it was assumed that updates were frequent compared to the duration of the on and off times, so that the error would even out. This could still happen if you didn't send the state when a switching event occurred and the error would average out over time.

The obvious easy way around this is, when the boiler changes state, to send the transition, i.e. if going from off to on, send "0" then immediately afterwards send "1" - and vice versa.

If you can't or don't want to do that, then I think you need to have the last state stored in the database (as a static variable inside the PHP script isn't good enough).

Paul Reed's picture

Re: Input on-time question

I think that you would have to add code to /Modules/input/process_model.php to do this calculation, possibly using 'convert kwh to kwh/d' as a template to determine the daily time that the value is set to '1'.

This would create a MySQL DAILY table to hold the accumulated data  - as Robert described above.

If you add a new section in the process_model.php file, you will also need to create a corresponding entry in Lib/tablejs/custom-table-fields.js

Paul

engeeaitch's picture

Re: Input on-time question

Hi - thanks for the suggestions.

I think I have a workaround for the two problems:

To get round the problem of the error when switching from on to off (and vice-versa), I have used Robert's suggestion and amended my code so that when I switch from on to off, I first send an on, then an off.  Similarly, when I switch from off to on, I first send an off, then an on.

Rather than use Input on-time, I have now multiplied my input (which is either 0 or 1) by 1000, and then used Power to kWhd which luckily gives the answer that I want (i.e. the number of hours in the day that the boiler is on for).

Thanks for the helpful suggestions.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.