项目作者: liske

项目描述 :
MQTT System Tray Icon
高级语言: Python
项目地址: git://github.com/liske/mqttstray.git
创建时间: 2018-11-01T21:50:20Z
项目社区:https://github.com/liske/mqttstray

开源协议:GNU General Public License v2.0

下载


mqttstray

MQTT System Tray Icon

description

About

This project provides a small python script which builds system tray icons from messages on MQTT subscribtions. The icons are build combining SVG template files and the jinja2 template processor to render images depending on the MQTT message payload. The payload needs to be JSON encoded.

I developed mqttstray to get the measurements of my CGM to my GNU/Linux desktop. See also the xDrip+ example.

Install

  1. # clone the repository
  2. git clone https://github.com/liske/mqttstray.git
  3. # create python virtual env
  4. cd mqttstray && virtualenv -p python3 .venv
  5. # enter virtual env and install missing dependencies
  6. . .venv/bin/activate
  7. pip install -r requirements.txt

Configuration

The main configuration file is ${XDG_CONFIG_HOME}/mqttstray/config.

MQTT

The configuration file requires to contain a section for the MQTT connection:

  1. [_MQTT]
  2. host=127.0.0.1
  3. port=8883
  4. tls=True
  5. verify=False
  6. username=joe
  7. password=foobar

The following settings are supported for the MQTT constructor and MQTT connect invocation:

  • host - the host used for the MQTT connection
  • port - the port used for the MQTT connection (default: 1883)
  • client_id - unique client id (default: ${USER}@$(hostname -f))
  • transport - tcp or websockets MQTT transport (default: tcp)
  • username - MQTT authentication username (default: None)
  • password - MQTT authentication password (default: None)

The following settings are supported for the MQTT tls_set invocation:

  • tls - enable TLS for the MQTT connection (default: False)
  • verify - verify the MQTT broker’s X.509 certificate (default: True)
  • ca_certs - pathname for the CA files (default: system’s CA list is used)
  • certfile - client certificate file used for authentication (default: None)
  • keyfile - client private key file used for authentication (default: None)
  • ciphers - restrict allowed encryption ciphers or use python’s default
  • insecure - ignore MQTT broker’s X.509 certificate subject hostname (default: False)

Icons

Any other section not beginning with a underscore (_) is handled as an icon configuration:

  1. [xDrip mmol/l]
  2. topic=android/broadcast/my-phone/xdrip
  3. filename=xDrip/icon-mmol.svg
  4. outdated=600

An icon section has the following options:

  • topic - a single MQTT topic used for this icon
  • filename - SVG filename to be used as jinja2 template to render the final icon

Examples

Example icons can be found in the ex/ directory.

Limitations

  • no support for wildcard topics(, yet)
  • currently only one topic per icon is supported
  • only a connection to a single MQTT broker is supported
  • MQTT payload requires to be JSON encoded