Skip to content

Commit

Permalink
docs(cookbook): Add starting a flow after HA restart example
Browse files Browse the repository at this point in the history
  • Loading branch information
zachowj committed Nov 25, 2020
1 parent d94a840 commit b82affd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vuepress/config.js
Expand Up @@ -40,6 +40,7 @@ module.exports = {
'expiration-date-monitor',
'using-date-and-time-entities-to-trigger-flows',
'check-if-an-entity-was-turned-on-in-the-last-24-hours',
'starting-flow-after-home-assistant-restart',
],
},
],
Expand Down
1 change: 1 addition & 0 deletions docs/cookbook/README.md
Expand Up @@ -13,6 +13,7 @@ further educate yourself in the world of Home Automation with Node-RED.
- [Expiration Date Monitor](./expiration-date-monitor.md)
- [Using date and time entities to trigger flows](./using-date-and-time-entities-to-trigger-flows.md)
- [Check if an entity was a certain state in the last 24 hours](./check-if-an-entity-was-turned-on-in-the-last-24-hours.md)
- [Starting flow after Home Assistant reestart](./starting-flow-after-home-assistant-restart.md)

All JSON exports are also available under the examples tab in the Node-RED
import menu.
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions docs/cookbook/starting-flow-after-home-assistant-restart.md
@@ -0,0 +1,29 @@
# Starting a flow after a Home Assistant restart

Use a Home Assistant automation to set an input boolean to `on` then from Node-RED check if that input boolean is `on` after a successful connection or at any time it changes to `on`.

## Create an input boolean using the Helpers menu (Configuration -> Helpers)

![screenshot](./images/starting-flow-after-home-assistant-restart_02.png)

## Create the Home Assistant automation

```yaml
alias: Home Assistant Restart
description: ""
trigger:
- platform: homeassistant
event: start
condition: []
action:
- service: input_boolean.turn_on
data: {}
entity_id: input_boolean.home_assistant_restarted
mode: single
```

## Create the Node-RED flow

![screenshot](./images/starting-flow-after-home-assistant-restart_01.png)

<<< @/examples/cookbook/starting-flow-after-home-assistant-restart/example_01.json
@@ -0,0 +1 @@
[{"id":"18e24240.85551e","type":"server-events","z":"91a80f99.6180e","name":"","event_type":"home_assistant_client","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":false,"x":152,"y":3968,"wires":[["45c2480a.030d78"]]},{"id":"45c2480a.030d78","type":"switch","z":"91a80f99.6180e","name":"running?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"running","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":364,"y":3968,"wires":[["aaf97af.8e20e88"]]},{"id":"8632ed30.bd796","type":"api-call-service","z":"91a80f99.6180e","name":"","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.home_assistant_restarted","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":760,"y":3968,"wires":[["9efea94e.8901e8"]]},{"id":"aaf97af.8e20e88","type":"api-current-state","z":"91a80f99.6180e","name":"has restarted?","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.home_assistant_restarted","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":528,"y":3968,"wires":[["8632ed30.bd796"],[]]},{"id":"f6b884f4.54b7b8","type":"server-state-changed","z":"91a80f99.6180e","name":"restarted?","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.home_assistant_restarted","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":540,"y":4016,"wires":[["8632ed30.bd796"],[]]},{"id":"aea736a5.b21058","type":"comment","z":"91a80f99.6180e","name":"Home Assistant Restarted","info":"","x":142,"y":3920,"wires":[]},{"id":"9efea94e.8901e8","type":"link out","z":"91a80f99.6180e","name":"Home Assistant Restarted","links":["8e22de6e.96a9d"],"x":1022,"y":3968,"wires":[],"l":true},{"id":"8e22de6e.96a9d","type":"link in","z":"91a80f99.6180e","name":"Home Assistant Restarted","links":["9efea94e.8901e8"],"x":142,"y":4064,"wires":[["7029511d.e34d7"]],"l":true},{"id":"7029511d.e34d7","type":"debug","z":"91a80f99.6180e","name":"do stuff","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":348,"y":4064,"wires":[]}]

0 comments on commit b82affd

Please sign in to comment.