mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-22 10:16:30 +00:00
Fix LoRaWan Decoding when SO147 is enabled
This commit is contained in:
parent
28f4a07fd6
commit
0abe70816b
@ -4,19 +4,19 @@
|
|||||||
var LwRegions = ["EU868", "US915", "IN865","AU915","KZ865","RU864","AS923", "AS923-1","AS923-2","AS923-3"]
|
var LwRegions = ["EU868", "US915", "IN865","AU915","KZ865","RU864","AS923", "AS923-1","AS923-2","AS923-3"]
|
||||||
|
|
||||||
import mqtt
|
import mqtt
|
||||||
tasmota.cmd('SetOption100 off')
|
tasmota.cmd('SetOption100 off') # Keep LwReceived in JSON message
|
||||||
tasmota.cmd('SetOption118 off')
|
tasmota.cmd('SetOption118 off') # Keep SENSOR as subtopic name
|
||||||
tasmota.cmd('SetOption119 off')
|
tasmota.cmd('SetOption119 off') # Keep device address in JSON message
|
||||||
|
tasmota.cmd('SetOption147 on') # Hide LwReceived MQTT message but keep rule processing
|
||||||
tasmota.cmd('LoRaWanBridge on')
|
tasmota.cmd('LoRaWanBridge on')
|
||||||
var thisDevice = tasmota.cmd('Status',true)['Status']['Topic']
|
var thisDevice = tasmota.cmd('Status',true)['Status']['Topic']
|
||||||
var LwDecoders = {}
|
var LwDecoders = {}
|
||||||
var LwDeco
|
var LwDeco
|
||||||
|
|
||||||
def LwDecode(topic, idx, data, databytes)
|
def LwDecode(data)
|
||||||
import json
|
import json
|
||||||
|
|
||||||
var LwData = json.load(data)
|
var LwData = type(data)=='string' ? json.load(data) : data
|
||||||
if !LwData.contains('LwReceived') return true end # Processed
|
|
||||||
var deviceData = LwData['LwReceived']
|
var deviceData = LwData['LwReceived']
|
||||||
var deviceName = deviceData.keys()()
|
var deviceName = deviceData.keys()()
|
||||||
var Payload = deviceData[deviceName]['Payload']
|
var Payload = deviceData[deviceName]['Payload']
|
||||||
@ -31,6 +31,7 @@ def LwDecode(topic, idx, data, databytes)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Payload.size() && LwDecoders.find(decoder)
|
if Payload.size() && LwDecoders.find(decoder)
|
||||||
|
var topic = "tele/" + thisDevice + "/SENSOR"
|
||||||
var decoded = LwDecoders[decoder].decodeUplink(FPort, Payload)
|
var decoded = LwDecoders[decoder].decodeUplink(FPort, Payload)
|
||||||
var mqttData = {"LwDecoded":{deviceName:decoded}}
|
var mqttData = {"LwDecoded":{deviceName:decoded}}
|
||||||
mqtt.publish (topic, json.dump(mqttData))
|
mqtt.publish (topic, json.dump(mqttData))
|
||||||
@ -39,4 +40,4 @@ def LwDecode(topic, idx, data, databytes)
|
|||||||
return true #processed
|
return true #processed
|
||||||
end
|
end
|
||||||
|
|
||||||
mqtt.subscribe("tele/" + thisDevice + "/SENSOR",LwDecode)
|
tasmota.add_rule("LwReceived", /value, trigger, payload -> LwDecode(payload))
|
Loading…
x
Reference in New Issue
Block a user