Hi Guys,
Having issues trying to get the BLE Bridge working.
- Node Red Cmnd Issue
- Unable to distinguish data.
I’ve got one of the Arlec BLE Bridges as per this Tasmota Page: https://templates.blakadder.com/arlec_SGS01HA.html
They are easy to get and relatively cheap from Bunnings.
I’m using this as a Sensor net in my garage.
2 x Motion Sensors
3 x Contact Sensors
2 x Temp Sensors
I have configured using the TUYA/Arlec App and paired all sensors to confirm they work. I have then flashed Tamota basic as per the instructions. Where i am stuck is how to decode the messages.
I’m using this code in a Function on Node Red:
// Get Message Payload
var payload = msg.payload
// Ignore Everything but Cmnd 54
if(payload.TuyaReceived.Cmnd != "54") { return }
// Extract the Sensor Hub ID
var Data = payload.TuyaReceived.Data;
var sensorHubID = Data.substr(0,12)
// Extract the Sensor Data Values
var CmndData = payload.TuyaReceived.CmndData;
var updateID = CmndData.substr(0,6); // Each sensor+battery update shares this string
var sensorNumber = parseInt(CmndData.substr(6,2));
var sensorType = CmndData.substr(8,6);
var sensorValue = CmndData.substr(14);
// Processing
switch(sensorType) {
case "4F0204":
sensorType = "TEMP"
fahrenheit = parseInt(sensorValue,16)
celsius = (fahrenheit - 32) * 0.555555555555555
sensorValue = parseInt(celsius)
break;
case "4E0204":
sensorType = "HUMIDITY"
humidity = parseInt(sensorValue,16)
sensorValue = parseInt(humidity)
break;
case "630204":
sensorType = "INTERVAL"
value = parseInt(value, 16) / 60 // Returns the interval in minutes at which the temp/humidity sensor will send an update. Interval is changed by pressing the button on the sensor
break;
case "5B0101":
sensorType = "CONTACT"
sensorValue = parseInt(sensorValue)
break;
case "5C0101":
sensorType = "MOTION"
sensorValue = parseInt(sensorValue)
break;
case "640204":
sensorHubID = (parseInt("55AA0136000B",16) - 3).toString(16).toUpperCase()
sensorType = "BATTERY"
percentage = parseInt(sensorValue,16)
sensorValue = percentage
break;
}
var topic = "tasmota_4003E1/BLE" + sensorNumber + "/" + sensorType
var mqttMessage = { payload: sensorValue, topic:topic };
var debugMessage = { mqtt : mqttMessage,
sensorhubid : sensorHubID,
sensornumber : sensorNumber,
sensortype : sensorType,
sensorvalue : sensorValue,
updateid : updateID, data : Data,
cmnddata : CmndData };
return [mqttMessage,debugMessage];
I have a contact sensor at my desk, which i can use to trigger a response in the messages being sent, but i have two issues:
-
The Code above is giving me a Debug Message: “TypeError: Cannot read property ‘Cmnd’ of undefined”
-
I can see a response change with the contact sensor, but unsure how to take it further in MQTT or NodeRed, and then finally to a sensor on HomeAssistant.
Finally, from the Tasmota Console with my BLE Contact Sensor:
Contact Closed:
02:10:21 RUL: TUYARECEIVED#CMND==54 performs ">Publish BleBridge/tele/command 802D060664020400000064"
02:10:25 MQT: tele/tasmota_4003E1/RESULT = {"TuyaReceived":{"Data":"55AA01070008010100FE050000FD11","Cmnd":7,"CmndData":"010100FE050000FD","DpType1Id1":"0x050000FD110064C855786671312E30","1":{"DpId":1,"DpIdType":1,"DpIdData":"050000FD110064C855786671312E30"},"DpType254Id0":"0x00FD110064C855786671312E302E30","0":{"DpId":0,"DpIdType":254,"DpIdData":"00FD110064C855786671312E302E30"}}}
02:10:25 RUL: TUYARECEIVED#CMNDDATA performs "var1 010100FE050000FD"
02:10:25 MQT: stat/tasmota_4003E1/RESULT = {"Var1":"010100FE050000FD"}
02:10:25 MQT: stat/tasmota_4003E1/RESULT = {"POWER":"ON"}
Contact Open:
02:11:31 RUL: TUYARECEIVED#CMND==54 performs ">Publish BleBridge/tele/command E8800B0664020400000064"
02:11:38 MQT: tele/tasmota_4003E1/RESULT = {"TuyaReceived":{"Data":"55AA010000010102","Cmnd":0,"CmndData":"01"}}
02:11:38 RUL: TUYARECEIVED#CMNDDATA performs "var1 01"
02:11:38 MQT: stat/tasmota_4003E1/RESULT = {"Var1":"01"}
02:11:42 MQT: tele/tasmota_4003E1/RESULT = {"TuyaReceived":{"Data":"55AA01070008010100FE050000FD11","Cmnd":7,"CmndData":"010100FE050000FD","DpType1Id1":"0x050000FD1100648855786671312E30","1":{"DpId":1,"DpIdType":1,"DpIdData":"050000FD1100648855786671312E30"},"DpType254Id0":"0x00FD1100648855786671312E302E30","0":{"DpId":0,"DpIdType":254,"DpIdData":"00FD1100648855786671312E302E30"}}}
02:11:42 RUL: TUYARECEIVED#CMNDDATA performs "var1 010100FE050000FD"