Good morning,
I'm relaunching a post to move forward with the image selection through comparisons because I had put a little aside.
Here is the first topic I started:
https://discourse.nodered.org/t/image-selection-by-comparison/91043
I tried to link in my template node as I was advised :
Here is the flow I set up:
[
{
"id": "05c47a899779d1ba",
"type": "mqtt in",
"z": "a3c2cda0fd0187df",
"name": "",
"topic": "Etat/capteur/portail/ouvert",
"qos": "2",
"datatype": "auto-detect",
"broker": "b690438f99f8231b",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 150,
"y": 360,
"wires": [
[
"939930196a253988",
"73f3b35b4398ef57"
]
]
},
{
"id": "be6e73f796b9f46c",
"type": "mqtt in",
"z": "a3c2cda0fd0187df",
"name": "",
"topic": "Etat/capteur/portail/ferme",
"qos": "2",
"datatype": "auto-detect",
"broker": "b690438f99f8231b",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 150,
"y": 420,
"wires": [
[
"9cb6f5ff2f452414",
"a1f18da35dd4a5a8"
]
]
},
{
"id": "939930196a253988",
"type": "change",
"z": "a3c2cda0fd0187df",
"name": "Change topic open",
"rules": [
{
"t": "change",
"p": "topic",
"pt": "msg",
"from": "Etat/capteur/portail/ouvert",
"fromt": "str",
"to": "open",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 390,
"y": 300,
"wires": [
[
"ac4c4104c6383254"
]
]
},
{
"id": "ac4c4104c6383254",
"type": "join",
"z": "a3c2cda0fd0187df",
"name": "Jonction des topics",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": true,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 440,
"y": 380,
"wires": [
[
"91533b8eec6b8189"
]
]
},
{
"id": "9cb6f5ff2f452414",
"type": "change",
"z": "a3c2cda0fd0187df",
"name": "Change topic close",
"rules": [
{
"t": "change",
"p": "topic",
"pt": "msg",
"from": "Etat/capteur/portail/ferme",
"fromt": "str",
"to": "close",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 390,
"y": 480,
"wires": [
[
"ac4c4104c6383254"
]
]
},
{
"id": "91533b8eec6b8189",
"type": "switch",
"z": "a3c2cda0fd0187df",
"name": "Open",
"property": "payload.open",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
},
{
"t": "eq",
"v": "1",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 630,
"y": 380,
"wires": [
[
"212535da6fa112f5"
],
[
"f55fb38745c98c88"
]
]
},
{
"id": "212535da6fa112f5",
"type": "switch",
"z": "a3c2cda0fd0187df",
"name": "Close",
"property": "payload.close",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
},
{
"t": "eq",
"v": "1",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 750,
"y": 360,
"wires": [
[],
[
"47d95921ea509417",
"76db506634486e02"
]
]
},
{
"id": "f55fb38745c98c88",
"type": "switch",
"z": "a3c2cda0fd0187df",
"name": "Close",
"property": "payload.close",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
},
{
"t": "eq",
"v": "1",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 750,
"y": 400,
"wires": [
[
"47d95921ea509417",
"76db506634486e02"
],
[
"47d95921ea509417",
"76db506634486e02"
]
]
},
{
"id": "73f3b35b4398ef57",
"type": "debug",
"z": "a3c2cda0fd0187df",
"name": "Ouvert",
"active": true,
"tosidebar": false,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 130,
"y": 280,
"wires": []
},
{
"id": "a1f18da35dd4a5a8",
"type": "debug",
"z": "a3c2cda0fd0187df",
"name": "Fermé",
"active": true,
"tosidebar": false,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 130,
"y": 500,
"wires": []
},
{
"id": "47d95921ea509417",
"type": "debug",
"z": "a3c2cda0fd0187df",
"name": "debug 142",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 870,
"y": 280,
"wires": []
},
{
"id": "76db506634486e02",
"type": "ui-template",
"z": "a3c2cda0fd0187df",
"group": "d8041a2154939ee4",
"page": "",
"ui": "",
"name": "",
"order": 2,
"width": 0,
"height": 0,
"head": "",
"format": "<template>\n\n <div>\n <img :scr = \"img\" style=\"width:100%\">\n </div>\n\n</template>\n\n<script>\n\nvar img;\nvar ouvert = \"/ouvert.png\";\nvar ferme = \"/ferme.png\";\nvar portillon = \"/portillon.png\";\n\nif (payload.open == 1 && payload.close == 0){\n var img = ferme;\n}\n\nif (payload.open == 0 && payload.close == 1){\nvar img = ouvert;\n}\n\nif (payload.open == 0 && payload.close == 1){\nvar img = portillon;\n}\n\n </script> \n",
"storeOutMessages": true,
"passthru": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 920,
"y": 380,
"wires": [
[
"27c10d8b1d73987f"
]
]
},
{
"id": "27c10d8b1d73987f",
"type": "debug",
"z": "a3c2cda0fd0187df",
"name": "debug 155",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 890,
"y": 460,
"wires": []
},
{
"id": "b690438f99f8231b",
"type": "mqtt-broker",
"name": "",
"broker": "192.168.1.13",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "d8041a2154939ee4",
"type": "ui-group",
"name": "Portail d'entrée",
"page": "242784246503bab6",
"width": "6",
"height": "1",
"order": 1,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "242784246503bab6",
"type": "ui-page",
"name": "Portails",
"ui": "acf62d88f4bd3d87",
"path": "portails",
"icon": "home",
"layout": "grid",
"theme": "18acbce16a65bbb8",
"breakpoints": [
{
"name": "Default",
"px": "0",
"cols": "3"
},
{
"name": "Tablet",
"px": "576",
"cols": "6"
},
{
"name": "Small Desktop",
"px": "768",
"cols": "9"
},
{
"name": "Desktop",
"px": "1024",
"cols": "12"
}
],
"order": 1,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "acf62d88f4bd3d87",
"type": "ui-base",
"name": "Maison",
"path": "/dashboard",
"includeClientData": true,
"acceptsClientConfig": [
"ui-notification",
"ui-control"
],
"showPathInSidebar": false,
"showPageTitle": true,
"navigationStyle": "default",
"titleBarStyle": "default"
},
{
"id": "18acbce16a65bbb8",
"type": "ui-theme",
"name": "Default Theme",
"colors": {
"surface": "#9ba50e",
"primary": "#0094ce",
"bgPage": "#eeeeee",
"groupBg": "#474747",
"groupOutline": "#000000"
},
"sizes": {
"density": "default",
"pagePadding": "12px",
"groupGap": "12px",
"groupBorderRadius": "4px",
"widgetGap": "12px"
}
}
]
Can you tell me if the script is good? and know what is blocking the display of the corresponding image ?
Thank you in advance for your help