Emoncms: installation on a shared host linux

Hello 

After running OpenEnergyMonitor from emoncms.org for a couple of weeks, I decided to "try" a shared host running linux.

I downloaded the v8.5mergeXT branch from GitHub.
I updated the settings.php file and disabled redis (not supported on that server), and fixed a couple of bugs as I moved along. So far so good.

I have one problem with the TimeZone. I know it's not new in this forum.
The message:

Call to a member function setTimezone() on a non-object
in MyHOME_HERE/emoncms/Modules/input/process_model.php on line 669

I set the Timezone on Emoncms account and in the PHP Settings of that server (date.timezone="Europe/Zurich").
Obviously, I don't have access to the php.ini file directly but I can do it through the web interface of the provider.

My problem:
As soon as I add the PHPTIMESERIES engine to any of the feeds, I get the above message and there is no update anymore.

In the Feeds column "Updated", there is a "NaNs ago" string but this has always been like that for any feeds until now. It's fine on the Inputs page.

Can someone help?

Thanks for your support

Walter

daturach's picture

Re: Emoncms: installation on a shared host linux

I think I have to live with that for the time being

I am a bit puzzled with the redis server. I read in this forum that we have to install it while other members say we don't have.

What are the consequences of not having it? 

Thanks

Walter

daturach's picture

Re: Emoncms: installation on a shared host linux

In the meantime, I found out the Chaveiro's sources (v8.5.1 XT) on Github and just installed them.

The "NaNs ago" disappeared and have been replaced by numbers.  Good

It still remains the message about the setTimezone() error when PHPTIMESERIES are defined.

Thanks

Walter

Eric_AMANN's picture

Re: Emoncms: installation on a shared host linux

Hi,

In the meantime, I experienced exactly the issue on my shared host linux (OVH). Also solved by installing the 8.5.1 XT branch.

I also can't install redis and that's problematic because some processes can't work without it. In particular "wh accumulator" and "kwh_to_power".  As I really need these processes, I'm modifying some files to make them work.

I will submit these modifications when fully tested.

Eric

ChrisBirkett's picture

Re: Emoncms: installation on a shared host linux

Hey Eric, I'm facing the same thing here. Did you submit your patch?

chaveiro's picture

Re: Emoncms: installation on a shared host linux

Last stable version is 8.5.2, try that:

https://github.com/emoncms/emoncms/archive/8.5.2.zip

 

Eric_AMANN's picture

Re: Emoncms: installation on a shared host linux

Hello,

Sorry for the late answer. Just back from long holidays.

Chris, do you still need my modified files to make "wh accumulator" and "kwh_to_power" work without Redis ? It works fine but it breaks the way process list is working, so it's not very clean.

Chaveiro, will Redis be required with the last emonCMS version ?

Eric

ChrisBirkett's picture

Re: Emoncms: installation on a shared host linux

Cheers for the reply Eric - I'd be interested to see the changes but did end up installing Redis.

Eric_AMANN's picture

Re: Emoncms: installation on a shared host linux

Hi,

Before updating an input value/time, I store the old value/time in mySql. In that way, I can calculate the difference between to consecutive input to make Wh_acc and Kwh_to_power works . 

The code is dirty but it works ... Some pieces of code bellow.

How did you manage to install redis on a share host linux ?

Eric

 

 

 

 

 public function wh_accumulator($feedid, $time, $value)
    {
        //WARNING : DOES NOT WORK AS OTHERS PROCESS.
        //$value is not used, only the input values and time are used
        // --> other processes before that one are not taken into account
        //       (except the calibration process 'x')
        //make sure the input is Wh and not kWh or anything else
        //this assumes that wh are always increasing or decreasing

        global $session;

      $usercampagneid = $session['userid'];
        $abo = 36;

        // identiying the input id
        $result = $this->mysqli->query("SELECT * FROM input WHERE processList LIKE '%34:$feedid%'");
        $row = $result->fetch_array();
        $inputid = $row['id'];  // check needed ? (that one and only one row exists)

        //setting max_power
        if ($row['description']=="Wh1" || $row['description']=="Wh2"  || $row['description']=="Wh3" )
            $max_power = 23500000*1.25; //allow 25% more
        else if ($row['description']=="Wh4")
            $max_power = 4500*1.25; //allow 25% more
        else
            $max_power = $abo*1000*1.25; //allow 25% more
    
        // getting the calibration factor
        $processes = explode(",",$row['processList']);
        $firstprocess = explode(":",$processes[0]);
        if ($firstprocess[0]==2)
            $calibfactor = $firstprocess[1];
        else
            $calibfactor = 1;

        $totalwh = $this->feed->get_timevalue($feedid)['value'];

        $Whinc = $calibfactor*($this->input->get_last_value($inputid)-$this->input->get_old_value($inputid));
    
        $timeelapsed = $this->input->get_last_Utime($inputid)-$this->input->get_old_Utime($inputid);

        //if Wh increments and time elapsed > 0 and power < max_power then
        if ( (($Whinc>0  && $totalwh>=0) || ($Whinc<0  && $totalwh<=0)) && $timeelapsed>0 ){
            $abspower = abs($Whinc * 3600 / $timeelapsed);
            if ($abspower<$max_power)
                $totalwh +=  $Whinc;

        }
    
        $padding_mode = "join";
        $this->feed->insert_data_padding_mode($feedid, $time, $time, $totalwh, $padding_mode);
                 
       return $totalwh;
    }

 

 

public function kwh_to_power($feedid,$time,$value)
    {
        //WARNING : DOES NOT WORK AS OTHERS PROCESS.
        //$value is not used, only the input values and time are used
        // --> other processes before that one are not taken into account
        //       (except the calibration process 'x')
        //make sure the input is Wh and not kWh or anything else
        //This assumes that Wh are increasing (because coming from a pulse sensor)

        global $session;

      $usercampagneid = $session['userid'];      
        $abo = 36;

        $max_power = $abo*1000*1.25; //allow 25% more
        $maxtime=120; //2min

        // identiying the input id
        $result = $this->mysqli->query("SELECT * FROM input WHERE processList LIKE '%21:$feedid%'");
        $row = $result->fetch_array();
        $inputid = $row['id'];  // check needed ? (that one and only one row exists)

        // getting the calibration factor
        $processes = explode(",",$row['processList']);
        $firstprocess = explode(":",$processes[0]);
        if ($firstprocess[0]==2)
            $calibfactor = $firstprocess[1];
        else
            $calibfactor = 1;
    
        $Whinc = $calibfactor*($this->input->get_last_value($inputid)-$this->input->get_old_value($inputid));
        $timeelapsed = $this->input->get_last_Utime($inputid)-$this->input->get_old_Utime($inputid);

        //if Wh increment is positive and 0 < time elapsed < maxtime, update the power feed
        if ($Whinc>=0 && $timeelapsed>0 && $timeelapsed<$maxtime){
            $power =  $Whinc * 3600 / $timeelapsed;
            if ($power<$max_power)
                $this->feed->insert_data($feedid, $time, $time, $power);
           else
                $power = null;
        }
        else
            $power = null;

        return $power;
    }

 

ChrisBirkett's picture

Re: Emoncms: installation on a shared host linux

Nice one. It's my own VPS actually but it was under-spec'd and I was keen to avoid installing yet another service. I did cough up for an extra 512MB RAM in the end but may revert back once I've looked through the changes in detail. Thanks a lot!

daturach's picture

Re: Emoncms: installation on a shared host linux

Thanks for the script.

I was doing a few tests with emoncms.org, passing data through URLs as described in http://emoncms.org/input/api

Something caught my attention. The server is running on PHP 5.3.10 (X-Powered-By:  PHP/5.3.10-1ubuntu3.16).

A few days ago, my Linux Host provider informed me they will move to PHP 5.6,  sometimes next year.

Is EmonCMS 9.0 ready for this version?

Thanks

Eric_AMANN's picture

Re: Emoncms: installation on a shared host linux

Chris,

The piece of code above is just an example to show how I implemented Wh_accumulator and Kwh_to_power without reddis.

To make these processes work on your server, you must modify many files (input_contoller.php, input_model.php, process_model.php, ...) and you must also create some columns in MySQL.

I'm not sure it's a good idea to make those modifications because it will be difficult to maintain your server in the future. I made it on my own server because I had an urgent need. Anyway, let me know if you need a complete guide.

Eric

Comment viewing options

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