|
1 | 1 | # LoRaWan Decoders |
2 | 2 |
|
| 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 |
3 | 12 | LoRaWan end devices transmit packets containing raw _Payload Data_. The Tasmota _LoRaWan Bridge_ feature normally passes the raw _Payload Data_ onto an MQTT server. |
4 | 13 | ``` |
5 | 14 | { |
@@ -87,3 +96,52 @@ Alternatively, find the manufacturer's datasheet/User Guide/User Manual/etc. to |
87 | 96 | 6. Submit a [PR](https://github.com/arendst/Tasmota/pulls) to share your new decoder with the Tasmota community. |
88 | 97 |
|
89 | 98 |
|
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | +``` |
0 commit comments