ruimarinho/miflora-mqtt

By ruimarinho

Updated over 6 years ago

Run the miflora-mqtt-daemon in Docker.

Image
2

500K+

ruimarinho/miflora-mqtt

Run the miflora-mqtt-daemon in Docker.

build statusruimarinho/miflora-mqttruimarinho/miflora-mqtt

miflora-mqtt-daemon

The miflora-mqtt-daemon is a bluetooth low energy to mqtt gateway enabling you to receive sensor information from Xiaomi Mi Plant sensors if they are away from your home automation server.

With this container, it becomes amazingly simply to setup a Raspberry or similar device running a container-optimized operating system such as HypriotOS and transform it into a low cost sensor gateway.

Usage

All settings of the miflora-mqtt-daemon can be dynamically configured via environment variables (thanks to confd) without having to create a new image or bind-mounting the configuration file.

The environment variable are organized into four groups, as per the original configuration file:

  • MIFLORA_GENERAL_<PROPERTY>: populates the [General] section.
  • MIFLORA_DAEMON_<PROPERTY>: populates the [Daemon] section.
  • MIFLORA_MQTT_<PROPERTY>: populates the [MQTT] section.
  • MIFLORA_SENSORS_<INDEX>_<PROPERTY>: populates each sensor inside the [Sensors] section.

Using the scheme above, the configuration can be as simple as setting the following environment variables:

docker run \
  -e 'MIFLORA_MQTT_HOSTNAME=127.0.0.1' \
  -e 'MIFLORA_SENSORS_0_Schefflera@Foo=C4:7C:8D:11:22:33' \
  -d ruimarinho/miflora-mqtt

If you need to further customize the daemon's settings, check the next chapter for a detailed reference guide.

Configuration Reference

Environment Variable NameDescription
MIFLORA_GENERAL_REPORTING_METHODThe operation mode of the program. Determines wether retrieved sensor data is published via MQTT or stdout/file.
MIFLORA_GENERAL_ADAPTERThe bluetooth adapter that should be used to connect to Mi Flora devices (Default: hci0)
MIFLORA_DAEMON_ENABLEEnable or Disable an endless execution loop (Default: true)
MIFLORA_DAEMON_PERIODThe period between two measurements in seconds (Default: 300)
MIFLORA_MQTT_HOSTNAMEThe hostname or IP address of the MQTT broker to connect to (Default: localhost)
MIFLORA_MQTT_PORTThe TCP port the MQTT broker is listening on (Default: 1883)
MIFLORA_MQTT_KEEPALIVEMaximum period in seconds between ping messages to the broker. (Default: 60)
MIFLORA_MQTT_TOPICThe MQTT base topic to publish all Mi Flora sensor data topics under. Default depends on the configured reporting_mode (mqtt-json, mqtt-smarthome: miflora, mqtt-homie: homie)
MIFLORA_MQTT_HOMIE_DEVICE_IDHomie specific: The device ID for this daemon instance (Default: miflora-mqtt-daemon)
MIFLORA_MQTT_USERNAMEThe MQTT broker authentification username (Default: no authentication)
MIFLORA_MQTT_PASSWORDThe MQTT broker authentification password (Default: no authentication)
MIFLORA_MQTT_TLS_ENABLEDEnable TLS/SSL on the connection
MIFLORA_MQTT_TLS_CA_CERTPath to CA Certificate file to verify host
MIFLORA_MQTT_TLS_CLIENT_KEYPath to TLS client auth key file
MIFLORA_MQTT_TLS_CLIENT_CERTPath to TLS client auth certificate file
MIFLORA_SENSORS_<N>_<NAME>[@LOCATION]Sensor configuration consisting of name, optional location and ethernet MAC address

Debugging

If you would like to take a look at the generated config file for debugging purposes, you can do so by running the following command:

docker run \
  --rm \
  --entrypoint sh \
  -ti ruimarinho/miflora-mqtt \
  -c confd -onetime -backend env -log-level debug && cat /miflora-mqtt-daemon/config.ini'

License

MIT

Docker Pull Command

docker pull ruimarinho/miflora-mqtt