MQTT Client in Python - OpenHAB
To make it simple, we work in a virtual machine.
Openhab will ack as the MQTT server and will display all the data he received from the MQTT client.
For more information on How To Install OpenHAB, please refer to the doc
-
Config file
{INSTALLATION_FOLDER}/configuration/openhab.cfg
:- Persistance :
mqtt-persistence:broker=openhab
- MQTT Transport :
mqtt:openhab.url=tcp://localhost:1883
- Item
{INSTALLATION_FOLDER}/configuration/item/demo.item
:
You can change the topics for what you want (ex: paho/temparature
)
Number mqttsw1 "temp [%.1f °C]" {mqtt="<[openhab:paho/temperature:state:default]"}
- Sitemap
{INSTALLATION_FOLDER}/configuration/sitemap/demo.sitemap
:
sitemap demo label="Main Menu"
{
Frame label="MQTT" {
Text item=mqttsw1
}
}
During the installation of openhab, you will be ask to install.
In the config file /etc/mosquitto/mosquitto.conf
you need to add this line :
allow_anonymous = true
Command that may help you to diagnotic issue with MQTT :
Subscribe to topics : mosquitto_sub -d -t paho/temperature
Send Msg to topics : mosquitto_pub -d -t paho/temperature -m "18"
Clone the branch :
git clone https://github.com/gzsierra/pytt/
For installation, please see the doc
For installation, please see the doc
For installation, please see the doc
Entry file format must be : [TIME] [VALUE]
ex: timeX 18
To execute the script : python pytt.py test.txt
MIT