gluap / pyess

Python library for communication with LG ESS power converters
MIT License
31 stars 10 forks source link

ESSmqtt as daemon #22

Closed pguich closed 1 year ago

pguich commented 1 year ago

Hi, I have a problem where my ESS keeps dropping off my WiFi, so I tried to follow your instructions to set up essmqtt as a system daemon. essmqtt works when I run it from Terminal.

The essmqtt.conf file is located in /etc/ The essmqtt file is located in /home/pguich/.local/bin/

I've created a essmqtt.service file in /etc/systemd/system. This is the file:

[Unit] Description=ESS MQTT wrapper test

[Service]

all essmqtt command line arguments can be used here. it is recommended to con>

for this use case

ExecStart=/home/pguich/.local/bin/essmqtt

Restart will keep the service alive for instance in case the mqtt server goes>

when esmqqt starts

Restart=on-failure

a sensible restart delay prevents fast restart loops potentially denial-of-se>

RestartSec=10

[Install]

we'd like to start, but only after network is up

WantedBy=default.target Wants=network-online.target

When I check the status of the service, I get this - and I'm not sure, but it looks to me it's not working as it should:

● essmqtt.service - ESS MQTT wrapper test Loaded: loaded (/etc/systemd/system/essmqtt.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Fri 2023-08-04 10:59:36 BST; 793ms ago Process: 6215 ExecStart=/home/pguich/.local/bin/essmqtt (code=exited, status=1/FAILURE) Main PID: 6215 (code=exited, status=1/FAILURE) CPU: 117ms

to me this doesn't look right, and I can confirm that after my ESS lost connection with the WiFi temporarily, the service didn't restart , I had to do it manually with the essmqtt command.

I've searched/googled what i might be doing wrong, but I'm at my wit's end.

Thanks for your help!

pguich commented 1 year ago

I guess is should have followed the instructions more closely, namely installing a vent. Following this to the letter resolved it all. https://github.com/gluap/pyess/issues/3#issuecomment-622967278

the following creates a sandboxed, local python installation in /opt/essmqtt:

python3.8 -m venv /opt/essmqtt

the following installs pyess in the sandbox:

/opt/essmqtt/bin/pip install pyess `

updating the essmqtt.service with the this:

ExecStart=/opt/essmqtt/bin/essmqtt

this fixed everything.