
Janus MQTT Proxy ูู ุฎุฏู
ุฉ ูุชุจุชูุง ุนูู Go ูู
ุดุฑูุน ููุงูุงุช. ูุชุตู ุจุณู
ุณุงุฑ MQTT ููุดุชุฑู ูู ุฌู
ูุน ุงูุฃุญุฏุงุซ ุ ููููู
ุงูุนู
ูุงุก ุจุฏูุฑู ุจุงูุงุชุตุงู ุจุงููููู ูุงูุชูุงุตู ู
ุนู ูู
ุง ูู ุงูุญุงู ู
ุน ูุณูุท MQTT.
ูุชูุญ ูู:
- ุชูููุฏ ูุตูู ุงูุนู
ูุงุก ุฅูู ู
ูุงุถูุน ู
ุฎุชููุฉ. ุจู
ุง ูู ุฐูู ุชูููุฏ ุงููุตูู ุฅูู ุงููุฑุงุกุฉ ูุงููุชุงุจุฉ ุจุดูู ู
ููุตู ุ
- ุงุณุชุจุฏู ุฃุณู
ุงุก ุงูู
ูุถูุนุงุช ูู
ุญุชููุงุช ุงูุฃุญุฏุงุซ ุจู regexp s.
ูู
ุงุฐุง ูู ุถุฑูุฑู
MQTT . , - 1 /my/lamp/on, - On /my/lamp. , , . , .
Janus MQTT : , , MQTT- . / , .
. , /light/main. ยซ, โ , โ , , ยป. , .
, , , . Janus MQTT / , . , , , โ .
Janus MQTT
, , โ , .
Janus MQTT , . โ :
broker_to_client: #
# MQTT discovery.
- topic: ^/devices/wb-gpio/controls/LIGHT_([^/]*)/meta/type$
template: /homeassistant/light/{{.f1}}/config
val_map:
switch: >-
{
"command_topic":"/light/{{.f1}}/state",
"state_topic":"/light/{{.f1}}/state",
"name":"{{.f1}}"
}
- topic: ^/devices/wb-gpio/controls/LIGHT_([^/]*)$
template: /light/{{.f1}}/state
val_map: {0: OFF, 1: ON}
client_to_broker: #
- topic: ^/light/([^/]*)/state$
template: /devices/wb-gpio/controls/LIGHT_{{.f1}}/on
val_map: {OFF: 0, ON: 1}
, . .
, Home Assistant , .
MQTT discovery : Wiren Board , . , . switch. retained โ . JSON-, , MQTT discovery .
Janus MQTT
Go paho.mqtt.golang. MQTT- . , , MQTT-.
: , , . . .. MITM.
:
- QoS โ 2 1 , ;
- - QoS message_id, uint16 ;
- Janus MQTT . , ;
- , in-memory retained-.
MQTT- client.serveIncoming, TCP-. MQTT- :
- ConnectPacket โ Connack ;
- SubscribePacket โ Suback retained-;
- UnsubscribePacket โ Unsuback ;
- PingreqPacket โ Pingresp;
- PublishPacket โ ;
- PubackPacket, PubrelPacket, PubcompPacket ;
- DisconnectPacket โ .
QoS. MQTT QoS:
, 1 2 , , , ( 2 , QoS 1, ).
publish- QOS=2

publish- QOS=2

Janus MQTT :
- Wiren Board โ ;
- Home Assistant โ ( );
- Yandex2mqtt โ .
Wiren Board
. . MQTT-.
Yandex2mqtt
oAuth API . . munrexio, bawdiest , .
, :
$ mosquitto_sub -h localhost -u yandex2mqtt -P yandex2mqtt -t '#' -v
/light/LIVING_TABLE/state 1

Home Assistant
. . , .
Home Assistant , , .
, Home Assistant MQTT Discovery โ , Home Assistant MQTT. JSON-, .
Home Assistant :
mqtt:
username: !env_var MQTT_USER
password: !env_var MQTT_PASS
broker: !env_var MQTT_HOST
discovery: true
discovery_prefix: /homeassistant
Janus MQTT
Janus MQTT Home Assistant . 100 , 17 , 6 (/) 5 . . .
Docker
NanoPi docker-compose.yml.

, , , .
10 M. Golang!
/ :
https://github.com/phoenix-mstu/janus-mqtt-proxy.
docker-compose :
https://github.com/phoenix-mstu/smart_home/tree/master/raspberry.
, : 52.59.242.204:26927 ( ), / โ habr/habr, โ MQTT, . . , :
- ( ).
- .
- โ , . , , . , DoS- โ . .