Skip to content

2. Installation

Arjan edited this page May 27, 2024 · 12 revisions

1. MQTT Broker

Make sure you have MQTT installed and know the details of connection / credentials

2. Alternative setup: using docker-compose

This is the easiest setup and allows you to run a script 'daily' instead of keeping a docker container running all day eating CPU/Memory, note that GRDF only updates once a day. The below assumes a setup on a Unix/Linux machine

  1. create a folder in a for-you appropriate location e.g. below assumes folder: /home/docker/gazpar_2_mqt
me@ha-nuc:~/docker/gazpar_2_mqtt_2$ ls -la
total 0
drwxrwxrwx 1 root root   4096 Apr 28 17:47 .
drwxrwxrwx 1 root root   4096 Apr 25 18:23 ..
  1. create a file docker-compose.yml
me@ha-nuc:~/docker/gazpar_2_mqtt_2$ ls -la
total 112
drwxrwxrwx 1 root root   4096 Apr 28 17:47 .
drwxrwxrwx 1 root root   4096 Apr 25 18:23 ..
-rwxrwxrwx 1 root root   1909 Apr 28 17:42 docker-compose.yml
  1. edit the parameters to match your situation, minimal/example Note: usually MQTT requires some login params hence used in below example but this may differ from your situation
version: '3.5'
services:
  gazpar2mqtt:
    container_name: gazpar_2_mqtt
    image: vingerha/gazpar_2_mqtt:latest
    tty: true
    restart: unless-stopped
    environment:
      # mandatory:
      GRDF_USERNAME: gazou@email.com
      GRDF_PASSWORD: gazou_password
      MQTT_HOST: host (or use ip-address)
      TZ: Europe/Paris
      STANDALONE_MODE: 'True'
      # optional
      MQTT_PORT: '1883'
      MQTT_TOPIC: 'gazpar'
      MQTT_CLIENTID: 'gazou'
      MQTT_USERNAME: 'your_mqtt_username'
      MQTT_PASSWORD: 'your_mqtt_password'
    volumes:     
      - ./:/data
      - ./app:/app

For more details, please look at the docker compose parameters

  1. Run the docker compose, for Ubuntu this looks like
docker-compose run --rm gazpar2mqtt

a sub-folder app will be auto-created as well as the sqlite database

me@ha-nuc:~/docker/gazpar_2_mqtt_2$ ls -la
total 180
drwxrwxrwx 1 root root   4096 Apr 28 17:47 .
drwxrwxrwx 1 root root   4096 Apr 25 18:23 ..
drwxrwxrwx 1 root root   4096 Apr 28 16:24 app
-rwxrwxrwx 1 root root   1909 Apr 28 17:42 docker-compose.yml
-rwxrwxrwx 1 root root 102400 Apr 28 16:25 gazpar2mqtt.db
  1. Debug If the above does not result in topics in MQTT, then you can try to add DEBUG to get more insight on where it blocks For this, add DEBUG: 'True' to environment section of the docker-compose.yml

3. Alternative setup: Docker

This setup assumes the parameters to be detailed in the param.py file. This allows for more finetuning then 'just' the docker-compose setup

  • create a folder ([yourdocker_dir]/gazpar_2_mqtt) to map to the container volume
  • in that folder, create a folder app ([yourdocker_dir]/gazpar_2_mqtt/app)
  • run docker command below, the very first time it will copy all necessary files into [yourdocker_dir]/gazpar_2_mqtt/app
  • it will then CRASH as it does not have the credentials
  • modify the param.py to match grdf and mqtt ip/port and (if needed) mqtt credentials
  • restart the container Docker location

Example of docker run command, assuming param.py having the credentials:

docker run --name gazpar_2_mqtt -v [yourdocker_dir]/gazpar_2_mqtt/app:/app -v [yourdocker_dir/gazpar_2_mqtt:/data --tty vingerha/gazpar_2_mqtt:latest

4. Add-on, for Hass.io users (ininital stages)

To install the addon

  • Go to: Settings > Add-ons > Addon Store.
  • Click the 3-dot on the top right to add a new repository.
  • Use https://github.com/vingerha/gazpar_2_mqtt to load the addon.
  • Refresh the screen so the addon shows, then open it and click: Install. This may take 10+ minutes
  • After the installation, start it. Initially it will crash as it does not have a valid configuration
  • Use vscode editor or file editor to edit the config.yaml in /config/gazpar_2_mqtt. Note that the file should be clean, no outcommented rows or comments. Example:
GRDF_USERNAME="your_username_usually_an_email"
GRDF_PASSWORD="your_password"
MQTT_HOST=192.168.x.y
MQTT_USERNAME=mqtt_username
MQTT_PASSWORD=mqtt_password
MQTT_TOPIC=gazpar_haos
MQTT_CLIENTID=gazpar_client_haos
HASS_DISCOVERY=True
HASS_PREFIX=homeassistant
HASS_DEVICE_NAME=gazpar
SCHEDULE_TIME=06:30
DEBUG_MODE=True

Add and empty line at the end

Note that the addon will try to find a local MQTT server and will then ignore above MQTT settings. You can omit this in the options of the addon The various parameters can be found in the docker compose parameters

  • restart the addon to take above into effect

5. Native/ standalone (not yet available)

As gazpar_2_mqtt is built upon python, one could theoretically run this outside of a container. This however requires all the software components to be installed and properly functioning, e.g. Selenium and Chromium (Dockerfile for details) At present this is all at your own discretion and not support will be provided as this differs per OS type/version