Node-RED - Relógio Cuco

Fala Moçada!

A quem interessar, abaixo encontra-se o passo a passo para implantar um RELÓGIO CUCO no HA com o Google Home.

Para iniciarmos, disponibilizei os ARQUIVOS no One Drive para download: https://1drv.ms/u/s!AjOmmz9u71z83xgPQH9mY0Sx_gic?e=NzHbYE

image

Baixe esses arquivos e os coloque na pasta: /config/www/sounds

Com isso feito, vamos para o NODE-RED…

Nesse fluxo, não coloquei as seguintes horas (23:00, 00:00 até 07:00) justamente para evitar que o CUCO toque nos horários em que estivermos dormindo. Se quiserem adicionar as outras horas é só seguir a mesma ideia.

Basicamente as AÇÕES começam com um TIMESTAMP (Inject) baseando-se na hora.

Em seguida coloquei um node CALL SERVICE que dei o nome de CUTUCO para “acordar” o Google Home antes de tocar de fato o som do CUCO relativo a hora em questão. No campo Entity Id você deve indicar o SEU Google Home.

E por fim, devemos fazer ele tocar o AUDIO referente a HORA em questão. Aqui novamente você vai ter que colocar o nome do SEU Google Home no campo Entity Id:

O conteúdo do campo MESSAGE será assim para quando a HORA for 12:00 (e/ou MEIA NOITE). Veja que você terá que indicar a URL do seu HA para que seja possível encontrar o ARQUIVO de SOM:

Segue o código para importação direta (via Clipboard) do Fluxo no NODE-RED:

[{"id":"f293abc0.37b338","type":"tab","label":"CUCO","disabled":false,"info":""},{"id":"dc347421.4b4ec8","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-12.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":40,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"75eac225.36fc0c","type":"inject","z":"f293abc0.37b338","name":"12:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 12 * * *","once":false,"onceDelay":0.1,"x":110,"y":40,"wires":[[]]},{"id":"670ef59e.391fdc","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-01.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":80,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"795470d7.e7479","type":"inject","z":"f293abc0.37b338","name":"13:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 13 * * *","once":false,"onceDelay":0.1,"x":110,"y":80,"wires":[["7c346915.2215c8"]]},{"id":"a21e8378.e5f38","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-02.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":120,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"3ba1c1c2.9b1dfe","type":"inject","z":"f293abc0.37b338","name":"14:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 14 * * *","once":false,"onceDelay":0.1,"x":110,"y":120,"wires":[["fc3b3d61.3abe5"]]},{"id":"c6d0babf.1898e8","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-03.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":160,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"f0ef041b.4b14c8","type":"inject","z":"f293abc0.37b338","name":"15:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 15 * * *","once":false,"onceDelay":0.1,"x":110,"y":160,"wires":[["3f58797f.6f81e6"]]},{"id":"e83291bc.3235e","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-04.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":200,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"6da042eb.8e15ec","type":"inject","z":"f293abc0.37b338","name":"16:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 16 * * *","once":false,"onceDelay":0.1,"x":110,"y":200,"wires":[["40689306.d704ac"]]},{"id":"60fad7cb.6f91b8","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-05.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":240,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"bb57316c.5feec","type":"inject","z":"f293abc0.37b338","name":"17:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 17 * * *","once":false,"onceDelay":0.1,"x":110,"y":240,"wires":[["643ce036.b42ea"]]},{"id":"e2dfde73.01ca7","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-06.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":280,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"e0337773.9735a8","type":"inject","z":"f293abc0.37b338","name":"18:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 18 * * *","once":false,"onceDelay":0.1,"x":110,"y":280,"wires":[["70373ea9.56881"]]},{"id":"75e9b4ee.944f8c","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-07.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":320,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"dda54c91.21e6a","type":"inject","z":"f293abc0.37b338","name":"19:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 19 * * *","once":false,"onceDelay":0.1,"x":110,"y":320,"wires":[["6ca3b8f1.e43528"]]},{"id":"1c24754.1c1428b","type":"inject","z":"f293abc0.37b338","name":"08:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 08 * * *","once":false,"onceDelay":0.1,"x":110,"y":360,"wires":[["66628ef6.85ab6"]]},{"id":"35f5bfd3.efbe8","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-08.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":380,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"db3e01de.38889","type":"inject","z":"f293abc0.37b338","name":"20:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 20 * * *","once":false,"onceDelay":0.1,"x":110,"y":400,"wires":[["66628ef6.85ab6"]]},{"id":"2a5ee789.fffeb8","type":"inject","z":"f293abc0.37b338","name":"09:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 09 * * *","once":false,"onceDelay":0.1,"x":110,"y":440,"wires":[["a9479747.6400d8"]]},{"id":"8ce074fb.74f3a8","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-09.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":460,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"40ae89cc.dfe4f8","type":"inject","z":"f293abc0.37b338","name":"21:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 21 * * *","once":false,"onceDelay":0.1,"x":110,"y":480,"wires":[["a9479747.6400d8"]]},{"id":"321a69fd.77cb86","type":"inject","z":"f293abc0.37b338","name":"10:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 10 * * *","once":false,"onceDelay":0.1,"x":110,"y":520,"wires":[["9c75eca7.04af6"]]},{"id":"d7af700.8ee439","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-10.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":540,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"bf6fef00.5f6f7","type":"inject","z":"f293abc0.37b338","name":"22:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 22 * * *","once":false,"onceDelay":0.1,"x":110,"y":560,"wires":[["9c75eca7.04af6"]]},{"id":"64af8bae.10e754","type":"inject","z":"f293abc0.37b338","name":"11:00","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"00 11 * * *","once":false,"onceDelay":0.1,"x":110,"y":600,"wires":[["eba0bdbd.3a19"]]},{"id":"2069c9f8.331776","type":"api-call-service","z":"f293abc0.37b338","name":"","server":"ef4eb39d.410e6","version":1,"service_domain":"media_player","service":"play_media","entityId":"media_player.casa_4","data":"{\"media_content_id\":\"https://SeuHomeAssistant.duckdns.org:8123/local/sounds/cuckoo-clock-11.wav\",\"media_content_type\":\"audio/wav\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":600,"wires":[[]],"icon":"node-red-contrib-cast/home.png"},{"id":"30940ef6.f26b12","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":1,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":40,"wires":[["dc347421.4b4ec8"]],"icon":"node-red-contrib-cast/home.png"},{"id":"7c346915.2215c8","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":80,"wires":[["670ef59e.391fdc"]],"icon":"node-red-contrib-cast/home.png"},{"id":"fc3b3d61.3abe5","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":120,"wires":[["a21e8378.e5f38"]],"icon":"node-red-contrib-cast/home.png"},{"id":"3f58797f.6f81e6","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":160,"wires":[["c6d0babf.1898e8"]],"icon":"node-red-contrib-cast/home.png"},{"id":"40689306.d704ac","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":200,"wires":[["e83291bc.3235e"]],"icon":"node-red-contrib-cast/home.png"},{"id":"643ce036.b42ea","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":240,"wires":[["60fad7cb.6f91b8"]],"icon":"node-red-contrib-cast/home.png"},{"id":"70373ea9.56881","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":1,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":280,"wires":[["e2dfde73.01ca7"]],"icon":"node-red-contrib-cast/home.png"},{"id":"6ca3b8f1.e43528","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":320,"wires":[["75e9b4ee.944f8c"]],"icon":"node-red-contrib-cast/home.png"},{"id":"66628ef6.85ab6","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":380,"wires":[["35f5bfd3.efbe8"]],"icon":"node-red-contrib-cast/home.png"},{"id":"a9479747.6400d8","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":460,"wires":[["8ce074fb.74f3a8"]],"icon":"node-red-contrib-cast/home.png"},{"id":"9c75eca7.04af6","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":540,"wires":[["d7af700.8ee439"]],"icon":"node-red-contrib-cast/home.png"},{"id":"eba0bdbd.3a19","type":"api-call-service","z":"f293abc0.37b338","name":"CUTUCO","server":"ef4eb39d.410e6","version":"1","service_domain":"tts","service":"google_translate_say","entityId":"media_player.casa_4","data":"{\"message\":\" \"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":600,"wires":[["2069c9f8.331776"]],"icon":"node-red-contrib-cast/home.png"},{"id":"ef4eb39d.410e6","type":"server","z":"","name":"Home Assistant"}]

:hatched_chick: CUCO!!

Forte Abraço,
José Henrique.

1 Curtida

Que idéia legal!!!

Vou aplicar no meu =) :clap::clap:

1 Curtida

É possível, ao invés de eu direcionar pra um arquivo de áudio, digitar um texto e o google home lê-lo? Por exemplo, caso alguém esqueça um portão aberto, o google home fala “o portão social está aberto”

Olá, @ctm514!

É possível, sim. No message (que na imagem está vazio) é onde você escreve a mensagem que quer que o GH diga.

Abraço,
José Henrique.