presence service with openhabianpi

50 views
Skip to first unread message

Mikeww1

unread,
Jan 30, 2018, 10:39:38 AM1/30/18
to Happy Bubbles
Hi
I tried to install the presence server on my pi with openhabian. Unfortunately that does not seem to work.
Installation seems to work but - as I read in another post - the subdirectories are not created and the subdirectory structure is different.

The service module is in the correct directory. I created the necessary directories manually under home and put the content of the zip there.

Then I ran all the commands from the script manually but I cannot connect on port 5555. Openhab2 and mosquitto is running on the same machine.

 I ran the following command , maybe it helps. I am no Linux Guru and cannot debug that myself.

[10:06:48] openhabian@openHABianPi:~$ sudo journalctl -xe
[sudo] password for openhabian:
Jan 26 09:55:35 openHABianPi systemd[1]: Unit presence.service entered failed st
Jan 26 09:56:18 openHABianPi sudo[29656]: openhabian : TTY=pts/0 ; PWD=/home/pi/
Jan 26 09:56:18 openHABianPi sudo[29656]: pam_unix(sudo:session): session opened
Jan 26 09:56:18 openHABianPi systemd[1]: Reloading.
Jan 26 09:56:19 openHABianPi sudo[29656]: pam_unix(sudo:session): session closed
Jan 26 09:56:35 openHABianPi sudo[29676]: openhabian : TTY=pts/0 ; PWD=/home/pi/
Jan 26 09:56:35 openHABianPi sudo[29676]: pam_unix(sudo:session): session opened
Jan 26 09:56:35 openHABianPi systemd[1]: Reloading.
Jan 26 09:56:36 openHABianPi sudo[29676]: pam_unix(sudo:session): session closed
Jan 26 09:57:29 openHABianPi sudo[29719]: openhabian : TTY=pts/0 ; PWD=/home/pi/
Jan 26 09:57:29 openHABianPi sudo[29719]: pam_unix(sudo:session): session opened
Jan 26 09:57:29 openHABianPi sudo[29719]: pam_unix(sudo:session): session closed
Jan 26 10:02:58 openHABianPi sudo[29850]: openhabian : TTY=pts/0 ; PWD=/etc/syst
Jan 26 10:02:58 openHABianPi sudo[29850]: pam_unix(sudo:session): session opened
Jan 26 10:05:01 openHABianPi CRON[29910]: pam_unix(cron:session): session opened
Jan 26 10:05:01 openHABianPi CRON[29914]: (root) CMD (command -v debian-sa1 > /d
Jan 26 10:05:01 openHABianPi CRON[29910]: pam_unix(cron:session): session closed
Jan 26 10:06:08 openHABianPi sudo[29850]: pam_unix(sudo:session): session closed
Jan 26 10:06:19 openHABianPi sshd[27599]: pam_unix(sshd:session): session closed
Jan 26 10:06:42 openHABianPi sshd[29973]: Accepted password for openhabian from
Jan 26 10:06:42 openHABianPi sshd[29973]: pam_unix(sshd:session): session opened
Jan 26 10:07:02 openHABianPi sudo[30383]: openhabian : TTY=pts/0 ; PWD=/home/ope
Jan 26 10:07:02 openHABianPi sudo[30383]: pam_unix(sudo:session): session opened
lines 2159-2181/2181 (END)

nemik

unread,
Feb 2, 2018, 12:47:29 PM2/2/18
to Happy Bubbles
Seems like it might be restarting itself and not able to connect to MQTT? Check the systemd service file's "ExecStart" variable to make sure your MQTT parameters are correct. Run the presence server with "-h" to see the help file and the available command-line options. If your MQTT server is not on local host, or running on a different port, or needs a username/pass, then you need to include those when starting the server.

Mikeww1

unread,
Feb 2, 2018, 2:57:09 PM2/2/18
to Happy Bubbles
Thanks for the hints.

I started to edit the presence.service file and corrected the directory paths that were wrong and I corrected the user because I dont know if user pi exists.
It looks like that now

[Unit]
Description=presence

[Service]
ExecStart=/home/pi/presence/presence -http_host_path=0.0.0.0:5555 -mqtt_host "localhost:1883" -mqtt_user$t_username "xxxxxxxx" -mqtt_password "yyyyyy"
WorkingDirectory=/home/pi/presence
User=openhabian
Group=pi
Restart=always

[Install]
WantedBy=multi-user.target

But I have still no response on port 5555.
Are there any prerequisites for running the server on the pi ?
What are the commands to debug this ? I have only basic knowledge of Linux.

Mikeww1

unread,
Feb 2, 2018, 3:07:14 PM2/2/18
to Happy Bubbles
In addition :
I am not sure how to start the service with parameters-

[20:04:02] openhabian@openHABianPi:/etc/systemd/system$ sudo service presence -h
Usage: service < option > | --status-all | [ service_name [ command | --full-restart ] ]
[20:10:24] openhabian@openHABianPi:/etc/systemd/system$ sudo service presence --status-all
presence: unrecognized service
[20:12:20] openhabian@openHABianPi:/etc/systemd/system$ sudo service presence --status
presence: unrecognized service



Mikeww1

unread,
Feb 5, 2018, 9:59:26 AM2/5/18
to Happy Bubbles
I found some additional information regarding the start problems of the presence server in the daemon.log:

Feb  5 15:39:07 openHABianPi presence[3602]: 2018/02/05 15:39:07 open presence.db: permission denied
Feb  5 15:39:07 openHABianPi systemd[1]: presence.service: main process exited, code=exited, status=1/FAILURE
Feb  5 15:39:07 openHABianPi systemd[1]: Unit presence.service entered failed state.

What permissions are necessary to avoid that error ?


nemik

unread,
Feb 5, 2018, 10:12:15 AM2/5/18
to Happy Bubbles
I'm not sure what user you're running as, but that user must be able able to open and write to that presence.db file which stores state for the presence server.

Can you find the presence.db file on your system and if you do "ls -al presence.db" there, it will tell you which user it belongs to and which permissions. Then those could be changed with "chmod". If you ran the presence server manually  before with sudo, it may have created the DB file with root permissions, so a regular user now can't use it. You can either change its permissions with 'chmod' or remove the file entirely if you don't have many beacons added and stored.

As for your previous question about the "-h" flag, you don't run it with 'service', so instead just fine where "presence" executable is located and run "./presence -h" to see the options, without service.

Mikeww1

unread,
Feb 5, 2018, 10:17:41 AM2/5/18
to Happy Bubbles
I solved the problem.

The directory pi was assigned to root. I changed that to openhabian:openhabian and now it runs !!
Thank you for your support.

nemik

unread,
Feb 5, 2018, 10:20:48 AM2/5/18
to Happy Bubbles
Great! Sorry the installation is so minimal and specific to Raspbian for now, but I'm glad you got it sorted.
Reply all
Reply to author
Forward
0 new messages