[webProtocol] MQTT protocol environment construction

Introduction

MQTT is a client-server (CS) architecture based publish/subscribe messaging protocol. Its design idea is light, open, simple, standardized and easy to implement. These characteristics make it a good choice for many scenarios, especially for constrained environments such as machine-to-machine communication (M2M) and Internet of Things environments (IoT).


Install BroKer for MQTT – mosquitto

  • The machine environment is CentOS7
cd /etc/yum.repos.d/
vi vi mosquitto.repo

[home_oojah_mqtt]
name=mqtt (CentOS_CentOS-7)
type=rpm-md
baseurl=http://download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/repodata/repomd.xml.key
enabled=1
  • Install:yum install -y mosquitto mosquitto-clients
  • start up:/etc/rc.d/init.d/mosquitto start

Install MQTT Client–homeassistant

  • pip3 install homeassistant
  • Edit configuration file:vi configuration.yaml
  • Add the following:
mqtt:
  broker: 192.168.88.103
  port: 1883
  • Start Client:py -m homeassistant --open-ui

test

  • Subscribe to channel test:mosquitto_sub -h localhost -t test
  • Post a message on homeassistant

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325984621&siteId=291194637