Advertisement
diyfuturism

Node-Red Alarm clock with Snooze

Dec 16th, 2018
5,798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 18.14 KB | None | 0 0
  1. [{"id":"4e372028.b4791","type":"comment","z":"50822ac6.45f6e4","name":"TRIGGER ALARM CLOCK","info":"","x":170,"y":60,"wires":[]},{"id":"73ca6a3d.3cf8a4","type":"join","z":"50822ac6.45f6e4","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":870,"y":80,"wires":[["9462cd.30c15d3"]]},{"id":"9462cd.30c15d3","type":"function","z":"50822ac6.45f6e4","name":"Compare Times","func":"newmsg = {};\nif (msg.payload[0] == msg.payload[1]) {\n    newmsg.payload = \"True\";\n} else {\n    newmsg.payload = \"False\";\n}\n\nreturn newmsg;","outputs":1,"noerr":0,"x":880,"y":140,"wires":[["d904ad6c.e2029"]]},{"id":"d904ad6c.e2029","type":"switch","z":"50822ac6.45f6e4","name":"Is it Time?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":890,"y":200,"wires":[["b1dc52e6.c21ce"]]},{"id":"fafca638.544048","type":"api-current-state","z":"50822ac6.45f6e4","name":"Alarm Clock ON?","server":"6a99bb32.7b2f04","halt_if":"off","override_topic":false,"override_payload":false,"override_data":false,"entity_id":"input_boolean.house_option_alarmclock","x":330,"y":120,"wires":[["fac779fe.d8a4d8","4071e699.ff3108"]]},{"id":"fac779fe.d8a4d8","type":"api-current-state","z":"50822ac6.45f6e4","name":"Get Alarm Time","server":"6a99bb32.7b2f04","halt_if":"","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"input_datetime.alarm_time","x":620,"y":200,"wires":[["340a1e69.297a02"]]},{"id":"4071e699.ff3108","type":"moment","z":"50822ac6.45f6e4","name":"Current Time","topic":"","input":"payload","inputType":"msg","inTz":"America/Los_Angeles","adjAmount":"0","adjType":"minutes","adjDir":"subtract","format":"H:mm","locale":"C","output":"payload","outputType":"msg","outTz":"America/Los_Angeles","x":630,"y":80,"wires":[["73ca6a3d.3cf8a4"]]},{"id":"1791d486.5d335b","type":"inject","z":"50822ac6.45f6e4","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":120,"wires":[["fafca638.544048"]]},{"id":"340a1e69.297a02","type":"moment","z":"50822ac6.45f6e4","name":"Alarm - 10min","topic":"","input":"payload","inputType":"msg","inTz":"America/Los_Angeles","adjAmount":"10","adjType":"minutes","adjDir":"subtract","format":"H:mm","locale":"C","output":"payload","outputType":"msg","outTz":"America/Los_Angeles","x":620,"y":140,"wires":[["73ca6a3d.3cf8a4"]]},{"id":"b1dc52e6.c21ce","type":"api-call-service","z":"50822ac6.45f6e4","name":"House State - Waking Up","server":"6a99bb32.7b2f04","service_domain":"variable","service":"set_variable","data":"{\"variable\":\"house_state\",\"value\":\"Waking Up\"}","mergecontext":"","x":1170,"y":140,"wires":[[]]},{"id":"d26f0bd9.11ac78","type":"comment","z":"50822ac6.45f6e4","name":"START ALARM CLOCK SEQUENCE","info":"","x":210,"y":300,"wires":[]},{"id":"8d7dafcd.b542e","type":"comment","z":"50822ac6.45f6e4","name":"Make Coffee","info":"","x":550,"y":480,"wires":[]},{"id":"e2193462.cd6618","type":"comment","z":"50822ac6.45f6e4","name":"Set Initial Flow Variables","info":"","x":590,"y":360,"wires":[]},{"id":"7fecfc93.b50954","type":"api-current-state","z":"50822ac6.45f6e4","name":"Radio?","server":"6a99bb32.7b2f04","halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"input_boolean.house_alarmclock_radio","state_type":"str","x":540,"y":620,"wires":[["4f5927db.4f6f08"]]},{"id":"262165d6.25b30a","type":"comment","z":"50822ac6.45f6e4","name":"LOOP LOGIC ","info":"","x":130,"y":780,"wires":[]},{"id":"deb9f2e2.32eef","type":"comment","z":"50822ac6.45f6e4","name":"Snooze Button Actions","info":"","x":860,"y":1200,"wires":[]},{"id":"d956cbf1.1945d8","type":"comment","z":"50822ac6.45f6e4","name":"Finish Alarm Sequence","info":"","x":1580,"y":960,"wires":[]},{"id":"26086923.380b06","type":"comment","z":"50822ac6.45f6e4","name":"Snooze Timer","info":"","x":550,"y":1280,"wires":[]},{"id":"f08c6f0d.6d80a","type":"change","z":"50822ac6.45f6e4","name":"Stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"snooze","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":940,"wires":[["d10b2b40.718e08","2159c5f2.55519a"]]},{"id":"3d075eea.ebf6b2","type":"server-state-changed","z":"50822ac6.45f6e4","name":"Snooze On","server":"6a99bb32.7b2f04","entityidfilter":"input_boolean.house_alarmclock_snooze","entityidfiltertype":"substring","outputinitially":false,"haltifstate":"off","x":340,"y":1240,"wires":[["f08c6f0d.6d80a","94a76075.3f98f","2c19a40e.98c15c"]]},{"id":"d10b2b40.718e08","type":"traffic","z":"50822ac6.45f6e4","name":"Brighten the Lights","property_allow":"payload","filter_allow":"start","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"snooze","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":false,"differ":false,"x":710,"y":880,"wires":[["67780497.7f3c4c"]]},{"id":"1bf4eca4.1c7a93","type":"link in","z":"50822ac6.45f6e4","name":"","links":["7ab54afd.e9dca4"],"x":675,"y":940,"wires":[["f08c6f0d.6d80a"]]},{"id":"94a76075.3f98f","type":"function","z":"50822ac6.45f6e4","name":"Reset to Brightness / Volume","func":"flow.set(\"brightness\", 30);\nflow.set(\"volume\",0.3);\nnewmsg = {\"payload\":\"true\"}\nreturn newmsg;","outputs":1,"noerr":0,"x":880,"y":1240,"wires":[["689a0948.31c8b8","14e985b2.52798a","7cc8399.ae9c0c8"]]},{"id":"2c19a40e.98c15c","type":"delay","z":"50822ac6.45f6e4","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":540,"y":1320,"wires":[["b501f39d.600e3"]]},{"id":"d0cdc13f.e93d1","type":"inject","z":"50822ac6.45f6e4","name":"Brightness ---->","topic":"","payload":"brightness","payloadType":"flow","repeat":"6","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":880,"wires":[["d10b2b40.718e08"]]},{"id":"67780497.7f3c4c","type":"function","z":"50822ac6.45f6e4","name":"Set Brightness","func":"newmsg = {}\nvar brightness = flow.get(\"brightness\");\n\nnewmsg.payload = { data: { \"brightness_pct\":brightness} }\n\nreturn newmsg;","outputs":1,"noerr":0,"x":920,"y":880,"wires":[["c76d36be.ce4738","21cabab2.450156"]]},{"id":"2a00765b.555a1a","type":"change","z":"50822ac6.45f6e4","name":"Start","rules":[{"t":"set","p":"payload","pt":"msg","to":"start","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":820,"wires":[["d10b2b40.718e08","2159c5f2.55519a"]]},{"id":"689a0948.31c8b8","type":"api-call-service","z":"50822ac6.45f6e4","name":"Turn Off Entry Light","server":"6a99bb32.7b2f04","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.entry\"}","render_data":false,"mergecontext":"","x":1170,"y":1180,"wires":[[]]},{"id":"14e985b2.52798a","type":"api-call-service","z":"50822ac6.45f6e4","name":"Turn Off Bedroom Light","server":"6a99bb32.7b2f04","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.bedroom\"}","render_data":false,"mergecontext":"","x":1190,"y":1240,"wires":[[]]},{"id":"b501f39d.600e3","type":"api-call-service","z":"50822ac6.45f6e4","name":"Snooze Off (Restart Loop)","server":"6a99bb32.7b2f04","service_domain":"homeassistant","service":"turn_off","data":"{\"entity_id\":\"input_boolean.house_alarmclock_snooze\"}","render_data":false,"mergecontext":"","x":870,"y":1320,"wires":[["366e956a.9957fa"]]},{"id":"c76d36be.ce4738","type":"api-call-service","z":"50822ac6.45f6e4","name":"Turn On Entry Light","server":"6a99bb32.7b2f04","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.entry\",\"rgb_color\":[255,255,255]}","render_data":false,"mergecontext":"","x":1170,"y":840,"wires":[["ac3b2d7a.d717"]]},{"id":"21cabab2.450156","type":"api-call-service","z":"50822ac6.45f6e4","name":"Turn On Bedroom Light","server":"6a99bb32.7b2f04","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.bedroom\",\"rgb_color\":[255,255,255]}","render_data":false,"mergecontext":"","x":1190,"y":920,"wires":[[]]},{"id":"94e22da.1027ad","type":"switch","z":"50822ac6.45f6e4","name":"Is it Time?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Waking Up","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":500,"wires":[["2a00765b.555a1a","8ccd1d8f.c0edf","a8750407.ebb1a8","7fecfc93.b50954"]]},{"id":"357de059.75d57","type":"server-state-changed","z":"50822ac6.45f6e4","name":"Snooze Off","server":"6a99bb32.7b2f04","entityidfilter":"input_boolean.house_alarmclock_snooze","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","x":340,"y":820,"wires":[["2a00765b.555a1a"]]},{"id":"ac3b2d7a.d717","type":"function","z":"50822ac6.45f6e4","name":"Increment Brightness","func":"var brightness = flow.get('brightness')||0;\n\nif (brightness < 100) {\n    brightness = brightness + 1;\n    flow.set(\"brightness\", brightness);\n    \n    newmsg = {\"payload\":\"looping\"}\n    return newmsg;\n}\nelse {\n    newmsg = {\"payload\":\"done\"};\n    return newmsg;\n}","outputs":1,"noerr":0,"x":1440,"y":840,"wires":[["f8a224e3.36da38"]]},{"id":"92731a6b.994ce8","type":"server-state-changed","z":"50822ac6.45f6e4","name":"Wake Up House","server":"6a99bb32.7b2f04","entityidfilter":"variable.house_state","entityidfiltertype":"substring","outputinitially":false,"haltifstate":"","x":140,"y":360,"wires":[["94e22da.1027ad"]]},{"id":"8ccd1d8f.c0edf","type":"api-current-state","z":"50822ac6.45f6e4","name":"Coffee?","server":"6a99bb32.7b2f04","halt_if":"","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"sensor.coffeemaker","x":540,"y":520,"wires":[["592c8979.104358"]]},{"id":"a8750407.ebb1a8","type":"function","z":"50822ac6.45f6e4","name":"Initialize Brightness / Volume to 0","func":"flow.set(\"brightness\", 1);\nflow.set(\"volume\", 0.0);\n\nnewmsg = {\"payload\":\"true\"}\nreturn newmsg;","outputs":1,"noerr":0,"x":620,"y":400,"wires":[[]]},{"id":"f8a224e3.36da38","type":"switch","z":"50822ac6.45f6e4","name":"Is Loop Done?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"done","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1560,"y":900,"wires":[["7ab54afd.e9dca4"]]},{"id":"592c8979.104358","type":"switch","z":"50822ac6.45f6e4","name":"Ready","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Ready","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":520,"wires":[["5aadddad.cbf4a4"]]},{"id":"7c64e529.5da1cc","type":"inject","z":"50822ac6.45f6e4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":870,"y":400,"wires":[["a8750407.ebb1a8"]]},{"id":"7ab54afd.e9dca4","type":"link out","z":"50822ac6.45f6e4","name":"FINISH ALARM SEQUENCE!","links":["1bf4eca4.1c7a93","45deb28f.3cb32c"],"x":1455,"y":960,"wires":[]},{"id":"5aadddad.cbf4a4","type":"delay","z":"50822ac6.45f6e4","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":820,"y":520,"wires":[["78ef44b6.b5e70c"]]},{"id":"78ef44b6.b5e70c","type":"api-call-service","z":"50822ac6.45f6e4","name":"Make Coffee","server":"6a99bb32.7b2f04","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.coffeemaker\"}","mergecontext":"","x":990,"y":520,"wires":[[]]},{"id":"429aadb.c9f6154","type":"comment","z":"50822ac6.45f6e4","name":"LIGHTING","info":"","x":920,"y":840,"wires":[]},{"id":"2159c5f2.55519a","type":"traffic","z":"50822ac6.45f6e4","name":"Turn Up Volume","property_allow":"payload","filter_allow":"start","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"snooze","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":false,"differ":false,"x":700,"y":1020,"wires":[["657333f1.7909fc"]]},{"id":"fad957dd.6dd4a8","type":"inject","z":"50822ac6.45f6e4","name":"Volume ---->","topic":"","payload":"volume","payloadType":"flow","repeat":"30","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":1020,"wires":[["43ea908e.3c395"]]},{"id":"657333f1.7909fc","type":"function","z":"50822ac6.45f6e4","name":"Set Volume","func":"newmsg = {};\nvar volume = flow.get(\"volume\");\n\nnewmsg.payload = { data: { \"volume_level\":volume} }\n\nreturn newmsg;","outputs":1,"noerr":0,"x":910,"y":1020,"wires":[["9af407f9.c86bf8"]]},{"id":"9af407f9.c86bf8","type":"api-call-service","z":"50822ac6.45f6e4","name":"Kitchen Alexa","server":"6a99bb32.7b2f04","service_domain":"media_player","service":"volume_set","data":"{\"entity_id\":\"media_player.kitchen\"}","render_data":false,"mergecontext":"","x":1160,"y":1020,"wires":[["80a72f1d.6b7e2"]]},{"id":"80a72f1d.6b7e2","type":"function","z":"50822ac6.45f6e4","name":"Increment Volume","func":"var volume = flow.get('volume')||0.0;\n\nif (volume < 0.75) {\n    volume = volume + 0.05;\n    flow.set(\"volume\", volume);\n    \n    newmsg = {\"payload\":\"looping\"}\n    return newmsg;\n}\nelse {\n    newmsg = {\"payload\":\"done\"};\n    return newmsg;\n}","outputs":1,"noerr":0,"x":1430,"y":1020,"wires":[[]]},{"id":"8731eb87.10b2b8","type":"comment","z":"50822ac6.45f6e4","name":"SNOOZE!","info":"","x":120,"y":1100,"wires":[]},{"id":"4dafac18.270c34","type":"comment","z":"50822ac6.45f6e4","name":"VOLUME","info":"","x":920,"y":960,"wires":[]},{"id":"9cde2a65.b70278","type":"comment","z":"50822ac6.45f6e4","name":"Turn on Radio","info":"","x":550,"y":580,"wires":[]},{"id":"43ea908e.3c395","type":"api-current-state","z":"50822ac6.45f6e4","name":"Radio?","server":"6a99bb32.7b2f04","halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"input_boolean.house_alarmclock_radio","state_type":"str","x":520,"y":1020,"wires":[["2159c5f2.55519a"]]},{"id":"4f5927db.4f6f08","type":"api-call-service","z":"50822ac6.45f6e4","name":"Volume","server":"6a99bb32.7b2f04","service_domain":"media_player","service":"volume_set","data":"{\"entity_id\":\"media_player.kitchen\",\"volume_level\":0}","render_data":false,"mergecontext":"","x":700,"y":620,"wires":[["ab5dfbde.ed7e48"]]},{"id":"ec5ccdb0.7df88","type":"api-call-service","z":"50822ac6.45f6e4","name":"Play NPR","server":"6a99bb32.7b2f04","service_domain":"media_player","service":"play_media","data":"{\"entity_id\":\"media_player.kitchen\",\"media_content_id\":\"K Q E D\",\"media_content_type\":\"TUNEIN\"}","render_data":false,"mergecontext":"","x":1000,"y":620,"wires":[["cfc6a2a9.7cac8"]]},{"id":"ab5dfbde.ed7e48","type":"change","z":"50822ac6.45f6e4","name":"Delete","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":620,"wires":[["ec5ccdb0.7df88"]]},{"id":"7cc8399.ae9c0c8","type":"api-call-service","z":"50822ac6.45f6e4","name":"Pause Radio","server":"6a99bb32.7b2f04","service_domain":"media_player","service":"media_pause","data":"{\"entity_id\":\"media_player.kitchen\"}","render_data":false,"mergecontext":"","x":1150,"y":1300,"wires":[["e2d7f0f1.8ce89"]]},{"id":"366e956a.9957fa","type":"change","z":"50822ac6.45f6e4","name":"Delete","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":1380,"wires":[["84babc62.ad05d"]]},{"id":"84babc62.ad05d","type":"api-call-service","z":"50822ac6.45f6e4","name":"Play","server":"6a99bb32.7b2f04","service_domain":"media_player","service":"media_play","data":"{\"entity_id\":\"media_player.kitchen\"}","render_data":false,"mergecontext":"","x":1130,"y":1380,"wires":[[]]},{"id":"e2d7f0f1.8ce89","type":"change","z":"50822ac6.45f6e4","name":"Delete","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":1300,"wires":[["f1d88296.5e1ba"]]},{"id":"f1d88296.5e1ba","type":"api-call-service","z":"50822ac6.45f6e4","name":"Volume","server":"6a99bb32.7b2f04","service_domain":"media_player","service":"volume_set","data":"{\"entity_id\":\"media_player.kitchen\",\"volume_level\":0.3}","render_data":false,"mergecontext":"","x":1460,"y":1300,"wires":[[]]},{"id":"aa63a8fc.5dab58","type":"mqtt in","z":"50822ac6.45f6e4","name":"Bedroom Button","topic":"zigbee2mqtt/bedroom_button","qos":"2","broker":"fcd2ccdf.1df12","x":560,"y":1460,"wires":[["91c5aee9.01081"]]},{"id":"91c5aee9.01081","type":"api-current-state","z":"50822ac6.45f6e4","name":"Waking Up?","server":"6a99bb32.7b2f04","halt_if":"Waking Up","halt_if_type":"str","halt_if_compare":"is_not","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"variable.house_state","state_type":"str","x":770,"y":1460,"wires":[["e0806e1e.e5e97"]]},{"id":"e0806e1e.e5e97","type":"api-call-service","z":"50822ac6.45f6e4","name":"Snooze On","server":"6a99bb32.7b2f04","service_domain":"homeassistant","service":"turn_on","data":"{\"entity_id\":\"input_boolean.house_alarmclock_snooze\"}","render_data":false,"mergecontext":"","x":950,"y":1460,"wires":[[]]},{"id":"e7355a75.1a9328","type":"comment","z":"50822ac6.45f6e4","name":"Snooze Button","info":"","x":560,"y":1420,"wires":[]},{"id":"cfc6a2a9.7cac8","type":"change","z":"50822ac6.45f6e4","name":"Delete","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":620,"wires":[["c5bcb252.89ad9"]]},{"id":"c5bcb252.89ad9","type":"api-call-service","z":"50822ac6.45f6e4","name":"Volume","server":"6a99bb32.7b2f04","service_domain":"media_player","service":"volume_set","data":"{\"entity_id\":\"media_player.kitchen\",\"volume_level\":0}","render_data":false,"mergecontext":"","x":1260,"y":620,"wires":[[]]},{"id":"6a99bb32.7b2f04","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true},{"id":"fcd2ccdf.1df12","type":"mqtt-broker","z":"","name":"MQTT","broker":"192.168.0.9","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement