Skip to content

Commit 0bea917

Browse files
authored
Merge pull request #1547 from UBWH/master
Update docs with new LoRaWAN sensor discovery for Home Assistant
2 parents 2b3e8e5 + 2e9a7ff commit 0bea917

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

docs/LoRaWan-Decoders.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# LoRaWan Decoders
22

3+
* [Introduction](#introduction)
4+
* [Adding Payload Data Decoding](#adding-payload-data-decodingadding_payload_data_decoding)
5+
* [Example LwDecoded MQTT message](#example-lwdecoded-mqtt-message)
6+
* [Files](#files)
7+
* [How to use the Device Decoder feature](#how-to-use-the-device-decoder-feature)
8+
* [Write your own Device Decoder file](#write-your-own-device-decoder-file)
9+
* [Home Assistant Discovery](#home-assistant-ha-discovery)
10+
11+
## Introduction
312
LoRaWan end devices transmit packets containing raw _Payload Data_. The Tasmota _LoRaWan Bridge_ feature normally passes the raw _Payload Data_ onto an MQTT server.
413
```
514
{
@@ -87,3 +96,52 @@ Alternatively, find the manufacturer's datasheet/User Guide/User Manual/etc. to
8796
6. Submit a [PR](https://github.com/arendst/Tasmota/pulls) to share your new decoder with the Tasmota community.
8897

8998

99+
## Home Assistant (HA) Discovery
100+
Tasmota has a built-in feature that reports device info to the [HA Tasmota Integration](https://www.home-assistant.io/integrations/tasmota/) at bootup.
101+
102+
![tasmota discovery](image.png)
103+
104+
Optionally, the LoRaWAN sensors can also be reported to HA using [MQTT Discovery](https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery)
105+
106+
![mqtt discovery](image-1.png)
107+
108+
To add HA LoRaWAN sensor discovery
109+
1. Edit the Decoder file to add these two functions. [Example](https://github.com/arendst/Tasmota/blob/development/tasmota/berry/lorawan/decoders/vendors/dragino/LHT52.be)
110+
1. `deviceInfo()`
111+
2. `HAssSensors()`
112+
113+
### How it works
114+
If [SetOption19](https://tasmota.github.io/docs/Commands/#setoptions) is 0 (default) then:
115+
1. `Device discovery` to the HA Tasmota Integration is enabled
116+
1. `LoRaWAN sensor discovery` to HA is enabled
117+
118+
119+
When the first LoRaWAN data packet from a paired device is received and decoded after bootup, and if the associated decoder file has the optional functions (above), a series of HA discovery MQTT messages are sent. One for each sensor.
120+
121+
122+
Example
123+
124+
![HA Discovery messages](image-2.png)
125+
```
126+
{
127+
"dev":{
128+
"mdl":"LHT52",
129+
"ids":"5390B0",
130+
"name":"T3S3",
131+
"mf":"Dragino"},
132+
"o":{
133+
"name":
134+
"T3S3"},
135+
"name":"Battery Voltage",
136+
"ic":"mdi:current-dc",
137+
"uniq_id":"tasmota_34B7DA5390B0_BattV",
138+
"pl_not_avail":"Offline",
139+
"val_tpl":"{{value_json['LwDecoded']['LHT52']['BattV']}}",
140+
"unit_of_meas":"V",
141+
"stat_t":"tele/LWG-T3S3_5390B0/SENSOR/A840414E4F5CAE3D",
142+
"device_cla":"voltage",
143+
"pl_avail":"Online",
144+
"avty_t":"tele/LWG-T3S3_5390B0/LWT",
145+
"state_cla":"measurement"
146+
}
147+
```

docs/image-1.png

15.3 KB
Loading

docs/image-2.png

8.53 KB
Loading

docs/image.png

19.3 KB
Loading

0 commit comments

Comments
 (0)