DemandShaper bug?

Seems like after the last update the DemandShaper no longer starts. At least, now when I go to either of my 2 I see this.

I’ve check both OpenEVSE units and MQTT shows connected.

On server information Demand Shaper shows Auto Restart.

Server Information

Server Information

Services

  • emonhub :- Active Running
  • emoncms_mqtt :- Active Running
  • feedwriter :- Active Running - sleep 300s 1950 feed points pending write
  • service-runner :- Active Running
  • emonPiLCD :- Inactive Dead
  • redis-server :- Active Running
  • mosquitto :- Active Running
  • demandshaper :- Activating Auto-restart

Emoncms

Server

  • OS :- Linux 4.19.75-v7+
  • Host :- emonpi | emonpi | (192.168.1.24)
  • Date :- 2020-05-28 09:22:08 BST
  • Uptime :- 09:22:08 up 5 min, 0 users, load average: 0.09, 0.43, 0.26

Memory

  • RAM :- Used: 16.62%
    • Total :- 975.62 MB
    • Used :- 162.15 MB
    • Free :- 813.47 MB
  • Swap :- Used: 0.00%
    • Total :- 100 MB
    • Used :- 0 B
    • Free :- 100 MB
      Write Load Period

Disk

  • / :- Used: 49.33%
    • Total :- 3.92 GB
    • Used :- 1.94 GB
    • Free :- 1.79 GB
    • Write Load :- n/a
  • /boot :- Used: 20.55%
    • Total :- 252.05 MB
    • Used :- 51.79 MB
    • Free :- 200.26 MB
    • Write Load :- n/a
  • /var/opt/emoncms :- Used: 3.41%
    • Total :- 9.98 GB
    • Used :- 348.82 MB
    • Free :- 9.13 GB
    • Write Load :- n/a
  • /var/log :- Used: 99.61%
    • Total :- 50 MB
    • Used :- 49.8 MB
    • Free :- 200 KB
    • Write Load :- n/a

HTTP

  • Server :- Apache/2.4.38 (Raspbian) HTTP/1.1 CGI/1.1 80

MySQL

  • Version :- 5.5.5-10.3.17-MariaDB-0+deb10u1
  • Host :- localhost:6379 (127.0.0.1)
  • Date :- 2020-05-28 09:22:07 (UTC 01:00‌​)
  • Stats :- Uptime: 300 Threads: 15 Questions: 943 Slow queries: 0 Opens: 54 Flush tables: 1 Open tables: 48 Queries per second avg: 3.143

Redis

  • Version :-
    • Redis Server :- 5.0.3
    • PHP Redis :- 5.0.2
  • Host :- localhost:6379
  • Size :- 284 keys (845.62K)
  • Uptime :- 0 days

MQTT Server

  • Version :- Mosquitto 1.5.7
  • Host :- localhost:1883 (127.0.0.1)

PHP

  • Version :- 7.3.9-1~deb10u1 (Zend Version 3.3.9)
  • Modules :- apache2handlercalendar Core ctype curl date dom v20031129exif fileinfo filter ftp gd gettext hash iconv json v1.7.0libxml mbstring mosquitto v0.4.0mysqli mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $openssl pcre PDO pdo_mysql Phar posix readline redis v5.0.2Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter xsl Zend OPcache zlib

Pi

  • Model :- Raspberry Pi 3 Model B+ Rev 1.3 - 1GB (Sony UK)

  • Serial num. :- 3BD68E61

  • CPU Temperature :- 52.62°C

  • GPU Temperature :- 52.6°C

  • emonpiRelease :- emonSD-17Oct19

  • File-system :- read-only

Client Information

Client Information

HTTP

  • Browser :- Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
  • Language :- en-US,en;q=0.9

Window

  • Size :- 1351 x 669

Screen

  • Resolution :- 1366 x 768

try

systemctl status demandshaper.service

what does it tell you?

This repeating on the output.

Of note seems to be this.

  Process: 3114 ExecStart=/usr/bin/php /opt/emoncms/modules/demandshaper/demandshaper_run.php (code=exited, status=255/EXCEPTION)
 Main PID: 3114 (code=exited, status=255/EXCEPTION)

Instead of a screenshot, please select the text and post between 3 backticks such that

```
text
```

What I would expect is

[email protected]:~ $ systemctl status demandshaper.service
● demandshaper.service - Emoncms Demandshaper service
   Loaded: loaded (/lib/systemd/system/demandshaper.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-05-23 18:35:23 BST; 4 days ago
     Docs: https://github.com/emoncms/demandshaper/blob/master/readme.md
 Main PID: 628 (php)
    Tasks: 1 (limit: 2319)
   Memory: 5.9M
   CGroup: /system.slice/demandshaper.service
           └─628 /usr/bin/php /opt/emoncms/modules/demandshaper/demandshaper_run.php

May 23 18:35:23 emonpi systemd[1]: Started Emoncms Demandshaper service.
[email protected]:~ $

But something at the bottom suggesting why it could not start.

Try

/usr/bin/php /opt/emoncms/modules/demandshaper/demandshaper_run.php

from the command line.

You could also try restarting the service

sudo systemctl restart demandshaper.service

and then checking the logs

sudo journalctl -f -u demandshaper

Not a problem.

● demandshaper.service - Emoncms Demandshaper service
   Loaded: loaded (/lib/systemd/system/demandshaper.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2020-05-28 14:57:09 BST; 8s ago
     Docs: https://github.com/emoncms/demandshaper/blob/master/readme.md
  Process: 3188 ExecStart=/usr/bin/php /opt/emoncms/modules/demandshaper/demandshaper_run.php (code=exited, status=255/EXCEPTION)
 Main PID: 3188 (code=exited, status=255/EXCEPTION)
~
~
~
~

Out for
/usr/bin/php /opt/emoncms/modules/demandshaper/demandshaper_run.php

[email protected]:~ $ /usr/bin/php /opt/emoncms/modules/demandshaper/demandshaper_run.php
PHP Fatal error:  Uncaught ErrorException: Undefined variable: date in /opt/emoncms/modules/demandshaper/scheduler.php:213
Stack trace:
#0 /opt/emoncms/modules/demandshaper/scheduler.php(213): exceptions_error_handler(8, 'Undefined varia...', '/opt/emoncms/mo...', 213, Array)
#1 /opt/emoncms/modules/demandshaper/demandshaper_run.php(398): get_forecast(Object(Redis), 'carbonintensity', 'America/New_Yor...')
#2 {main}
  thrown in /opt/emoncms/modules/demandshaper/scheduler.php on line 213

Fatal error: Uncaught ErrorException: Undefined variable: date in /opt/emoncms/modules/demandshaper/scheduler.php:213
Stack trace:
#0 /opt/emoncms/modules/demandshaper/scheduler.php(213): exceptions_error_handler(8, 'Undefined varia...', '/opt/emoncms/mo...', 213, Array)
#1 /opt/emoncms/modules/demandshaper/demandshaper_run.php(398): get_forecast(Object(Redis), 'carbonintensity', 'America/New_Yor...')
#2 {main}
  thrown in /opt/emoncms/modules/demandshaper/scheduler.php on line 213

Finally trying to restart it.

[email protected]:~ $ sudo systemctl restart demandshaper.service
[email protected]:~ $ sudo journalctl -f -u demandshaper
-- Logs begin at Thu 2020-05-28 13:52:22 BST. --
May 28 14:59:50 emonpi demandshaper[3261]: #2 {main}
May 28 14:59:50 emonpi demandshaper[3261]:   thrown in /opt/emoncms/modules/demandshaper/scheduler.php on line 213
May 28 14:59:50 emonpi demandshaper[3261]: Fatal error: Uncaught ErrorException: Undefined variable: date in /opt/emoncms/modules/demandshaper/scheduler.php:213
May 28 14:59:50 emonpi demandshaper[3261]: Stack trace:
May 28 14:59:50 emonpi demandshaper[3261]: #0 /opt/emoncms/modules/demandshaper/scheduler.php(213): exceptions_error_handler(8, 'Undefined varia...', '/opt/emoncms/mo...', 213, Array)
May 28 14:59:50 emonpi demandshaper[3261]: #1 /opt/emoncms/modules/demandshaper/demandshaper_run.php(398): get_forecast(Object(Redis), 'carbonintensity', 'America/New_Yor...')
May 28 14:59:50 emonpi demandshaper[3261]: #2 {main}
May 28 14:59:50 emonpi demandshaper[3261]:   thrown in /opt/emoncms/modules/demandshaper/scheduler.php on line 213
May 28 14:59:50 emonpi systemd[1]: demandshaper.service: Main process exited, code=exited, status=255/EXCEPTION
May 28 14:59:50 emonpi systemd[1]: demandshaper.service: Failed with result 'exit-code'.

Ok thanks. @Gwil @TrystanLea @glyn.hudson will need to have a look. They should know where to look now.

No problem. lol. Only reason I even noticed this was I went in to see about changing the charge current for my OpenEVSE charger for summer charging.

Hello @Ryan_S I think this may have been caused by a change to the settings structure in the more recent version. It’s possible to clear this by deleting the device and recreating it - but that will delete the associated inputs and input processing as well. If that’s easy to recreate for you then that’s probably the quicker route to getting this back up and running. Otherwise I can take a look to see if I can fix the issue in the code.

Could you check if there are any javascript errors in the browser console?