Home Assistant - powiadamianie o otwartym oknie gdy temperatura spada

Home Assistant - powiadamianie o otwartym oknie gdy temperatura spada

Zdarza się Wam w okresie wiosennym/jesiennym, zapomnieć zamknąć okno gdy słońce już zachodzi i robi się zimno? Mnie niestety bardzo często! 

O nie, znowu zmarły mi stopy! Postanowiłem z tym skończyć - przecież tak być nie może! ;) Zrobiłem szybką automatyzację, która powiadomi mnie o nie zamkniętych oknach na głośniki Google gdy temperatura na zewnątrz spadnie poniżej 16 stopni - oczywiście tylko wtedy kiedy jesteśmy w domu.

Automatyzacja prosta

Po prostu ma mnie powiadomić, że mam nie zamknięte okna i warto to zrobić.

Kod Node-RED:

[
    {
        "id": "406208bc.d24e48",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "Wather Out <16",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.weather_tmp",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "num",
        "haltifstate": "16",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 260,
        "y": 1260,
        "wires": [
            [
                "39e3ef2b.e4088"
            ],
            []
        ]
    },
    {
        "id": "fd8511a5.2ac27",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Awesome w domu?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "group.awesome_people",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 890,
        "y": 1420,
        "wires": [
            [
                "880cd931.ca6f28",
                "2ff487d5.38c478"
            ],
            []
        ]
    },
    {
        "id": "459eb74.78ff548",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Balcony window open?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "binary_sensor.balcony_window",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 580,
        "y": 1340,
        "wires": [
            [
                "77b6cf1b.9f241"
            ],
            [
                "f505d13e.4b933"
            ]
        ]
    },
    {
        "id": "880cd931.ca6f28",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Zimno zamknij okno!",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "debugenabled": false,
        "service_domain": "tts",
        "service": "google_translate_say",
        "entityId": "media_player.mini_hallway",
        "data": "{\"message\":\"Zimno zamknij okno!\",\"language\":\"pl\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "mustacheAltTags": false,
        "x": 1100,
        "y": 1360,
        "wires": [
            []
        ]
    },
    {
        "id": "f505d13e.4b933",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Balcony door open?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "binary_sensor.balcony_door",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 580,
        "y": 1420,
        "wires": [
            [
                "77b6cf1b.9f241"
            ],
            [
                "ac55368.e5869c8"
            ]
        ]
    },
    {
        "id": "ac55368.e5869c8",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Office window open?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "binary_sensor.office_window",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 580,
        "y": 1500,
        "wires": [
            [
                "77b6cf1b.9f241"
            ],
            [
                "b47fabe4.0decd8"
            ]
        ]
    },
    {
        "id": "b47fabe4.0decd8",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Bedroom window open?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "binary_sensor.bedroom_window",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 570,
        "y": 1580,
        "wires": [
            [
                "77b6cf1b.9f241"
            ],
            []
        ]
    },
    {
        "id": "77b6cf1b.9f241",
        "type": "trigger",
        "z": "e47906ea.f77ce8",
        "op1": "",
        "op2": "",
        "op1type": "nul",
        "op2type": "payl",
        "duration": "5",
        "extend": true,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "name": "",
        "x": 860,
        "y": 1360,
        "wires": [
            [
                "fd8511a5.2ac27"
            ]
        ]
    },
    {
        "id": "88c129cd.7c08a8",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Zimno zamknij okno!",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "debugenabled": false,
        "service_domain": "tts",
        "service": "google_translate_say",
        "entityId": "media_player.office",
        "data": "{\"message\":\"Zimno zamknij okno!\",\"language\":\"pl\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "mustacheAltTags": false,
        "x": 1100,
        "y": 1520,
        "wires": [
            []
        ]
    },
    {
        "id": "2ff487d5.38c478",
        "type": "trigger",
        "z": "e47906ea.f77ce8",
        "op1": "",
        "op2": "",
        "op1type": "nul",
        "op2type": "payl",
        "duration": "5",
        "extend": true,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "name": "",
        "x": 900,
        "y": 1520,
        "wires": [
            [
                "88c129cd.7c08a8"
            ]
        ]
    },
    {
        "id": "39e3ef2b.e4088",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Temperature weather <16",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "16",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "override_topic": false,
        "entity_id": "sensor.weather_tmp",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 550,
        "y": 1260,
        "wires": [
            [
                "459eb74.78ff548"
            ],
            []
        ]
    },
    {
        "id": "9e338ba4.b10d78",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "Awesome w domu",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "group.awesome_people",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 270,
        "y": 1320,
        "wires": [
            [
                "39e3ef2b.e4088"
            ],
            []
        ]
    }
]

Automatyzacja rozbudowana

Przecież nie będę latał z pokoju do pokoju szukając otwartego okna, zrobimy to inaczej! 

Kod Node-RED:

[
    {
        "id": "406208bc.d24e48",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "Wather Out <16",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.weather_tmp",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "num",
        "haltifstate": "16",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 120,
        "y": 1260,
        "wires": [
            [
                "39e3ef2b.e4088"
            ],
            []
        ]
    },
    {
        "id": "459eb74.78ff548",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Balcony window open?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "binary_sensor.balcony_window",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 440,
        "y": 1380,
        "wires": [
            [
                "88c129cd.7c08a8"
            ],
            [
                "f505d13e.4b933"
            ]
        ]
    },
    {
        "id": "880cd931.ca6f28",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Zimno zamknij w gabinecie!",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "debugenabled": false,
        "service_domain": "tts",
        "service": "google_translate_say",
        "entityId": "media_player.office",
        "data": "{\"message\":\"Zimno zamknij w gabinecie!\",\"language\":\"pl\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "mustacheAltTags": false,
        "x": 780,
        "y": 1520,
        "wires": [
            []
        ]
    },
    {
        "id": "f505d13e.4b933",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Balcony door open?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "binary_sensor.balcony_door",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 440,
        "y": 1460,
        "wires": [
            [
                "88c129cd.7c08a8"
            ],
            [
                "ac55368.e5869c8"
            ]
        ]
    },
    {
        "id": "ac55368.e5869c8",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Office window open?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "binary_sensor.office_window",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 440,
        "y": 1540,
        "wires": [
            [
                "880cd931.ca6f28"
            ],
            [
                "b47fabe4.0decd8"
            ]
        ]
    },
    {
        "id": "b47fabe4.0decd8",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Bedroom window open?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "binary_sensor.bedroom_window",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 430,
        "y": 1620,
        "wires": [
            [
                "88bec8c1.140fb8"
            ],
            []
        ]
    },
    {
        "id": "88c129cd.7c08a8",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Zimno zamknij okno w dziennym!",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "debugenabled": false,
        "service_domain": "tts",
        "service": "google_translate_say",
        "entityId": "media_player.mini_hallway",
        "data": "{\"message\":\"Zimno zamknij okno w dziennym!\",\"language\":\"pl\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "mustacheAltTags": false,
        "x": 800,
        "y": 1420,
        "wires": [
            []
        ]
    },
    {
        "id": "39e3ef2b.e4088",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Temperature weather <16",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "16",
        "halt_if_type": "num",
        "halt_if_compare": "lt",
        "override_topic": false,
        "entity_id": "sensor.weather_tmp",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 410,
        "y": 1280,
        "wires": [
            [
                "13bab6fc.b61ec9"
            ],
            []
        ]
    },
    {
        "id": "9e338ba4.b10d78",
        "type": "server-state-changed",
        "z": "e47906ea.f77ce8",
        "name": "Awesome w domu",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "group.awesome_people",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 130,
        "y": 1320,
        "wires": [
            [
                "39e3ef2b.e4088"
            ],
            []
        ]
    },
    {
        "id": "13bab6fc.b61ec9",
        "type": "api-current-state",
        "z": "e47906ea.f77ce8",
        "name": "Awesome w domu?",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "outputs": 2,
        "halt_if": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "group.awesome_people",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 190,
        "y": 1420,
        "wires": [
            [
                "459eb74.78ff548"
            ],
            []
        ]
    },
    {
        "id": "88bec8c1.140fb8",
        "type": "api-call-service",
        "z": "e47906ea.f77ce8",
        "name": "Zimno zamknij okno w sypialni!",
        "server": "b3e9b226.7fd0c",
        "version": 1,
        "debugenabled": false,
        "service_domain": "tts",
        "service": "google_translate_say",
        "entityId": "media_player.office",
        "data": "{\"message\":\"Zimno zamknij okno w sypialni!\",\"language\":\"pl\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "mustacheAltTags": false,
        "x": 790,
        "y": 1620,
        "wires": [
            []
        ]
    }
]

Podsumowanie

Chyba w końcu muszę zamontować czujniki otwarcia na pozostałych oknach, bo obecnie nałożyłem je tylko na te które rzeczywiście używam a reszta czujników sobie leży w półce ;)

 


Photo by Anna Dudkova on Unsplash


Chcesz wiedzieć więcej? Dołącz do naszej grupy na FB - będzie nam też miło jak polubisz nasz Fanpage!