Finding X lowest values

Avatar
  • updated
  • Under review

I'm trying to put together a Task to run a pool circulation pump only on the hours when the electricity cost is the lowest. I can get the prices from nordpoolspot.com API. I end up with 24 Doubles, one for each hour of the day. But I have not managed to figure out a way to filter out the lowest values.


For instance I need to run the pump for 6 hours every day. So at every hour I need a way to check "Is this current hour one of the 6 cheapest hours for today?"


Any ideas?

Avatar
Maximilian Rauch
Quote from Rait Lotamõis

I still have not managed to find a way to achieve this, however I'm using a temporary "good enough" solution. I'm calculating the average of the days power cost and then checking to see if current hours cost is below average. If it is, it counts as one of the "safe" hours.


The only problem is, when I need to run the pump for longer than there are hours with below average costs in a given day. For that case I'm currently just logging an error message saying "The pump was asked to run for X hours, but it only ran for Y hours yesterday." To give me a heads up should this happen.

the trick is to find the highest value of the X cheepset hours and then you can check if the actual hour price is <= this price. To finde this reverence price will be a tough one.

Max

Avatar
Maximilian Rauch

This woud be an easy task with an script language or an API for custom tasks.

More advanced logic ands up quite messy with the simple generic Tasks.

Best regards Max 


Avatar
Allar Valksaare

so you want to take 24 random values and put them into a order from lowest to highest right?

Push the boundries and just do 24 x 24 min/max/average calculations :D 

But actually we need a function that takes random values and realignes them into a order from highest to lowest or other way around :) Thank you comfortclick

Avatar
Rait Lotamõis

That's ok. The reason for this question was to see if something like that is currently possible. It's not important enough for me to have you guys do custom work on it. I just enjoy pushing the boundaries of new systems and see what I can get away with :)

Avatar
ComfortClick Support

Hello,


since this is a more advance technical question and will require additional work, please create a ticked in our Comfortclick ticketing system.


To open a ticket:


  1. Login to your account on our web page http://www.comfortclick.com/ (or create an account if you don't have one).
  2. Click on your User name (upper right corner) and select Support Tickets from the drop down menu.
  3. Create a New Ticket

We'll get back to you in the shortest possible time.


Regards


Avatar
Rait Lotamõis

The prices get fetched at 00:00 every day and that is when I reset the "Hours ran today" variable for the circulation pump. So it's all a clean slate.

Avatar
ComfortClick Support
  • Under review

Hello,


do those "cheaper hours" start every day at the same time? When do you receive your prices from your API?


Regards.

Avatar
Rait Lotamõis

I still have not managed to find a way to achieve this, however I'm using a temporary "good enough" solution. I'm calculating the average of the days power cost and then checking to see if current hours cost is below average. If it is, it counts as one of the "safe" hours.


The only problem is, when I need to run the pump for longer than there are hours with below average costs in a given day. For that case I'm currently just logging an error message saying "The pump was asked to run for X hours, but it only ran for Y hours yesterday." To give me a heads up should this happen.