Files
ThingsBoard/migration/convertVanity.ipynb
2023-06-03 11:42:26 -05:00

68 lines
1.5 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Device Name form: Jones Holton FW #2\n",
"#MQTT clientID form: jones-holton-fw-2"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Banay WW 18 #4 banay-ww-18-4\n"
]
}
],
"source": [
"deviceName = \"Banay WW 18 #4\"\n",
"def convertVanityToClientId(deviceName):\n",
" mqttClientId = []\n",
" for c in deviceName:\n",
" if c == \" \":\n",
" mqttClientId.append(\"-\")\n",
" elif c.isalnum():\n",
" mqttClientId.append(c.lower())\n",
" elif c == '\"':\n",
" mqttClientId.append(\"in\")\n",
" elif c == '-':\n",
" mqttClientId.append(c)\n",
" mqttClientId = \"\".join(mqttClientId)\n",
" return mqttClientId\n",
"print(deviceName, convertVanityToClientId(deviceName))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "thingsboard",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}