SwitchBot Blind Tilt BLE integration

Thanks for the confirmation, I will merge the changes into Theengs Decoder so it will also be included in the OpenMQTTGateway nightly development builds from tonight on.

Have you got both of these set to true?
"disc":true,"ohdisc":true

Make sure they are both set to true, then issue a restart command to the gateway.

After the restart the Blind Tilts should show up in your inbox.

Unfortunately please be aware that while OpenHAB states Home Assistant MQTT Components discovery, this only seems to be implemented half-baked, so you will likely need to manually adjust some of the discovered devicesā€™ properties.

Yep, both are true.

If Iā€™m not wrong, something should be published in homeassistant topic whith the informations needed to create the things.
But there are only the topics of the OpenMQTTGateway.

Finally, Iā€™ve created the things with channels manually.

I found this implementation of the Blind Tilt on Github, perhaps it will help to update this implementation.

And you issued a restart with both true?
Which is important to do with new devices, which all your Blinds Tilts were as they were only recognised and decoded after the newly amended decoder was included.

But Iā€™m glad to hear you got it working with creating the things and channels manually - as I also do myself for everything.
Nevertheless the discovery should work correctly with the steps above, and does for me with other sensors when testing. Not having the Blind Tilt here, but the property definitions are very much the same as for other decoders.

Yes :confused:

Can you give me a small example on how to operate the Blind Tilt from OMG ? (If itā€™s possible)

Then Iā€™m wondering if "disc":true needs to be sent with "save":true as toggling of discovery does in the HA UI?!? And then issuing a restart?!? Something to look into ā€¦

I usually create one single command string thing per gateway, along the lines of

Type string : mqtt_config_string_command        "string Command"    [ commandTopic="home/OMG_BLE/commands/MQTTtoBT/config" ]

with a related String item for this. Then set up your UI elements as you want them, likely with buttons, segmented controls, a slider for the openb percentage etc. as desired. Then in the rule(s) triggered by these UI elements send a OMG WRITE command like

MQTT_BT_Config_Command.sendCommand('{\"ble_write_address\":\"AA:BB:CC:DD:EE:FF\",\"mac_type\":1,\"ble_write_service\":\"aaaa\",\"ble_write_char\":\"bbbb",\"ble_write_value\":\"XXXXXXXX\",\"value_type\":\"HEX\",\"ttl\":4,\"immediate\":true}')

with the ble_write_value XXXXXXXX being the actual HEX command with the ending octet likely being the variable open percentage, and aaaa/bbbb the appropriate service and characteristic for writing the command to the SwitchBot Blind Tilt. All of which I donā€™t know by heart, and somehow canā€™t currently seem to find the repo where I saw it previously on GitHub :frowning:

Similar to what I wrote here for the SwitchBot Curtain

Anyone else got a Blind Tilt and these values at hand? Or best to have a fresh look again tomorrow :wink:

Well, the SwitchBot command structure for the Blind Tilt seems to be very similar/the same as the Curtain, so not sure if you have already tried it out with these.

Best to have some test runs in the Publish section of MQTT Explorer, with

Open : 570F4501010132 (Quiet Slow??)
Open : 570F450105FF32

Close UP: 570F4501010164 (Quiet Slow??)
Close UP: 570F450105FF64

Close DOWN: 570F4501010100 (Quiet Slow??)
Close DOWN: 570F450105FF00

And I would assume the service to be 0d00 (or fd3d in case of this Blind Tilt version?!?) as well, with the characteristic being 0002.

Be aware that there is an issue when sending concurrent connection commands in OpenMQTTGateway, so best to wait a few seconds between commands.

Let us know how you get on.

Unfortunately I donā€™t have so much time this weekend.
But will have a try in the next few days.

If I look in the Python code from my link (in device.py), write and service seemā€™s to be common to all SwitchBot devices.

image

Yes, I was suspecting that, but always good when users with actual SwitchBot devices get proactive in device implementations :wink: and with so many recent undocumented firmware and advertising data changes from SwitchBot one can never be sure :wink:

Any remaining uncertainties or verifications can also easily be done by anyone with a particular device and a mobile phone with nRF Connect installed.

So it is 0d00 and 0002, and making the last octet in the ble_write_value a variable to be concatenated into the WRITE command, you should be all set.

Iā€™m just wondering if the raw open value should also be included in the decoder. Then it could be defined as a separate channel, directly linkable to a 0-100 slider item, with both the stateTopic and commandTopic in a single channel definition.

Let me know, when you get the time to implement this, if a raw_open property would be helpful, and with which kind of UI elements you are setting up the Blind Tilt control.

Something doesnā€™t workā€¦

I send this 2 payloads on home/OpenMQTTGateway/commands/MQTTtoBT/config :

{"ble_write_address":"D6:48:35:AF:72:BA","mac_type":1,"ble_write_service":"cba20d00-224d-11e6-9fb8-0002a5d5c51b","ble_write_char":"cba20002-224d-11e6-9fb8-0002a5d5c51b","ble_write_value":"570F4501010100","value_type":"HEX","ttl":4,"immediate":true}
{"ble_write_address":"D6:48:35:AF:72:BA","mac_type":1,"ble_write_service":"cba20d00-224d-11e6-9fb8-0002a5d5c51b","ble_write_char":"cba20002-224d-11e6-9fb8-0002a5d5c51b","ble_write_value":"570F450105FF00","value_type":"HEX","ttl":4,"immediate":true}

And nothing is moving :thinking:

You didnā€™t include the

,\"mac_type\":1

form my example above, which all SwitchBots, and any other "mac_type":1 devices, require, and is documented in the READ/WRITE section

Exactly the same issue with the linked Curtain thread on Github, when my suggested commands initially didnā€™t work :wink:

And you could also very possibly just use the 16-bit ble_write_service and ble_write_char instead of the long 128-bit ones.

And just to be on the completely safe side. Is your gateway name actually OpenMQTTGateway? This is only a place holder in all the command examples, but (hopefully obviously) needs to be replaced with the actual name of each individual gateway.

Let us know how it works with the mac_type included and the correct gateway name.

"mac_type":1 is the second parameter of my JSON stringā€¦

Yep the name of my gateway is OpenMQTTGateway.

A screenshot of MQTT Explorer :

And how about with the 16-bit ble_write_service and ble_write_char?
e. g.

{
ā€œble_write_addressā€:ā€œD6:48:35:AF:72:BAā€,
ā€œmac_typeā€:1,
ā€œble_write_serviceā€:ā€œ0d00ā€,
ā€œble_write_charā€:ā€œ0002ā€,
ā€œble_write_valueā€: ā€œ570f450105ff00ā€,
ā€œvalue_typeā€: ā€œHEXā€,
ā€œttlā€: 4,
ā€œimmediateā€: true
}

Nopā€¦

{"ble_write_address":"D6:48:35:AF:72:BA","mac_type":1,"ble_write_service":"0d00","ble_write_char":"0002","ble_write_value":"570F4501010132","value_type":"HEX","ttl":4,"immediate":true}
{"ble_write_address":"D6:48:35:AF:72:BA","mac_type":1,"ble_write_service":"0d00","ble_write_char":"0002","ble_write_value":"570F450105FF32","value_type":"HEX","ttl":4,"immediate":true}

I let 200 ms between the 2 commands.

Might actually still be too close causing the gateway crash and restart, until the issue is fixed.

Should be visible through the gateway uptime in SYStoMQTT.

While I know that your linked Python implementation seems to indicate that both commands are required, I am not really too sure about that, as the Curtain implementation looks much the same, but only really needs a single command - thatā€™s why I also commented these commands with (Quiet Slow??)

Could you just try the single command I just now gave above? I. e. your second command, or also try it with the single first command.

DANG!!! my bad, your bad, we just really donā€™t read the docs properly :stuck_out_tongue_winking_eye:

The READ/WRITE commands must not have the /config at the end, somehow makes sense, as we do not want to set any config setting of the gateway, but READ or WRITE a command.

So, send the Blind Tilt commands to
home/OpenMQTTGateway/commands/MQTTtoBT

How does it work then?

Uptime is OK.

Here is the info in the console of the OMG :

N: [ MQTT->OMG ]: {"ble_write_address":"D6:48:35:AF:72:BA","mac_type":1,"ble_write_service":"cba20d00-224d-11e6-9fb8-0002a5d5c51b","ble_write_char":"cba20002-224d-11e6-9fb8-0002a5d5c51b","ble_write_value":"570f4501010132","value_type":"HEX","ttl":4,"immediate":true}
N: Send on /BTtoMQTT msg {"bleconnect":true,"interval":55555,"adaptivescan":true,"intervalacts":55555,"intervalcnct":3600000,"scanduration":10000,"onlysensors":false,"randommacs":false,"hasspresence":false,"prestopic":"presence/","presuseuuid":false,"minrssi":-100,"extDecoderEnable":false,"extDecoderTopic":"undecoded","filterConnectable":false,"pubadvdata":false,"pubuuid4topic":false,"ignoreWBlist":false,"presenceawaytimer":120000,"movingtimer":60000,"forcepscn":false,"tskstck":2280,"crstck":3004,"enabled":true,"scnct":7173}
N: [ MQTT->OMG ]: {"ble_write_address":"D6:48:35:AF:72:BA","mac_type":1,"ble_write_service":"cba20d00-224d-11e6-9fb8-0002a5d5c51b","ble_write_char":"cba20002-224d-11e6-9fb8-0002a5d5c51b","ble_write_value":"570f450105ff32","value_type":"HEX","ttl":4,"immediate":true}
N: Send on /BTtoMQTT msg {"bleconnect":true,"interval":55555,"adaptivescan":true,"intervalacts":55555,"intervalcnct":3600000,"scanduration":10000,"onlysensors":false,"randommacs":false,"hasspresence":false,"prestopic":"presence/","presuseuuid":false,"minrssi":-100,"extDecoderEnable":false,"extDecoderTopic":"undecoded","filterConnectable":false,"pubadvdata":false,"pubuuid4topic":false,"ignoreWBlist":false,"presenceawaytimer":120000,"movingtimer":60000,"forcepscn":false,"tskstck":2280,"crstck":3004,"enabled":true,"scnct":7173}

OK now if I send the command to home/OpenMQTTGateway/commands/MQTTtoBT, each time I send a command, the OMG crash :sweat_smile:

Iā€™ve changed the delay between the 2 commands to 2000 ms, but it still crash.
If I only send the first command, it crash too. :grimacing:

Sorry about that, but I am just experiencing the very same here myself, when issuing a READ command which previously always worked.

Give us some time to look into this with the current development version.

Will let you know here when things are sorted and fixed, so that we all can properly send READ and WRITE commands again :wink:

OK no problems, thanks for your help !

Oh and I finaly get the Blind Tilt in the inbox in openHABā€¦
To avoid problems, Iā€™ve removed the topic home/OpenMQTTGateway/commands/MQTTtoBT from my MQTT server and after the 1st OMG crash, the things were in the inbox.
I had set a whitelist with a retain flag, probably the cause of the non creation of the values in the homeassistant topic.