Oui mais sur mon volet je n’ai pas opening et closing
En tout cas je ne vois pas du tout où c’est si je l’ai !
J’ai tiens quelques choses en faisant ceci :
[
{
"id": "567d18c9dc769018",
"type": "api-current-state",
"z": "678e5b75cdd9e231",
"name": "",
"server": "e4803443912781dd",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "cover.vr_ch_parents",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 1260,
"y": 1000,
"wires": [
[
"84aca8929fa726f4"
]
]
},
{
"id": "84aca8929fa726f4",
"type": "function",
"z": "678e5b75cdd9e231",
"name": "Position VR",
"func": "var position = msg.data.attributes.current_position\n//var data.new_state.attributes.current_position\n\nif (position > 90 && position <=100){\n msg.position = position;\n msg.url = 'https://i.imgur.com/euE8rQi.png';\n msg.icon_url = 'https://i.imgur.com/euE8rQi.png';\n} else if(position > 80 && position <= 90){\n msg.position = position;\n msg.url = 'https://i.imgur.com/25kEzgz.png';\n msg.icon_url = 'https://i.imgur.com/25kEzgz.png';\n} else if (position > 70 && position <= 80) {\n msg.position = position;\n msg.url = 'https://i.imgur.com/8qVV7Gt.png';\n msg.icon_url = 'https://i.imgur.com/8qVV7Gt.png';\n} else if (position > 60 && position <= 70) {\n msg.position = position;\n msg.url = 'https://i.imgur.com/mpv2JZ5.png';\n msg.icon_url = 'https://i.imgur.com/mpv2JZ5.png';\n} else if (position > 50 && position <= 60) {\n msg.position = position;\n msg.url = 'https://i.imgur.com/ZU7w1mR.png';\n msg.icon_url = 'https://i.imgur.com/ZU7w1mR.png';\n} else if (position > 40 && position <= 50) {\n msg.position = position;\n msg.url = 'https://i.imgur.com/7GHZeDx.png';\n msg.icon_url = 'https://i.imgur.com/7GHZeDx.png';\n} else if (position > 30 && position <= 40) {\n msg.position = position;\n msg.url = 'https://i.imgur.com/hrvZuss.png';\n msg.icon_url = 'https://i.imgur.com/hrvZuss.png';\n} else if (position > 20 && position <= 30) {\n msg.position = position;\n msg.url = 'https://i.imgur.com/cDFtyWw.png';\n msg.icon_url = 'https://i.imgur.com/cDFtyWw.png';\n} else if (position > 10 && position <= 20) {\n msg.position = position;\n msg.url = 'https://i.imgur.com/cztSRBY.png';\n msg.icon_url = 'https://i.imgur.com/cztSRBY.png';\n} else {\n msg.position = position;\n msg.url = 'https://i.imgur.com/id9Pv6R.png';\n msg.icon_url = 'https://i.imgur.com/id9Pv6R.png';\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1510,
"y": 1000,
"wires": [
[
"14f1e30e0b017d37"
]
]
},
{
"id": "14f1e30e0b017d37",
"type": "function",
"z": "678e5b75cdd9e231",
"name": "Embed ON",
"func": "const msg1 = {};\nvar time = new Date();\nvar heure = time.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}) //.toLocaleTimeString('fr-FR');\n//var position = msg.position\n\nglobal.set(\"heure_debut\",heure);\n\nmsg1.channel = \"1050807293509374003\";\nmsg1.payload = \"\";\nmsg.message = \"msg.message\"\nmsg1.embeds = {\n color: '#FFD700',\n title: \"VR CH Parents - Node Function Cron VR\",\n\tdescription: \"Le volet de la chambre vient de s'ouvrir à : **\" + heure + \"** à la position : \" + \"**\" + msg.position + \"**\",\n author: {\n\t\tname: \"Gestion des Volets Roulants\",\n\t\ticon_url: msg.icon_url,\n\t\turl: 'https://148lx7gf3ch3nj9c1c5s2zmx5nwh9wtb.ui.nabu.casa/lovelace/ch-parents',\n\t},\n thumbnail: {\n\t\turl: msg.url,\n\t},\n\ttimestamp: new Date(),\n footer: {\n\t\ttext: 'Flow Volets HA - Node Red',\n\t\ticon_url: 'https://i.imgur.com/7NuCa93.png',\n\t},\n};\n\nreturn msg1;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1690,
"y": 1000,
"wires": [
[
"2d2ec940f38ebd00"
]
]
},
{
"id": "2d2ec940f38ebd00",
"type": "discordMessageManager",
"z": "678e5b75cdd9e231",
"name": "",
"channel": "",
"token": "",
"x": 1910,
"y": 1000,
"wires": [
[]
]
},
{
"id": "59c10b4cd8b48666",
"type": "server-events",
"z": "678e5b75cdd9e231",
"name": "",
"server": "e4803443912781dd",
"version": 2,
"eventType": "call_service",
"exposeToHomeAssistant": false,
"eventData": "",
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"waitForRunning": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "$outputData(\"eventData\").event_type",
"valueType": "jsonata"
}
],
"event_type": "",
"x": 670,
"y": 1000,
"wires": [
[
"96706cca83839f6a"
]
]
},
{
"id": "96706cca83839f6a",
"type": "switch",
"z": "678e5b75cdd9e231",
"name": "",
"property": "payload.event.service",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "stop_cover",
"vt": "str"
},
{
"t": "eq",
"v": "set_cover_position",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 850,
"y": 1000,
"wires": [
[
"9e9c0ed428803ac3"
],
[
"9e9c0ed428803ac3"
],
[]
]
},
{
"id": "9e9c0ed428803ac3",
"type": "delay",
"z": "678e5b75cdd9e231",
"name": "",
"pauseType": "delay",
"timeout": "500",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 1010,
"y": 1000,
"wires": [
[
"567d18c9dc769018"
]
]
},
{
"id": "e4803443912781dd",
"type": "server",
"name": "HA domojeca",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": "at: ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": true
}
]
Un inconvénient à ceci c’est que sur le service set_cover_position
j’ai l’info de suite alors que le VR est encore en mouvement mais il y a de l’idée du rendu que je souhaite.
Du coup je viens de m’apercevoir aussi que je ne sais pas mettre en variable Node Red la valeur de la position
du genre comme ceci
