Voici un Flow très simple pour la gestion d’un éclairage par détection de mouvements (il n’est pas de moi mais je ne me souviens plus ou je l’ai pompé …)
Son fonctionnement est simple : Détection de mouvement => allumage de la lumière puis extinction au bout d’un temps déterminé.
Il y a les contrôles d’usage (lumières déjà allumées etc)
Code ci-dessous permettant d’importer le Flow dans votre node red
[
{
"id": "1d552762.ab8959",
"type": "server-state-changed",
"z": "aec169ba.0a9a68",
"name": "",
"server": "67f7a3d5.cd302c",
"version": 1,
"entityidfilter": "binary_sensor.mouvement_bureau",
"entityidfiltertype": "substring",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": false,
"x": 200,
"y": 480,
"wires": [
[
"e8e1c78b.d7e698"
]
]
},
{
"id": "73ae654a.077b0c",
"type": "api-call-service",
"z": "aec169ba.0a9a68",
"name": "",
"server": "67f7a3d5.cd302c",
"version": "1",
"service_domain": "switch",
"service": "turn_on",
"entityId": "switch.lumiere_plafond_bureau",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 1040,
"y": 540,
"wires": [
[]
]
},
{
"id": "5eafd061.4a9a8",
"type": "api-call-service",
"z": "aec169ba.0a9a68",
"name": "",
"server": "67f7a3d5.cd302c",
"version": "1",
"service_domain": "switch",
"service": "turn_off",
"entityId": "switch.lumiere_plafond_bureau",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 1040,
"y": 620,
"wires": [
[]
]
},
{
"id": "e8e1c78b.d7e698",
"type": "switch",
"z": "aec169ba.0a9a68",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
},
{
"t": "eq",
"v": "off",
"vt": "str"
}
],
"checkall": "true",
"outputs": 2,
"x": 380,
"y": 580,
"wires": [
[
"d9c3b588.3d24f8",
"f5290886.d95fd8"
],
[
"d9c3b588.3d24f8"
]
]
},
{
"id": "f5290886.d95fd8",
"type": "api-current-state",
"z": "aec169ba.0a9a68",
"name": "Lumière is Already On?",
"server": "67f7a3d5.cd302c",
"version": "1",
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"override_topic": true,
"entity_id": "switch.lumiere_plafond_bureau",
"state_type": "str",
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"blockInputOverrides": false,
"x": 808,
"y": 573,
"wires": [
[],
[
"73ae654a.077b0c"
]
]
},
{
"id": "d9c3b588.3d24f8",
"type": "stoptimer",
"z": "aec169ba.0a9a68",
"duration": "5",
"units": "Minute",
"payloadtype": "num",
"payloadval": "0",
"name": "20min",
"x": 580,
"y": 620,
"wires": [
[
"7b75beaf.c2b6"
],
[]
]
},
{
"id": "7b75beaf.c2b6",
"type": "api-current-state",
"z": "aec169ba.0a9a68",
"name": "Détecteur bureau Is on ?",
"server": "67f7a3d5.cd302c",
"version": "1",
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"override_topic": true,
"entity_id": "binary_sensor.mouvement_bureau",
"state_type": "str",
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"blockInputOverrides": false,
"x": 810,
"y": 640,
"wires": [
[],
[
"5eafd061.4a9a8"
]
]
},
{
"id": "67f7a3d5.cd302c",
"type": "server",
"z": "",
"name": "Home Assistant",
"legacy": false,
"hassio": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true
}
]