Presence detection with low cost BLE devices and Raspberry Pi/Zero W

I have this working but for some reason I cannot get it operating as a service. My steps are:

sudo nano /etc/systemd/system/room-assistant.service

[Unit]
Description=Room Assistant service

[Service]
ExecStart=/usr/bin/npm start
WorkingDirectory=/home/pi/room-assistant
Restart=always
RestartSec=10
User=pi

[Install]
WantedBy=multi-user.target

And then:

sudo systemctl enable room-assistant.service
sudo systemctl start room-assistant.service

The result I get is:

**pi@raspberrypi** : **~/room-assistant $** systemctl status room-assistant.service

ā— room-assistant.service - Room Assistant service

Loaded: loaded (/etc/systemd/system/room-assistant.service; enabled; vendor preset: enabled)

Active: activating (auto-restart) (Result: exit-code) since Fri 2018-11-23 11:32:04 AEDT; 6s ago

Process: 768 ExecStart=/usr/bin/npm start **(code=exited, status=203/EXEC)**

Main PID: 768 (code=exited, status=203/EXEC)

Nov 23 11:32:04 raspberrypi systemd[1]: **room-assistant.service: Failed with result 'exit-code'.**

Any ideas what the problem is?

Got this working.
Had to change to ExecStart=/usr/local/bin/npm start

[Unit]
Description=Room Assistant service

[Service]
ExecStart=/usr/local/bin/npm start
WorkingDirectory=/home/pi/room-assistant
Restart=always
RestartSec=10
User=pi

[Install]
WantedBy=multi-user.target

You say you ā€œprobably wouldnā€™t use it to switch lights on when you enter a roomā€ā€¦ why not? Seems like the most logical use for this. What do you use it for?

In my experience it wouldnā€™t respond quickly enough - you could probably bring it down to 10-15 milliseconds but I donā€™t know how reliable that would be and you could end up standing in the dark :slight_smile:

Iā€™m getting an error at step 13. Any idea what this could be?

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

EDIT: The issue was that the current version of Docker (18.09.0) was running an error and you needed to go back. See the comment here: https://github.com/moby/moby/issues/38175#issuecomment-439422785

I am having issues with getting the json file to work correctly on room assistant v2.4.0 any ideas?

Itā€™s easier to use YAML with the new version in my opinion. Can you show your json file?

What size SD card is recommended for running room assistant on the Pi Zero W?

I donā€™t think thereā€™s a recommended size, room-assistant itself uses almost no space.

I have 8 Gb cards in all my Pi Zero Ws.

Nearly everything that you use should work. But try to get something smaller than 32GB for a reasonable priceā€¦ At Amazon the 16GB is more expensive than the 32GBā€¦
Use what you get for a good price, Iā€™m quite sure there is nothing on the market anymore, that would be to small. :slight_smile:

Hi Iā€™m wondering if anyone can help, ive got a piZero running room assistant. Every now and again the pi crashes and I need to reboot. Ive found I can use a shell integration to send a reboot command and also also creates a switch in home assistant. what I need help with is changing this switch to a press button. this is the code ive used.

shell:
  sensors:
    - name: Kitchen Wifi Strength
      command: 'iwconfig wlan0 | grep -i quality'
      regex: 'Signal level=(-?[0-9]+) dBm'
      cron: '* * * * *'
      icon: mdi:wifi
      unitOfMeasurement: dBm
      deviceClass: signal_strength
  switches:
    - name: Onboard LED
      onCommand: 'echo mmc0 | sudo tee /sys/class/leds/led0/trigger'
      offCommand: 'echo none | sudo tee /sys/class/leds/led0/trigger && echo 1 | sudo tee /sys/class/leds/led0/brightness'
    - name: Reboot
      onCommand: 'echo none | sudo reboot'
      offCommand: 'echo none'