Emoncms and emonhub on Debian VM or Container

Hello again.

I have had better luck with making user pi and installing from that account.

Again, basic emoncms install was error-free. I left the line install_emonhub=true just hoping that even if it does not get installed, the entries for it to appear in emoncms would be ready.

Installing emonhub using the script these errors occurred:

Defaulting to user installation because normal site-packages is not writeable
Collecting paho-mqtt
  Downloading paho-mqtt-1.6.1.tar.gz (99 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 99.4/99.4 KB 2.7 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting requests
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 KB 27.6 MB/s eta 0:00:00
Collecting pybluez
  Downloading PyBluez-0.23.tar.gz (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.6/97.6 KB 16.2 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in PyBluez setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Defaulting to user installation because normal site-packages is not writeable

I “solved” it (maybe) by apt install python3-requests python3-paho-mqtt

Then the systemd issue is solved by changing these:

Requires=rsyslog.service
After=network.target

plus the obligatory sudo systemctl daemon-reload.

Then emonhub will start! And, after adding user pi to the group dialout on the guest CT, and some fiddling with /dev/ttyUSB0 on Proxmox host ( chown 100000:100020 /dev/ttyUSB0 ), and modifying the CT config file on the Proxmox host to end with

lxc.cgroup2.devices.allow: c 188:00 rwm
lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file

and restarting it of course. YMMV, but this is working for my set up.

Notably, the entry for emonhub does NOT appear in emoncms webconfig settings. I’m not sure if that is expected or not. So I modified the emonhub config file commenting out things I don’t use and adding my emonTx4 with USB connection as directed:

[interfacers]
### Manually added for the emonTx4 unit
[[USB]]
    Type = EmonHubOEMInterfacer
    [[[init_settings]]]
        com_port = /dev/ttyUSB0
        com_baud = 115200
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,
        nodename = emonTx4

when I tail the emonhub.log I see what looks like correct functionality:

2023-08-24 12:44:37,155 DEBUG    USB        Report 248  AC present V1 = 240.61 V2 = 0.00 V3 = 0.00 f=50.02
2023-08-24 12:44:37,357 DEBUG    USB        Ch 1 I=0.048 W=0 VA=11 Wh=0 pf=0.0087
2023-08-24 12:44:37,458 DEBUG    USB        Ch 2 I=0.045 W=0 VA=11 Wh=0 pf=-0.0658
2023-08-24 12:44:37,559 DEBUG    USB        Ch 3 I=0.023 W=0 VA=5 Wh=0 pf=-0.0418
2023-08-24 12:44:37,660 DEBUG    USB        Ch 4 I=0.022 W=0 VA=5 Wh=0 pf=-0.0647
2023-08-24 12:44:37,762 DEBUG    USB        Ch 5 I=0.022 W=0 VA=5 Wh=0 pf=-0.0074
2023-08-24 12:44:37,863 DEBUG    USB        Ch 6 I=0.009 W=0 VA=2 Wh=0 pf=-0.0083
2023-08-24 12:44:37,964 DEBUG    USB        Ch 7 I=0.009 W=0 VA=2 Wh=0 pf=-0.0757
2023-08-24 12:44:38,065 DEBUG    USB        Ch 8 I=0.009 W=0 VA=2 Wh=0 pf=-0.0303
2023-08-24 12:44:38,166 DEBUG    USB        Ch 9 I=0.010 W=0 VA=2 Wh=0 pf=0.0056
2023-08-24 12:44:38,268 DEBUG    USB        Ch 10 I=0.008 W=0 VA=2 Wh=0 pf=-0.0107
2023-08-24 12:44:38,369 DEBUG    USB        Ch 11 I=0.009 W=0 VA=2 Wh=0 pf=-0.0496
2023-08-24 12:44:38,471 DEBUG    USB        Ch 12 I=0.009 W=0 VA=2 Wh=0 pf=-0.0670
2023-08-24 12:44:46,312 DEBUG    USB        RF No Ack (1)
2023-08-24 12:44:46,815 DEBUG    USB        RF No Ack (2)
2023-08-24 12:44:46,917 DEBUG    USB        Report 249  AC present V1 = 240.75 V2 = 0.00 V3 = 0.00 f=49.91
2023-08-24 12:44:47,118 DEBUG    USB        Ch 1 I=0.047 W=0 VA=11 Wh=0 pf=-0.0042
2023-08-24 12:44:47,219 DEBUG    USB        Ch 2 I=0.045 W=0 VA=11 Wh=0 pf=-0.0708
2023-08-24 12:44:47,321 DEBUG    USB        Ch 3 I=0.022 W=0 VA=5 Wh=0 pf=-0.0344
2023-08-24 12:44:47,422 DEBUG    USB        Ch 4 I=0.022 W=0 VA=5 Wh=0 pf=-0.0690
2023-08-24 12:44:47,523 DEBUG    USB        Ch 5 I=0.022 W=0 VA=5 Wh=0 pf=0.0028
2023-08-24 12:44:47,624 DEBUG    USB        Ch 6 I=0.009 W=0 VA=2 Wh=0 pf=-0.0306
2023-08-24 12:44:47,725 DEBUG    USB        Ch 7 I=0.009 W=0 VA=2 Wh=0 pf=-0.0747
2023-08-24 12:44:47,827 DEBUG    USB        Ch 8 I=0.009 W=0 VA=2 Wh=0 pf=-0.0113
2023-08-24 12:44:47,928 DEBUG    USB        Ch 9 I=0.009 W=0 VA=2 Wh=0 pf=-0.0614
2023-08-24 12:44:48,029 DEBUG    USB        Ch 10 I=0.009 W=0 VA=2 Wh=0 pf=0.0096
2023-08-24 12:44:48,130 DEBUG    USB        Ch 11 I=0.008 W=0 VA=2 Wh=0 pf=-0.0672
2023-08-24 12:44:48,231 DEBUG    USB        Ch 12 I=0.009 W=0 VA=2 Wh=0 pf=-0.0681

(I haven’t connected the CT clamps to anything yet)

The docs say that once this is done I will see the sensors from the emonTx4 automatically populate in the INPUTS area of emoncms webconfig – but I don’t!

Maybe I should take that to a new thread. I did here.

When I look in emoncms ‘System Info’ I see the following services are green and happy:

emonhub
emoncms_mqtt
feedwriter
service-runner
redis-server
mosquitto
demandshaper

and emonPiLCD “not found or not installed”

Please let me know if you have any suggestions and thanks for bearing with me.