I am new to using nodered.
I'm having quite a bit of difficulty in transforming and processing mqtt messages.
The goal is to transform a mqtt message and update the HA UI.
I created all the data as input_text, the data has the same name in the MQTT message.
I'm sending from an mqtt client messages that look like this.
/Test/demo/test : msg.payload : string[634]
"{"infos_chaudiere_temp_sonde" : "10",
"infos_chaudiere_temp_ext" : "10",
"infos_chaudiere_temp_salon" : "10",
"infos_chaudiere_consommation_jour_chauffage" : "10",
"infos_chaudiere_consommation_jour_eau_chaude" : "10",
"infos_chaudiere_consigne_temperature_confort " : "10",
"infos_chaudiere_consigne_temperature_reduit " : "10",
"infos_chaudiere_consigne_temperature_party " : "10",
"infos_chaudiere_consigne_temperature_eau_chaude" : "10",
"infos_chaudiere_temp_corps" : "10",
"infos_chaudiere_temp_ecs" : "10",
"infos_chaudiere_temp_fumées" : "10",
"infos_chaudiere_puissance" : "10",
"infos_chaudiere_temps_fonctionnement" : "10"}"
After the message arrives, I get this ( as you can see the decoded value is an empty string, why ?)!
27/03/2022, 12:48:47node: 99e3ae88da717887
msg :
object
domain: "input_text"
service: "set_value"
data: object
value: ""
entity_id: "input_text.infos_chaudiere_temp_sonde"
27/03/2022, 12:48:47node: 97dda74252a5ac22
/Test/demo/test : msg : Object
object
topic: "/Test/demo/test"
payload: object
domain: "input_text"
service: "set_value"
data: object
value: ""
entity_id: "input_text.infos_chaudiere_temp_sonde"
qos: 2
retain: false
_topic: "/Test/demo/test"
_msgid: "f5598f08dfbb326e"
Here is the nodered :
[
{
"id": "d76fc4e57706f6fe",
"type": "tab",
"label": "MQTT",
"disabled": false,
"info": "",
"env": []
},
{
"id": "69880985f1586235",
"type": "comment",
"z": "d76fc4e57706f6fe",
"name": "Chaudière",
"info": "",
"x": 80,
"y": 60,
"wires": []
},
{
"id": "e264a5db96aa8980",
"type": "mqtt in",
"z": "d76fc4e57706f6fe",
"name": "infos_chaudière",
"topic": "/Test/demo/test",
"qos": "2",
"datatype": "auto",
"broker": "6ce377512fcb384f",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 120,
"y": 120,
"wires": [
[
"d5185a7193d60f33",
"99e3ae88da717887"
]
]
},
{
"id": "99e3ae88da717887",
"type": "api-call-service",
"z": "d76fc4e57706f6fe",
"name": "",
"server": "11a90641.be375a",
"version": 5,
"debugenabled": true,
"domain": "input_text",
"service": "set_value",
"areaId": [],
"deviceId": [],
"entityId": [
"input_text.infos_chaudiere_temp_sonde"
],
"data": "{ \"value\" : \"{{payload.infos_chaudiere_temp_sonde}}\"}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"x": 380,
"y": 100,
"wires": [
[
"97dda74252a5ac22"
]
]
},
{
"id": "97dda74252a5ac22",
"type": "debug",
"z": "d76fc4e57706f6fe",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 590,
"y": 100,
"wires": []
},
{
"id": "d5185a7193d60f33",
"type": "debug",
"z": "d76fc4e57706f6fe",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 350,
"y": 160,
"wires": []
},
{
"id": "6ce377512fcb384f",
"type": "mqtt-broker",
"name": "",
"broker": "localhost",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
},
{
"id": "11a90641.be375a",
"type": "server",
"name": "Home Assistant",
"version": 2,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": false,
"cacheJson": false,
"heartbeat": false,
"heartbeatInterval": 30
}
]
Thanks for your help.
Bernard