i’ve done this through this nodered flow as the integration wasn’t stable enough during my tests. i also remembers that some sensors wasn’t implemented. it publish status and battery through mqtt integration and even receive temperature changes. it even send ON to the boiler if needed.
[
{
"id": "103b1fd4c70bd5ad",
"type": "tab",
"label": "Chaudière MQTT",
"disabled": false,
"info": "",
"env": []
},
{
"id": "fd3ce805ed926c80",
"type": "inject",
"z": "103b1fd4c70bd5ad",
"name": "timer",
"props": [],
"repeat": "15",
"crontab": "",
"once": true,
"onceDelay": "1",
"topic": "",
"x": 90,
"y": 420,
"wires": [
[
"248a31587c7960fe"
]
]
},
{
"id": "7b8330524ea2f4c4",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt chaudiere",
"topic": "tasmota/chaudiere/cmnd/POWER",
"qos": "0",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 620,
"y": 100,
"wires": []
},
{
"id": "9fabcb15eb75a432",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "compute action",
"func": "var res = {};\nvar miss = 0;\nfor (const [key, value] of Object.entries(msg.payload)) {\n if (value.device_type == 3) {\n name = value.room_name.replace(\" \", \"_\");// + \"_\" + value.device_name.replace(\" \", \"_\");\n if (value.temp < value.setpoint) {\n if (value.room_name != 'WC')\n miss += value.setpoint - value.temp;\n }\n res[name] = { \"status\": \"off\" };\n }\n}\n\nvar action = null;\nif (miss <= 0.5) {\n action = 'OFF';\n}\nif (miss >= 1.2) {\n action = 'ON';\n for (const [key, value] of Object.entries(msg.payload)) {\n if (value.device_type == 3) {\n name = value.room_name.replace(\" \", \"_\");// + \"_\" + value.device_name.replace(\" \", \"_\")\n if (value.temp < value.setpoint && value.room_name != 'WC') {\n status = 'heat';\n } else {\n status = 'off';\n }\n res[name] = { \"status\": status };\n }\n }\n}\nreturn [ { 'payload': action, 'heat': miss }, { \"payload\": res } ];",
"outputs": 2,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 400,
"y": 120,
"wires": [
[
"7b8330524ea2f4c4",
"87831a7d8384ba61"
],
[
"f1d30ee021d42cf6"
]
]
},
{
"id": "3355f9d8134bb8d5",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 590,
"y": 440,
"wires": [
[
"abcd09898c38c8b2",
"92e0fc2670adcad8",
"150d48cddfcad4b4"
]
]
},
{
"id": "bd0c8714d97255f4",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt thermostat",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 1100,
"y": 440,
"wires": []
},
{
"id": "abcd09898c38c8b2",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "config",
"func": "msg.topic = 'homeassistant/climate/' + msg.payload.room_name.replace(\" \", \"_\");\nmsg.payload.config = {}\nmsg.payload.config[\"~\"] = msg.topic;\nmsg.payload.config[\"uniq_id\"] = \"maxcube_\" + msg.payload.room_name.replace(\" \", \"_\");\nmsg.payload.config[\"name\"] = \"Thermostat \" + msg.payload.room_name;\nmsg.payload.config[\"modes\"] = [ \"heat\", \"off\" ]\nmsg.payload.config[\"mode_state_topic\"] = \"~/status\";\nmsg.payload.config[\"temp_cmd_t\"] = \"~/setpoint/set\";\nmsg.payload.config[\"temp_stat_t\"] = \"~/setpoint\";\nmsg.payload.config[\"curr_temp_t\"] = \"~/temp\";\nmsg.payload.config[\"min_temp\"] = \"12\";\nmsg.payload.config[\"max_temp\"] = \"25\";\nmsg.payload.config[\"temp_step\"] = \"0.5\";\nmsg.payload.config[\"preset_modes\"] = [ \"AUTO\", \"MANUAL\", \"BOOST\" ];\nmsg.payload.config[\"preset_mode_command_topic\"] = \"~/mode/set\";\nmsg.payload.config[\"preset_mode_state_topic\"] = \"~/mode\";\ndelete msg.parts;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 440,
"wires": [
[
"6e516fa2a5793285"
]
]
},
{
"id": "6e516fa2a5793285",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 830,
"y": 440,
"wires": [
[
"7ffcfab4ee726aaf"
]
]
},
{
"id": "7ffcfab4ee726aaf",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "suffix",
"func": "msg.topic = msg.topic + '/' + msg.key;\ndelete msg.key;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 440,
"wires": [
[
"bd0c8714d97255f4"
]
]
},
{
"id": "a9b073610ed0da42",
"type": "mqtt in",
"z": "103b1fd4c70bd5ad",
"name": "",
"topic": "",
"qos": "2",
"datatype": "auto",
"broker": "d7efe4ef4af81eb9",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 1,
"x": 850,
"y": 380,
"wires": [
[
"e9411a4bc76c03a2"
]
]
},
{
"id": "92e0fc2670adcad8",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "subscribe",
"func": "msgo = {}\nmsgo.action = 'subscribe'\nmsgo.topic = 'homeassistant/climate/' + msg.payload.room_name.replace(\" \", \"_\") + '/setpoint/set';\nvar persist = flow.get('persist', 'file');\nif (typeof persist == 'undefined') {\n persist = {};\n}\npersist[msgo.topic] = msg.payload.rf_address;\nflow.set('persist', persist, 'file');\nreturn msgo;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 720,
"y": 380,
"wires": [
[
"a9b073610ed0da42"
]
]
},
{
"id": "2ebfae9701dd6b68",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "decode",
"func": "var res = {};\nfor (const [key, value] of Object.entries(msg.payload)) {\n if (value.device_type) {\n name = value.room_name.replace(\" \", \"_\") + \"_\" + value.device_name.replace(\" \", \"_\");\n if (!(value.device_type in res))\n res[value.device_type] = {};\n res[value.device_type][name] = value;\n }\n}\nreturn [ { \"payload\": res[1] }, { \"payload\": res[3] }, { \"payload\": res[4] }, res ];",
"outputs": 4,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 380,
"y": 420,
"wires": [
[
"f3a618cb9b217476"
],
[
"3355f9d8134bb8d5"
],
[
"da37c30786c72470"
],
[]
]
},
{
"id": "f1d30ee021d42cf6",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 590,
"y": 160,
"wires": [
[
"835b0a70c0092e13"
]
]
},
{
"id": "87ccec39faacfbcc",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt thermostat etat",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 1120,
"y": 160,
"wires": []
},
{
"id": "835b0a70c0092e13",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "config",
"func": "msg.topic = 'homeassistant/climate/' + msg.parts.key.replace(\" \", \"_\");\ndelete msg.parts;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 160,
"wires": [
[
"f18cca60a898e6f9"
]
]
},
{
"id": "f18cca60a898e6f9",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 830,
"y": 160,
"wires": [
[
"6396fa8e0d2f7d94"
]
]
},
{
"id": "6396fa8e0d2f7d94",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "suffix",
"func": "msg.topic = msg.topic + '/' + msg.key;\ndelete msg.key;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 160,
"wires": [
[
"87ccec39faacfbcc"
]
]
},
{
"id": "f3a618cb9b217476",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 590,
"y": 280,
"wires": [
[
"8513a6b21cadce2a",
"74a4afe44b816105"
]
]
},
{
"id": "62f3a5b66c9cb055",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt valve",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 1090,
"y": 280,
"wires": []
},
{
"id": "8513a6b21cadce2a",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "config",
"func": "msg.topic = 'homeassistant/climate/' + msg.parts.key.replace(\" \", \"_\");\nmsg.payload.config = {}\nmsg.payload.config[\"~\"] = msg.topic;\nmsg.payload.config[\"uniq_id\"] = \"maxcube_valve_\" + msg.parts.key.replace(\" \", \"_\");\nmsg.payload.config[\"name\"] = \"Valve \" + msg.payload.room_name + \" / \" + msg.payload.device_name;\nmsg.payload.config[\"temp_cmd_t\"] = \"~/setpoint/set\";\nmsg.payload.config[\"temp_stat_t\"] = \"~/setpoint\";\nmsg.payload.config[\"curr_temp_t\"] = \"~/temp\";\nmsg.payload.config[\"min_temp\"] = \"12\";\nmsg.payload.config[\"max_temp\"] = \"25\";\nmsg.payload.config[\"temp_step\"] = \"0.5\";\ndelete msg.parts;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 280,
"wires": [
[
"aa8232289a396eff"
]
]
},
{
"id": "aa8232289a396eff",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 830,
"y": 280,
"wires": [
[
"27fc31acdbfffe24"
]
]
},
{
"id": "27fc31acdbfffe24",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "suffix",
"func": "msg.topic = msg.topic + '/' + msg.key;\ndelete msg.key;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 280,
"wires": [
[
"62f3a5b66c9cb055"
]
]
},
{
"id": "da37c30786c72470",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 590,
"y": 540,
"wires": [
[
"6c5e65de567ed8c2",
"ab2eac1169d5bf93"
]
]
},
{
"id": "110869ca1733d7fc",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt window",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 1090,
"y": 540,
"wires": []
},
{
"id": "6c5e65de567ed8c2",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "config",
"func": "msg.topic = 'homeassistant/binary_sensor/' + msg.parts.key.replace(\" \", \"_\");\nmsg.payload.config = {}\nmsg.payload.config[\"~\"] = msg.topic;\nmsg.payload.config[\"uniq_id\"] = \"maxcube_\" + msg.parts.key.replace(\" \", \"_\");\nmsg.payload.config[\"name\"] = \"Contact \" + msg.payload.room_name + \" / \" + msg.payload.device_name;\nmsg.payload.config[\"state_topic\"] = \"~/open\";\nmsg.payload.config[\"device_class\"] = \"window\";\nmsg.payload.config[\"payload_off\"] = \"false\";\nmsg.payload.config[\"payload_on\"] = \"true\";\ndelete msg.parts;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 540,
"wires": [
[
"ed64e89cb77da718"
]
]
},
{
"id": "ed64e89cb77da718",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 830,
"y": 540,
"wires": [
[
"034bc8bc91f49b79"
]
]
},
{
"id": "034bc8bc91f49b79",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "suffix",
"func": "msg.topic = msg.topic + '/' + msg.key;\ndelete msg.key;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 540,
"wires": [
[
"110869ca1733d7fc"
]
]
},
{
"id": "e9411a4bc76c03a2",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "get_rfaddress",
"func": "var persist = flow.get('persist', 'file');\nreturn { \"payload\": { \"rf_address\": persist[msg.topic], \"degrees\": parseFloat(msg.payload), \"mode\": \"MANUAL\" } };",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1000,
"y": 380,
"wires": [
[
"5991875a317f02fa"
]
]
},
{
"id": "5d446138a103fe2c",
"type": "delay",
"z": "103b1fd4c70bd5ad",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 1300,
"y": 380,
"wires": [
[
"248a31587c7960fe"
]
]
},
{
"id": "87831a7d8384ba61",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "config",
"func": "msgo = {};\nmsgo.payload = msg;\nmsgo.payload.heat = msgo.payload.heat.toFixed(1)\nmsgo.topic = 'homeassistant/sensor/maxcube_heat';\nmsgo.payload.config = {}\nmsgo.payload.config[\"~\"] = msgo.topic;\nmsgo.payload.config[\"uniq_id\"] = \"maxcube_heat\";\nmsgo.payload.config[\"name\"] = \"Chaudière Total\";\nmsgo.payload.config[\"state_topic\"] = \"~/heat\";\nmsgo.payload.config[\"unit_of_measurement\"] = \"°\";\nreturn msgo;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 590,
"y": 60,
"wires": [
[
"f855b4166b9fe922"
]
]
},
{
"id": "9288a4f985382537",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt chaudiere total",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 1020,
"y": 60,
"wires": []
},
{
"id": "f855b4166b9fe922",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 730,
"y": 60,
"wires": [
[
"9f45cc50a1240208"
]
]
},
{
"id": "9f45cc50a1240208",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "suffix",
"func": "msg.topic = msg.topic + '/' + msg.key;\ndelete msg.key;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 850,
"y": 60,
"wires": [
[
"9288a4f985382537"
]
]
},
{
"id": "29949c9d2834f922",
"type": "comment",
"z": "103b1fd4c70bd5ad",
"name": "boiler",
"info": "boiler management.\nCompute total of missing degrees in each room and turn on the boiler if needed.",
"x": 370,
"y": 80,
"wires": []
},
{
"id": "af681e641dcfc3b7",
"type": "comment",
"z": "103b1fd4c70bd5ad",
"name": "homeassistant",
"info": "send/receive to homeassistant",
"x": 400,
"y": 360,
"wires": []
},
{
"id": "f3a417bab7c65a6f",
"type": "http in",
"z": "103b1fd4c70bd5ad",
"name": "",
"url": "/cube",
"method": "post",
"upload": false,
"swaggerDoc": "",
"x": 420,
"y": 700,
"wires": [
[
"808c2d31a411d3ae",
"248a31587c7960fe"
]
]
},
{
"id": "808c2d31a411d3ae",
"type": "http response",
"z": "103b1fd4c70bd5ad",
"name": "",
"statusCode": "200",
"headers": {},
"x": 610,
"y": 740,
"wires": []
},
{
"id": "26ec92d3c27156f2",
"type": "comment",
"z": "103b1fd4c70bd5ad",
"name": "cube notification",
"info": "receive cube notification",
"x": 410,
"y": 660,
"wires": []
},
{
"id": "8d145d485d89195c",
"type": "http in",
"z": "103b1fd4c70bd5ad",
"name": "",
"url": "/cube",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 410,
"y": 740,
"wires": [
[
"808c2d31a411d3ae"
]
]
},
{
"id": "5991875a317f02fa",
"type": "maxcube in",
"z": "103b1fd4c70bd5ad",
"server": "9a07e5adcaeb56f7",
"x": 1160,
"y": 380,
"wires": [
[
"5d446138a103fe2c"
]
]
},
{
"id": "248a31587c7960fe",
"type": "maxcube out",
"z": "103b1fd4c70bd5ad",
"server": "9a07e5adcaeb56f7",
"singleMessage": true,
"x": 220,
"y": 420,
"wires": [
[
"9fabcb15eb75a432",
"2ebfae9701dd6b68"
]
]
},
{
"id": "f7cb83ab364fcd59",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt thermostat bat",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 1110,
"y": 480,
"wires": []
},
{
"id": "150d48cddfcad4b4",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "config",
"func": "msg.topic = 'homeassistant/sensor/' + msg.parts.key.replace(\" \", \"_\") + \"_battery\";\nmsg.payload.config = {}\nmsg.payload.config[\"~\"] = msg.topic;\nmsg.payload.config[\"uniq_id\"] = \"maxcube_\" + msg.parts.key.replace(\" \", \"_\") + \"_battery\";\nmsg.payload.config[\"name\"] = \"Thermostat \" + msg.payload.room_name + \" / \" + msg.payload.device_name + \" Battery\";\nmsg.payload.config[\"device_class\"] = \"battery\";\nmsg.payload.config[\"entity_category\"] = \"diagnostic\";\nmsg.payload.config[\"state_class\"] = \"measurement\";\nmsg.payload.config[\"state_topic\"] = \"~/battery_low\";\nmsg.payload.config[\"unit_of_measurement\"] = \"%\";\nmsg.payload.config[\"value_template\"] = '{{ 0 if value == \"true\" else 100 }}';\ndelete msg.parts;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 480,
"wires": [
[
"a51f87f02c4caa9c"
]
]
},
{
"id": "a51f87f02c4caa9c",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 830,
"y": 480,
"wires": [
[
"e4afa539314f57e0"
]
]
},
{
"id": "e4afa539314f57e0",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "suffix",
"func": "msg.topic = msg.topic + '/' + msg.key;\ndelete msg.key;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 480,
"wires": [
[
"f7cb83ab364fcd59"
]
]
},
{
"id": "81bd3c2349b324fd",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt valve bat",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 1100,
"y": 320,
"wires": []
},
{
"id": "74a4afe44b816105",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "config",
"func": "msg.topic = 'homeassistant/sensor/' + msg.parts.key.replace(\" \", \"_\") + \"_battery\";\nmsg.payload.config = {}\nmsg.payload.config[\"~\"] = msg.topic;\nmsg.payload.config[\"uniq_id\"] = \"maxcube_\" + msg.parts.key.replace(\" \", \"_\") + \"_battery\";\nmsg.payload.config[\"name\"] = \"Valve \" + msg.payload.room_name + \" / \" + msg.payload.device_name + \" Battery\";\nmsg.payload.config[\"device_class\"] = \"battery\";\nmsg.payload.config[\"entity_category\"] = \"diagnostic\";\nmsg.payload.config[\"state_class\"] = \"measurement\";\nmsg.payload.config[\"state_topic\"] = \"~/battery_low\";\nmsg.payload.config[\"unit_of_measurement\"] = \"%\";\nmsg.payload.config[\"value_template\"] = '{{ 0 if value == \"true\" else 100 }}';\ndelete msg.parts;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 320,
"wires": [
[
"cfbbccaac48a692f"
]
]
},
{
"id": "cfbbccaac48a692f",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 830,
"y": 320,
"wires": [
[
"66cde02a0101b7b3"
]
]
},
{
"id": "66cde02a0101b7b3",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "suffix",
"func": "msg.topic = msg.topic + '/' + msg.key;\ndelete msg.key;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 320,
"wires": [
[
"81bd3c2349b324fd"
]
]
},
{
"id": "5dcb6933d4102886",
"type": "mqtt out",
"z": "103b1fd4c70bd5ad",
"name": "mqtt window bat",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "d7efe4ef4af81eb9",
"x": 1100,
"y": 580,
"wires": []
},
{
"id": "ab2eac1169d5bf93",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "config",
"func": "msg.topic = 'homeassistant/sensor/' + msg.parts.key.replace(\" \", \"_\") + \"_battery\";\nmsg.payload.config = {}\nmsg.payload.config[\"~\"] = msg.topic;\nmsg.payload.config[\"uniq_id\"] = \"maxcube_\" + msg.parts.key.replace(\" \", \"_\") + \"_battery\";\nmsg.payload.config[\"name\"] = \"Contact \" + msg.payload.room_name + \" / \" + msg.payload.device_name + \" Battery\";\nmsg.payload.config[\"device_class\"] = \"battery\";\nmsg.payload.config[\"entity_category\"] = \"diagnostic\";\nmsg.payload.config[\"state_class\"] = \"measurement\";\nmsg.payload.config[\"state_topic\"] = \"~/battery_low\";\nmsg.payload.config[\"unit_of_measurement\"] = \"%\";\nmsg.payload.config[\"value_template\"] = '{{ 0 if value == \"true\" else 100 }}';\ndelete msg.parts;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 580,
"wires": [
[
"e8287865bfb90923"
]
]
},
{
"id": "e8287865bfb90923",
"type": "split",
"z": "103b1fd4c70bd5ad",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 830,
"y": 580,
"wires": [
[
"fbb85cba9aa4609c"
]
]
},
{
"id": "fbb85cba9aa4609c",
"type": "function",
"z": "103b1fd4c70bd5ad",
"name": "suffix",
"func": "msg.topic = msg.topic + '/' + msg.key;\ndelete msg.key;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 580,
"wires": [
[
"5dcb6933d4102886"
]
]
},
{
"id": "d7efe4ef4af81eb9",
"type": "mqtt-broker",
"name": "MQTT",
"broker": "10.68.69.5",
"port": "1883",
"clientid": "nodered",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "nodered/status",
"birthQos": "0",
"birthRetain": "true",
"birthPayload": "online",
"birthMsg": {},
"closeTopic": "nodered/status",
"closeQos": "0",
"closeRetain": "true",
"closePayload": "offline",
"closeMsg": {},
"willTopic": "nodered/status",
"willQos": "0",
"willRetain": "true",
"willPayload": "timeout",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "9a07e5adcaeb56f7",
"type": "maxcube-server",
"host": "10.68.69.120",
"port": "62910",
"disabled": false
}
]