This repository is used to provision a Raspberry Pi with a Home Assistant installation for monitoring and controlling Farm Urban Edible Walls.
The Raspberry Pi requires an Arduino Shield for attaching the sensors:
- Gravity: Arduino Shield for Raspberry Pi B+/2B/3B/3B+/4B
- Gravity: DHT22 Temperature & Humidity Sensor
- Gravity: PWM Infrared Carbon Dioxide Sensor (400-5000 ppm)
- Gravity: Waterproof DS18B20 Temperature Sensor Kit
- Gravity: Analog Ambient Light Sensor for Arduino / ESP32 / micro:bit / Raspberry Pi (1~6000 Lux)
- Gravity: Analog Electrical Conductivity Sensor /Meter V2
- Gravity: Analog pH Sensor/Meter Kit V2
- Gravity: Analog Signal Isolator
There are currently issues with the network manager interface when using external wifi. One bug is described here: home-assistant/supervisor#4383 (comment)
Another issue that we encountered was that the wifi connection disconnects and is then disabled and needs to be manually renabled.
Potentially this bug: home-assistant/supervisor#3674 home-assistant/operating-system#2720
For this reason, we've had to ditch the HA OS and will use a standard Linux OS on the RPI and add the HA Supervisor.
- Use the Raspberry Pi Imager to flash an SD card with the Home Assistant OS.
- Insert SD card and second USB wifi dongle into the pi.
- On OSX: System Preferences -> Sharing -> Internet Sharing: On
- Plug ethernet cable into Mac and the Raspberry Pi.
- Go to: http://homeassistant.local:8123/ and do basic setup (user: fu)
- Go to user settings and enable Advanced Mode.
- Settings -> Add-ons -> ADD-ON STORE
- Install Advanced SSH Addon and set
username
andauthorized_keys
. Turn off the Protected Mode for the addon (required to accces docker on the installation). - Install Tailscale, start the addon, and look in the logs to the the authorisation url, go there and authenticate.
- Install Advanced SSH Addon and set
- Settings -> System -> Network:
- Set USB wifi card (WLP1SOU1U2) to IP4 to
automatic
. We use this for the connection to the Wifi as it doesn't support AP mode so we use the internal card as the AP (seetasks\setup_ap.yml
)
- Set USB wifi card (WLP1SOU1U2) to IP4 to
- Install ansible on the host machine.
- Edit the ansible files in the ansible directory to set:
- The MAC/HOSTNAME/IP for the ip camera and plugs in
tasks/setup_ap.yml
- Edit
files//mqtt.yml
to set which sensors are present.
- The MAC/HOSTNAME/IP for the ip camera and plugs in
- Run the ansible script in the
ansible
directory of this repository with:ansible-playbook -i 100.76.171.127, ha.yml
- Goto Settings -> Devices & Services and click to automatically configure MQTT
- the addon is setup by the ansible script.
- create a camera account on the camera with the Tapo app (Camera -> Device Settings -> Advanced Settings -> Camera Account).
- add the webcam to the network using the Tapo app.
- If the above doesn't work: Devices and Services -> Add Integration -> Tapo: Cameras Control
- use Motion Eye plugin to control the USB webcam.
- Checkout
https://github.com/linucks/fu_sensors
to build the docker image (if updating) - Edit the build.sh to set the SENSOR_DIR variable to the location of the above repository.
- Run the
build.sh
script to build and upload the Docker image to github.
- Find a USB wifi dongle that is natively supported by HA (https://github.com/morrownr/USB-WiFi) - this means that it has an in-kernel driver, and supports AP mode.
- Decided on 2.4GHz model from the Pi Hut, this has a supported driver but doesn't support AP mode, so this is used for for Pi to connect to the Wifi, and the internal USB card serves as the AP.
- Could try Panda PAU03 - might have in kernel driver and support AP mode.
- Products: https://www.athom.tech/where-to-buy
- Products: https://www.mylocalbytes.com/
- ESP flasher: https://www.tindie.com/products/makerspacelt/esp-12f-flasher-v1/
- https://www.diy.com/departments/arlec-smart-socket-3-gang-3-metre/9311644542407_BQ.prd
- https://uk.gosund.com/collections/smart-plugs-and-outlets/products/smart-power-strip-up9
To configure the connection for a wifi not present at setup:
- https://github.com/home-assistant/operating-system/blob/dev/Documentation/network.md
- https://community.home-assistant.io/t/configure-wifi-connection/157201/29
- https://tasmota.github.io/docs/Securing-your-IoT-from-hacking/
- https://www.hivemq.com/blog/mqtt-security-fundamentals-securing-mqtt-systems/
- https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04
- Enter shell on container:
docker exec -it $(docker container ls | grep rpi-ardcli | cut -f1 -d " ") /bin/sh
- Manually set network parameters: `ha network update wlan0 --ipv4-method auto --wifi-auth wpa-psk --wifi-mode infrastructure --wifi-ssid 'FARMURBAN' --wifi-psk 'XXX'``
- Network on the pi:
nmcli con show
- Getting the slug for an addon:
ha addons
- Getting options for an addon from the command-line:
curl \
-sSL \
-H "Authorization: Bearer $SUPERVISOR_TOKEN" \
http://supervisor/addons/30e576d0_hassio-access-point/info \
| jq
curl \
-sSL \
-H "Authorization: Bearer $SUPERVISOR_TOKEN" \
-X POST \
http://supervisor/addons/30e576d0_hassio-access-point/options \
-d '{"options": {"addon_option1": 1, "addon_option2": 2}'