Emonhub refuses to start

I’ve had a emonbase and 2 x emontx’s running for a couple of years now with no issues.

I’ve now got another emontx which I’m connecting directly via serial to a raspberry pi 2. I can open /dev/ttyAMA0 with minicom and see the data feed from the emontx, so this side is working. I’ve flashed a 16gb sd card using etcher then expanded it.

It appears emonhub will not start. The log file is empty. The configue file has only had the section for the serial connection changed. When i run sudo service emonhub status this is what i get:

[email protected](ro):log$ sudo service emonhub  status
● emonhub.service - LSB: Start/stop emonHub
   Loaded: loaded (/etc/init.d/emonhub)
   Active: active (exited) since Tue 2017-11-21 12:09:27 UTC; 35min ago
  Process: 552 ExecStart=/etc/init.d/emonhub start (code=exited, status=0/SUCCESS)

Nov 21 12:09:27 emonpi sudo[698]: pam_unix(sudo:session): session closed for user root
Nov 21 12:09:27 emonpi sudo[729]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/chown -R emonhub /var/log/emonhub
Nov 21 12:09:27 emonpi sudo[729]: pam_unix(sudo:session): session opened for user root by (uid=0)
Nov 21 12:09:27 emonpi sudo[729]: pam_unix(sudo:session): session closed for user root
Nov 21 12:09:27 emonpi emonhub[552]: Starting OpenEnergyMonitor emonHub: emonhub has been started ok.
Nov 21 12:09:27 emonpi systemd[1]: Started LSB: Start/stop emonHub.
Nov 21 12:09:29 emonpi emonhub[552]: Traceback (most recent call last):
Nov 21 12:09:29 emonpi emonhub[552]: File "/usr/share/emonhub/emonhub.py", line 63, in <module>
Nov 21 12:09:29 emonpi emonhub[552]: ehi.EmonHubEmoncmsHTTPInterfacer = interfacers.EmonHubEmoncmsHTTPInterfacer.EmonHubEmoncmsHTTPInterfacer
Nov 21 12:09:29 emonpi emonhub[552]: AttributeError: 'module' object has no attribute 'EmonHubEmoncmsHTTPInterfacer'

Any ideas?

It also seems the syslog is full of nod-red errors.

So are you using the emonSD image?

If not please confirm the version of emonhub you are using.

Can you please also attach your emonhub.conf? (with any domain names or apikeys fudged)

If you have 2x emonTx’s working on an emonBase. I assume you are using a rfm2pi (or rfm69pi) which will already be using the gpio serial port (/dev/ttyAMA0) so how are you connecting the new emonTx? Have you removed the rfm2pi/rfm69pi and connected via the gpio or have you connected using a serial to usb converter?

The above question about serial connections will not be the cause of the fail to start, it says there is an issue with no module called “EmonHubEmoncmsHTTPInterfacer” which prompted the question about versions, it looks like you might possibly be using a emonpi variant emonhub.conf file with original emonhub.

Yes I’m using the emonSD image 26Oct17.

I’ve run the updater since installation.

This is a separate raspberry pi and emontx to my other setup, running in a different location.

Here’s my emonhub.conf

#######################################################################
#######################      emonhub.conf     #########################
#######################################################################
### emonHub configuration file, for info see documentation:
### 
#######################################################################
#######################    emonHub  settings    #######################
#######################################################################

[hub]
### loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL
loglevel = INFO
### Uncomment this to also send to syslog
 use_syslog = yes
#######################################################################
#######################       Interfacers       #######################
#######################################################################

[interfacers]
[[SerialTx3e]]
     Type = EmonHubTx3eInterfacer
      [[[init_settings]]]
           # Un-comment line below if using RS485 adapter
           #com_port = /dev/ttyRS485-0
           # default com port if using USB to UART adapter
           com_port= /dev/ttyAMA0
           com_baud = 115200
      [[[runtimesettings]]]
           pubchannels = ToEmonCMS,
[[MQTT]]

    Type = EmonHubMqttInterfacer
    [[[init_settings]]]
        mqtt_host = 127.0.0.1
        mqtt_port = 1883
        mqtt_user = emonpi
        mqtt_passwd = emonpimqtt2016

    [[[runtimesettings]]]
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,

        # emonhub/rx/10/values format
        # Use with emoncms Nodes module
        node_format_enable = 1
        node_format_basetopic = emonhub/

        # emon/emontx/power1 format - use with Emoncms MQTT input
        #
        nodevar_format_enable = 1
        nodevar_format_basetopic = emon/

[[emoncmsorg]]
    Type = EmonHubEmoncmsHTTPInterfacer
    [[[init_settings]]]
    [[[runtimesettings]]]
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,
        url = https://emoncms.org
        apikey = xxxxxxxxxxxxxxx
        senddata = 1                    # Enable sending data to 
        sendstatus = 1                  # Enable sending WAN IP to  MyIP >
        sendinterval= 30                # Bulk send interval to  in seconds

#######################################################################
#######################          Nodes          #######################
#######################################################################

[nodes]



[[5]]
    nodename = emonpi
    [[[rx]]]
        names = power1,power2,power1pluspower2,vrms,t1,t2,t3,t4,t5,t6,pulsecount
        datacodes = h, h, h, h, h, h, h, h, h, h, L
        scales = 1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
        units = W,W,W,V,C,C,C,C,C,C,p

[[6]]
    nodename = emontxshield
    [[[rx]]]
       names = power1, power2, power3, power4, vrms
       datacode = h
       scales = 1,1,1,1,0.01
       units =W,W,W,W,V

[[7]]
   nodename = emontx4
   [[[rx]]]
      names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
      datacodes = h,h,h,h,h,h,h,h,h,h,h,L
      scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
      units =W,W,W,W,V,C,C,C,C,C,C,p

[[8]]
    nodename = emontx3
    [[[rx]]]
       names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[9]]
   nodename = emontx2
   [[[rx]]]
      names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
      datacode = h
      scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
      units =W,W,W,W,V,C,C,C,C,C,C,p

[[10]]
    nodename = emontx1
    [[[rx]]]
       names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacode = h
       scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[11]]
    nodename = 3phase
    [[[rx]]]
       names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
       units =W,W,W,W,V,C,C,C,C,C,C,p
       
[[12]]
    nodename = 3phase2
    [[[rx]]]
       names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[13]]
    nodename = 3phase3
    [[[rx]]]
       names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[14]]
    nodename = 3phase4
    [[[rx]]]
       names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[19]]
   nodename = emonth1
   [[[rx]]]
      names = temperature, external temperature, humidity, battery
      datacode = h
      scales = 0.1,0.1,0.1,0.1
      units = C,C,%,V

[[20]]
   nodename = emonth2
   [[[rx]]]
      names = temperature, external temperature, humidity, battery
      datacode = h
      scales = 0.1,0.1,0.1,0.1
      units = C,C,%,V

[[21]]
   nodename = emonth3
   [[[rx]]]
      names = temperature, external temperature, humidity, battery
      datacode = h
      scales = 0.1,0.1,0.1,0.1
      units = C,C,%,V

[[22]]
   nodename = emonth4
   [[[rx]]]
      names = temperature, external temperature, humidity, battery
      datacode = h
      scales = 0.1,0.1,0.1,0.1
      units = C,C,%,V

[[23]]
    nodename = emonth5
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

[[24]]
    nodename = emonth6
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

[[25]]
    nodename = emonth7
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

[[26]]
    nodename = emonth8
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

I can see no reason why emonhub won’t start, the log says no module found and points to Line 63 of emonhub.py.
Are you able to ssh in and check the file is still present?

ls -la /home/pi/emonhub/src/interfacers/EmonHubEmoncmsHTTPInterfacer.py

although I can’t think of reason it shouldn’t be there. please post the response so we can see the date, owner and permissions.

Are you using emoncms.org? I see the apikey is missing, or is that just where you’ve removed it to post?

Try adding a hash “#” to comment out the “Type =” line to see if it starts

[[emoncmsorg]]
    #Type = EmonHubEmoncmsHTTPInterfacer
    [[[init_settings]]]

This will cause the emoncmsorg interfacer to not be created and test the rest of the set up.

[email protected](ro):log$ ls -la /home/pi/emonhub/src/interfacers/EmonHubEmoncmsHTTPInterfacer.py
-rw-r--r-- 1 pi pi 0 Nov 21 00:14 /home/pi/emonhub/src/interfacers/EmonHubEmoncmsHTTPInterfacer.py

I’ve removed the api key to post

I’ll try commenting out the type line …

Thanks for the help :slight_smile:

2nd thoughts that won’t work, this is happening during the first read of emonhub.py, long before it starts creating interfacers.

yes doen’t seem to have changed anything

Is is something to do with file permsions somewhere?

I flashed the image with etcher, then expanded.

This reply says the file is empty ie 0 bytes

Here is my (out of date) reply on my test emonpi

-rw-r--r-- 1 pi pi 5853 Dec 11  2016 /home/pi/emonhub/src/interfacers/EmonHubEmoncmsHTTPInterfacer.py

you can see the size is 5853 despite the date being much older.

can you go to the emonhub filder and try a git pull

cd /home/pi/emonhub
rpi-rw
git pull

i suspect it will fail can you post the result?

[email protected](ro):~$ cd /home/pi/emonhub
[email protected](ro):emonhub$ rpi-rw
Filesystem is unlocked - Write access
type ' rpi-ro ' to lock
[email protected](rw):emonhub$ git pull
error: object file .git/objects/ed/9c0867b22f7aaf157e05c98e0552231e0bf3e6 is empty
error: object file .git/objects/ed/9c0867b22f7aaf157e05c98e0552231e0bf3e6 is empty
fatal: loose object ed9c0867b22f7aaf157e05c98e0552231e0bf3e6 (stored in .git/objects/ed/9c0867b22f7aaf157e05c98e0552231e0bf3e6) is corrupt
fatal: The remote end hung up unexpectedly
[email protected](rw):emonhub$

So that’s it then

I guess I should just reflash the card and start again?

That’s up to you, there will no doubt be a way of forcing the emonhub repo to download the missing file, it’s more a question of “is this the only error?” and how much work have you put into this build?

If you could recall accidentally deleting the file contents (or even say that is a possibility) I would say definitely repair, if you are unsure and it is almost a stock image, perhaps it’s better to start again in case there are other errors?

cd /home/pi/emonhub
rpi-rw
git fetch origin
git reset --hard origin/emon-pi

should sort the repo out if you want to try it (first?)

I followed the generic emonhub install instructions, and now it starts with a log file. I can see some values now in input, so should be able to sort it out from here

Thanks for all your help.