Emoncms - only store value in database every 30 second

I am trying to reduce the interval for storing 5 temperatures from an emomtx witch is sending power and temperature every 3 second to my emonbase a raspberry pi running on an iscsi drive.

I have tried to modify the process_model.php in the emoncms/modules/input folder.

I made an copy of the log to feed function  and created a entry in the $list
– and altered to:

$list[31]=array(
_(”Log to feed 30 sec”),
ProcessArg::FEEDID,
”log_to_feed_30sec”,
1,
DataType::REALTIME
);

public function log_to_feed_30sec($id,$time,$value)
{
//Get last value
$last=$this->feed->get_timevalue($id);
$last_time=strotime($last['time']);
$last_value=$last['value']);

$time_elapsed=($time-$last_time);
$temp_diff= abs($value-$last_value);

if ($time_elapsed > 30 && $temp_diff > 0.1)
{
$this->feed->insert_data($id,$time,$time,$value);
return $value;
}
}

Then i create a feed to the input using the new function

But i'am not getting the result i want.

The feed is stored in the mysql database without regard to the conditions i set.

Why?

When is the value stored in the database – i think it is the

public function log_to_feed($id,$time,$value)
{
$this->feed->insert_data($id,$time,$time,$value);
return $value;
}

– but am i wrong?

Kasper Wohlert

TrystanLea's picture

Re: Emoncms - only store value in database every 30 second

Hello Kasper, that looks ok, your right that it is the $this->feed->insert_data($id,$time,$time,$value); call that does the writting. Did you reset the raspberrypi_run.php script inbetween changes?

Comment viewing options

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