Giter Club home page Giter Club logo

smarthomeserver's Introduction

smarthomeserver

A simple setup for your own smart home server (on a Raspberry Pi)

Why you need your own smart home server

The smart home market is really fragmented. Using different gateways and Apps from different ecosystems can be annoying, expansive and might not work very well together. Instead I suggest using a custom smart home server with some open source software that can replace all your hubs and give you access to one system to control it all.

The hardware

I am running this on a Raspberry Pi but as these are Docker containers you can run them on pretty much any platform.

Login

I recommend accessing your Pi/server via SSH. If you do make sure to configure it for save usage and change the standard password! It is recommended to use login via SSH keys. I described how to set that up here

How to get started

Create a folder to hold all your docker data. Then clone this repository and update the .env file. Change the password and IDs and update the path to the folder you just created. Make sure that the data folder belongs to the same user/group ids you are providing in the .env file. If you see any errors errors in the container logs about Permission denied or similar then you have to check if that subfolder in your datafolder belongs to the same user the container is using. If you still run into problems add user: ${PUID}:${PGID} to the container definition to force it to use that user.

Be sure to update the email related settings if you want to use notifications for automatic container updates. If you have done that uncomment the WATCHTOWER_NOTIFICATIONS related variables in the hosting.yml file.

If you want to use Loki/Grafana to see all logs in one place you need to also copy the loki-configuration.yaml file to ${DATADIR}/loki/config/loki-config.yaml. You need to also install the Loki logging driver or remove the logging commands from the compose files. The installation can be done via

docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
// or if you are running this on a Raspberry Pi
docker plugin install grafana/loki-docker-driver:arm-v7 --alias loki --grant-all-permissions

Alternatively if you are going to use promtail to ingest the logs you need to also copy the promtail-config.yaml file to ${DATADIR}/promtail/config/promtail-config.yaml and remove the logging: parts in the compose yaml files.

If you want to use monitoring of your containers and host system via prometheus you should also create a config directory for that and copy the config file from this repository like

mkdir /some/data/dir/prometheus/etc
cp prometheus_config.yaml ${DATADIR}/prometheus/etc/prometheus.yml

If you want to use the Mosquitto MQTT broker make sure to also copy the provided configuration file like

cp mosquitto.conf ${DATADIR}/mosquitto/config

If you want to use Zigbee2MQTT do not forget to copy the config file and update it via

cp zigbee2mqtt_configuration.yaml ${DATADIR}/zigbee2mqtt/data/configuration.yaml

and update the IP of your Zigbee bridge (if you use a networked one) or switch to serial port in the same config file. Also make sure to update the devices: entry in your smarthome.yml file to pass the right serial device to your Docker container in that case.

Then you can start the containers via docker compose.

docker-compose -f hosting.yml up -d
docker-compose -f smarthome.yml up -d
docker-compose -f monitoring.yml up -d

// to see logs (some will only be available via Grafana, see below)
docker-compose -f ...yml logs -f
// to see if containers are running
docker-compose -f ...yml ps

// to stop
docker-compose -f ...yml down

Which services are included?

In the smarthome.yml:

Service Port Setup
Mosquitto 1883 You need to copy the config file above. Can be accessed with a MQTT client like MQTT explorer
InfluxDB only internally available from other containers -
Grafana 3000 Setup can be done according to my Grafana dashboard guide. You can use this to view logs according to the Loki guide
TasmoAdmin 3080 just let it scan your network for devices
Zigbee2MQTT - Setup can be done according to my Zigbee2MQTT guide
Zigbee2MQTTAssistant 8880 More info
HomeAssistant 8123 Just go to the webpage and follow the setup wizard

In the hosting.yml:

Service Port Setup
Heimdall 9080 -
PiHole 6080 There is a nice in-depth guide here
Adguard Home 3380 You can follow my setup guide here
Unifi controller 8080 Just follow the setup wizard
Watchtower - This is set up according to my Watchtower guide
Diun - This is set up according to my Diun guide
Loki 3100 This is set up according to my Loki guide
Duplicati 8200 This allows you to back up any data from your Docker containers. More details here

You really only need one way of notifying you about Docker image updates so I would recommend running either Watchtower or Diun, depening on whether you want automatic updates or not.

In the monitoring.yml

Service Port Setup
Prometheus 9090 There is a full explanation here
node exporter 9100 No frontend, see prometheus guide
cadvisor 8080 No frontend, see prometheus guide

You should only use one adblocker (Adguard Home or PiHole) at a time as they use the same ports. If you want to run a second Adguard Home instance somewhere else as a backup and still keep the setting in sync then follow this article. The needed container is already in the hosting.yml file.

Logging

If something is not working, check the logs first! Some service logs can only be viewed directly via docker logs containername or docker-compose -f yamlname.yaml logs. The important services are pushing their logs to Loki which collects all of them. You can use Grafana to view them all. I describe this in more detail here. You need to install the Loki logging driver (see installation part above) for this to work or slightly change the compose files by removing the custom logging sections. Loki creates a json file for each services log that is kepts until a restart. Without any restrictions these files can get really big. To avoid this I added a size restriction to the configuration of each service via the max-size argument. More details about this can be found here.

How does it look like? I need more details

You can find more images and a details in my blog post

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.