Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't start the systemd service on my RasperryPI #11

Open
mnsami opened this issue Apr 18, 2023 · 4 comments
Open

I can't start the systemd service on my RasperryPI #11

mnsami opened this issue Apr 18, 2023 · 4 comments

Comments

@mnsami
Copy link

mnsami commented Apr 18, 2023

Hello, I followed your steps for the setup following the blog of Pieter https://www.pieterbrinkman.com/2022/02/01/make-your-city-heating-stadsverwarming-smart-and-connect-it-home-assistant-energy-dashboard/#comment-20805

But whenever I run sudo systemctl start kamstrup_meter.service the system freeze and the service doesn't start.

I'm not sure what i'm doing wrong.

I have the project checkout in the /opt folder, with below permissions

pi@pi-mr:/opt/kamstrup $ ls -lah
total 76K
drwxr-xr-x 6 pi   pi   4.0K Apr 18 22:51 .
drwxr-xr-x 3 root root 4.0K Apr 18 22:34 ..
-rw-r--r-- 1 pi   pi    371 Apr 18 22:36 config.yaml
-rw-r--r-- 1 pi   pi   2.5K Apr 18 22:34 daemon.py
-rw-r--r-- 1 pi   pi    252 Apr 18 22:34 docker-compose.yml
-rw-r--r-- 1 pi   pi    228 Apr 18 22:34 Dockerfile
drwxr-xr-x 8 pi   pi   4.0K Apr 18 22:34 .git
-rw-r--r-- 1 pi   pi     30 Apr 18 22:34 .gitignore
drwxr-xr-x 2 pi   pi   4.0K Apr 18 22:34 images
-rw-r--r-- 1 pi   pi   5.1K Apr 18 22:34 kamstrup_meter.py
-rw-r--r-- 1 pi   pi    288 Apr 18 22:44 kamstrup_meter.service
-rw-r--r-- 1 pi   pi   1.1K Apr 18 22:34 LICENSE
drwxr-xr-x 2 pi   pi   4.0K Apr 18 22:41 logs
-rw-r--r-- 1 pi   pi   2.1K Apr 18 22:34 mqtt_handler.py
drwxr-xr-x 2 pi   pi   4.0K Apr 18 22:41 __pycache__
-rw-r--r-- 1 pi   pi   7.9K Apr 18 22:34 readme.md
-rw-r--r-- 1 pi   pi     27 Apr 18 22:34 requirements.txt

and I have configure the systemd service to run as follows

[Unit]
Description=Kamstrup2mqtt Service
After=multi-user.target

[Service]
User=pi
Type=simple
WorkingDirectory=/opt/kamstrup
ExecStart=/usr/bin/python3 /opt/kamstrup/daemon.py
StandardOutput=null
StandardError=journal
Restart=always

[Install]
WantedBy=multi-user.target

BTW, running the script via command line send the output correctly

Thank you in advance

@jrkalf
Copy link

jrkalf commented Apr 19, 2023

Hi @mnsami,

Just covering the basic questions here.

  1. did you configure your config.yaml to point to the correct serial device?
  2. You claim the system freezes. Do you have a strong powersupply to the Raspberry Pi ? I know the IR reader can be a bit power hungry. If your system freezes, it might be draining too much power causing the whole system to too low on power and die.

@matthijsvisser
Copy link
Owner

Hi,

I see that you've added "user=pi" to the systemd file. Does it work without specifying that user? You can also try to add "group=" with the users group.

@mnsami
Copy link
Author

mnsami commented May 8, 2023

thanks @matthijsvisser for the help, it is working now, but for some reason the readings stop after some time ? might it be possible that the meter go to sleep mode from time to time ?

If so, how can I prevent that from happening in the future ? any tips and tricks ?

below is the last log entries

2023-05-05 11:35:58 daemon.py __init__:  34 - INFO - initializing daemon]
[2023-05-05 11:36:04 daemon.py __init__:  34 - INFO - initializing daemon]
[2023-05-05 11:36:15 daemon.py __init__:  34 - INFO - initializing daemon]
[2023-05-05 11:36:24 daemon.py __init__:  34 - INFO - initializing daemon]
[2023-05-05 11:36:32 daemon.py __init__:  34 - INFO - initializing daemon]

it looks to me that the daemon was trying to restart then it stopped

I appreciate all the effort you spent for your support and awesomeness !

@matthijsvisser
Copy link
Owner

thanks @matthijsvisser for the help, it is working now, but for some reason the readings stop after some time ? might it be possible that the meter go to sleep mode from time to time ?

If so, how can I prevent that from happening in the future ? any tips and tricks ?

below is the last log entries

2023-05-05 11:35:58 daemon.py __init__:  34 - INFO - initializing daemon]
[2023-05-05 11:36:04 daemon.py __init__:  34 - INFO - initializing daemon]
[2023-05-05 11:36:15 daemon.py __init__:  34 - INFO - initializing daemon]
[2023-05-05 11:36:24 daemon.py __init__:  34 - INFO - initializing daemon]
[2023-05-05 11:36:32 daemon.py __init__:  34 - INFO - initializing daemon]

it looks to me that the daemon was trying to restart then it stopped

I appreciate all the effort you spent for your support and awesomeness !

Which meter do you got? The 402 can be manually activated by pressing a button on the meter and will need to be polled by the scripts at least once every 30 minutes to remain active. Other models only require a strong magnet to remain active.

An other thought: is your meterhead fixed in place on the meter? If not, you can try to do so with tape when you've found the right spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants