Forum Francophone Home Assistant

Flow Gestion éclairage sur détection de mouvements

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
    }
]
3 J'aimes

Bonjour,
Pourrais-tu m’indiquer le procédure à suivre pour « importer le flow dans le node-red » ?
[Edit] Finalement j’ai trouvé (depuis le menu import de node red).

2 J'aimes

bonsoir je m’essaye a node red.
et je souhaite rajouter un lux-metre a ton flow.

et le code

Résumé

[{"id":"106719c5.e0dd46","type":"tab","label":"test lampe","disabled":false,"info":""},{"id":"c453c6a4.40f258","type":"inject","z":"106719c5.e0dd46","name":"éteint lampes salon","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"eteint","payload":"false","payloadType":"str","x":210,"y":400,"wires":[["32d3c78e.46cc28"]]},{"id":"8e8e0957.933068","type":"api-call-service","z":"106719c5.e0dd46","name":"","server":"4e189928.780ea8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.lampe_salon","data":"","dataType":"jsonata","mergecontext":"","output_location":"marche","output_location_type":"msg","mustacheAltTags":false,"x":1050,"y":20,"wires":[[]]},{"id":"32d3c78e.46cc28","type":"api-call-service","z":"106719c5.e0dd46","name":"","server":"4e189928.780ea8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.lampe_salon","data":"","dataType":"jsonata","mergecontext":"","output_location":"eteint","output_location_type":"msg","mustacheAltTags":false,"x":1050,"y":400,"wires":[[]]},{"id":"f554f24c.8121d","type":"inject","z":"106719c5.e0dd46","name":"allume lampes salon","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"allumé","payload":"true","payloadType":"str","x":210,"y":20,"wires":[["8e8e0957.933068"]]},{"id":"16fc6324.2d3a3d","type":"delay","z":"106719c5.e0dd46","name":"tempo","pauseType":"delay","timeout":"10","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":450,"y":300,"wires":[["e8940c5c.b3496"]]},{"id":"33150074.31d9e","type":"server-state-changed","z":"106719c5.e0dd46","name":"présence salon","server":"4e189928.780ea8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.presence_salon","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":80,"y":200,"wires":[["e4f1a5ab.d45088"]]},{"id":"1936e199.5ff82e","type":"api-current-state","z":"106719c5.e0dd46","name":"Lux salon","server":"4e189928.780ea8","version":1,"outputs":2,"halt_if":"150","halt_if_type":"num","halt_if_compare":"lte","override_topic":false,"entity_id":"sensor.lux_salon","state_type":"num","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":860,"y":220,"wires":[["8e8e0957.933068"],["32d3c78e.46cc28"]]},{"id":"e4f1a5ab.d45088","type":"switch","z":"106719c5.e0dd46","name":"oui/non?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":280,"y":200,"wires":[["7d441cae.3ba704"],["16fc6324.2d3a3d"]]},{"id":"e8940c5c.b3496","type":"api-current-state","z":"106719c5.e0dd46","name":"présence salon ?","server":"4e189928.780ea8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.presence_salon","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":630,"y":300,"wires":[["1936e199.5ff82e"],["32d3c78e.46cc28"]]},{"id":"7d441cae.3ba704","type":"api-current-state","z":"106719c5.e0dd46","name":"lumiere éteintes ?","server":"4e189928.780ea8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"group.lampe_salon","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":550,"y":120,"wires":[["1936e199.5ff82e"],[]]},{"id":"4e189928.780ea8","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]