Procesy z życia wzięte - Status poranny

Hej
ponizej jak ja mam
Jak wydarzenie w kalandarzu jest np za 3 dni to nie bedzie gadac w ogole
Tylko jeżeli jest dziś lub jutro
@luki25 I jeszcze mam inaczej śmieci zrobione, z tego względu że u mnie czasem wywożą sortowane bez zmieszanych, najpierw sprawdza czy jakiekolwiek śmieci są jezeli tak jest wiadomość ze wywiozą smieci i ładnie mówi jakie

[{"id":"b6733b7c.8faa28","type":"tab","label":"test","disabled":false,"info":""},{"id":"8f8a91a6.19975","type":"api-current-state","z":"b6733b7c.8faa28","name":"Aktualna pogoda","server":"","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.openweathermap_condition","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1090,"y":250,"wires":[["27cea6e6.bf98ba"]]},{"id":"b6418621.73a748","type":"api-current-state","z":"b6733b7c.8faa28","name":"Aktualna temperatura","server":"","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.czujnik_temperatury_podworko_temperature","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":689,"y":250,"wires":[["33c3354a.50266a"]]},{"id":"21430c31.eecbe4","type":"function","z":"b6733b7c.8faa28","name":"Aktualna pogoda","func":"msg.aktualna_pogoda = msg.payload\nmsg.wiadomosc = msg.wiadomosc+\n    \", Pogoda na ten moment to \"+msg.aktualna_pogoda+\". \";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1479,"y":250,"wires":[["5c13f6d4.cdcd68"]]},{"id":"33c3354a.50266a","type":"function","z":"b6733b7c.8faa28","name":"Temperatura","func":"msg.temperatura = Math.round(msg.payload);\nmsg.wiadomosc = msg.wiadomosc+\n    \"Temperatura na dworzu wynosi \"+msg.temperatura+\" stopni. \";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":879,"y":250,"wires":[["8f8a91a6.19975"]]},{"id":"5c4282f.826c07c","type":"api-current-state","z":"b6733b7c.8faa28","name":"Najbliższe zadanie poranne","server":"","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"calendar.btylingo_gmail_com","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1180,"y":370,"wires":[["ce0bf0b8.e4826"]]},{"id":"5c13f6d4.cdcd68","type":"api-current-state","z":"b6733b7c.8faa28","name":"Przewidywana pogoda","server":"","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.openweathermap_forecast_condition","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":520,"y":310,"wires":[["82490c47.2fb52"]]},{"id":"a9af25e1.480098","type":"switch","z":"b6733b7c.8faa28","name":"Przewidywana pogoda","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"aktualna_pogoda","vt":"msg"},{"t":"eq","v":"aktualna_pogoda","vt":"msg"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":310,"wires":[["fc921a12.60d588"],["5c4282f.826c07c"]]},{"id":"fc921a12.60d588","type":"function","z":"b6733b7c.8faa28","name":"Zmiana","func":"msg.przewidywana_pogoda = msg.payload\nmsg.wiadomosc = msg.wiadomosc+\n    \"W najbliższych godzinach pogoda ulegnie zmianie na \"+msg.przewidywana_pogoda+\". \";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1080,"y":310,"wires":[["5c4282f.826c07c"]]},{"id":"27cea6e6.bf98ba","type":"change","z":"b6733b7c.8faa28","name":"Tłumacz","rules":[{"t":"change","p":"payload","pt":"msg","from":"sunny","fromt":"str","to":"słonecznie","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"partlycloudy","fromt":"str","to":"częściowe zachmurzenie","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"cloudy","fromt":"str","to":"pochmurno","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"rainy","fromt":"str","to":"deszczowo","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"fog","fromt":"str","to":"mgła","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"snowy","fromt":"str","to":"opady śniegu","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"-rainy","fromt":"str","to":" z deszczem","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":250,"wires":[["21430c31.eecbe4"]]},{"id":"2b1dd1e1.56e38e","type":"function","z":"b6733b7c.8faa28","name":"Aktualna data","func":"const teraz = new Date();\nconst dni_tygodnia = [\"niedziela\", \"poniedziałek\", \"wtorek\", \"środa\", \"czwartek\", \"piątek\", \"sobota\"];\n\nconst miesiace = [\"stycznia\",\"lutego\",\"marca\",\"kwietnia\",\"maja\",\"czerwca\",\"lipca\",\n                  \"sierpnia\",\"września\",\"października\",\"listopada\",\"grudnia\"];\n                  \nconst godziny = [\"północ\", \"pierwsza\",\"druga\",\"trzecia\", \"czwarta\",\"piąta\", \n                 \"szósta\", \"sidma\", \"ósma\", \"dziewiąta\", \"dziesiąta\", \"jedenasta\", \n                 \"dwunasta\", \"trzynasta\", \"czternasta\",\"piętnasta\", \"szesnasta\", \n                 \"siedemnasta\", \"osiemstansta\", \"dziewiętnasta\", \"dwudziesta\", \n                 \"dwudziestapierwsza\", \"dwudziestadruga\", \"dwudziestatrzecia\"];\n                 \nconst dzien_slow = [\"zerowy\",\"pierwszy\", \"drugi\",\"trzeci\", \"czwarty\", \"piąty\", \"szósty\", \n                    \"siódmy\", \"ósmy\", \"dziewiąty\", \"dziesiąty\", \"jedynasty\", \n                    \"dwunasty\", \"trzynasty\", \"czternasty\", \"piętnasty\", \"szesnasty\", \n                    \"siedemnasty\", \"osiemnasty\", \"dziewiętnasty\", \"dwudziesty\", \n                    \"dwudziestypierwszy\", \"dwudziestydrugi\", \"dwudziestytrzeci\", \n                    \"dwudziestyczwarty\", \"dwudzistypiąty\", \"dwudziestyszósty\", \n                    \"dwudziestysiódmy\", \"dwudziestyósmy\", \"dwudziestydziewiąty\", \n                    \"trzydziesty\", \"trzydziestypierwszy\"];\n\nmsg.akt_godzina = `${ godziny[teraz.getHours()] }`;\nmsg.minuty = teraz.getMinutes();\n\nmsg.dzien_tygodnia = `${ dni_tygodnia[teraz.getDay()] }`;\nmsg.dzien_miesiaca =  `${ dzien_slow[teraz.getDate()] }`;\nmsg.miesiac = `${ miesiace[teraz.getMonth()] }`\n\nmsg.wiadomosc =\"Witaj. Jest godzina \"+msg.akt_godzina+\" \"+msg.minuty+ \". Dzisiaj jest \"+msg.dzien_tygodnia+\". \"+msg.dzien_miesiaca+\" \"+msg.miesiac+\" . \" ;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":250,"wires":[["b6418621.73a748"]]},{"id":"82490c47.2fb52","type":"change","z":"b6733b7c.8faa28","name":"Tłumacz","rules":[{"t":"change","p":"payload","pt":"msg","from":"sunny","fromt":"str","to":"słonecznie","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"partlycloudy","fromt":"str","to":"częściowe zachmurzenie","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"cloudy","fromt":"str","to":"pochmurno","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"rainy","fromt":"str","to":"deszczowo","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"fog","fromt":"str","to":"mgła","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"snowy","fromt":"str","to":"opady śniegu","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"-rainy","fromt":"str","to":" z deszczem","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":310,"wires":[["a9af25e1.480098"]]},{"id":"6453215b.c4f98","type":"api-current-state","z":"b6733b7c.8faa28","name":"zmieszane","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.odpady_zmieszane","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1060,"y":450,"wires":[["8ab1521c.ff761"],["35a8ca18.bb0aa6"]]},{"id":"8ab1521c.ff761","type":"function","z":"b6733b7c.8faa28","name":"odpadów zmieszanych","func":"msg.wiadomosc = msg.wiadomosc+\n    \"odpadów zmieszanych\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1260,"y":450,"wires":[["35a8ca18.bb0aa6"]]},{"id":"b4e1deb4.52d36","type":"function","z":"b6733b7c.8faa28","name":"Śmieci dziś","func":"msg.wiadomosc = msg.wiadomosc+\n    \" Przypominam, dziś jest wywóz śmieci\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":880,"y":450,"wires":[["6453215b.c4f98"]]},{"id":"35a8ca18.bb0aa6","type":"api-current-state","z":"b6733b7c.8faa28","name":"Plastik","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.plastik","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1080,"y":500,"wires":[["eec8ccdf.1468d"],["6e34236b.3a5c2c"]]},{"id":"eec8ccdf.1468d","type":"function","z":"b6733b7c.8faa28","name":"plasiku","func":"msg.wiadomosc = msg.wiadomosc+\n    \", plastików\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1220,"y":500,"wires":[["6e34236b.3a5c2c"]]},{"id":"6e34236b.3a5c2c","type":"api-current-state","z":"b6733b7c.8faa28","name":"papier","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.papier","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1080,"y":540,"wires":[["2e32cf5e.6e8e4"],["3f77288.df85fd8"]]},{"id":"2e32cf5e.6e8e4","type":"function","z":"b6733b7c.8faa28","name":"papieru","func":"msg.wiadomosc = msg.wiadomosc+\n    \", papieru\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1220,"y":540,"wires":[["3f77288.df85fd8"]]},{"id":"3f77288.df85fd8","type":"api-current-state","z":"b6733b7c.8faa28","name":"Szkło","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.szklo","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1080,"y":580,"wires":[["8987d548.fb7508"],["7ed7ade9.cfc6c4"]]},{"id":"8987d548.fb7508","type":"function","z":"b6733b7c.8faa28","name":"szkła","func":"msg.wiadomosc = msg.wiadomosc+\n    \", szkła\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1210,"y":580,"wires":[["7ed7ade9.cfc6c4"]]},{"id":"7ed7ade9.cfc6c4","type":"api-current-state","z":"b6733b7c.8faa28","name":"Popiół","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.popiol","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1080,"y":620,"wires":[["cb4ec278.72341"],["ebf9b8bc.d521e8"]]},{"id":"cb4ec278.72341","type":"function","z":"b6733b7c.8faa28","name":"popiołu","func":"msg.wiadomosc = msg.wiadomosc+\n    \", popiołu\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1220,"y":620,"wires":[["ebf9b8bc.d521e8"]]},{"id":"ebf9b8bc.d521e8","type":"function","z":"b6733b7c.8faa28","name":"KOMUNIKAT","func":"msg.komunikat =\n{\n    \"data\":\n    {\n        \"message\": msg.wiadomosc,\n    }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":860,"y":700,"wires":[["11887863.6c9d08"]]},{"id":"11887863.6c9d08","type":"debug","z":"b6733b7c.8faa28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":700,"wires":[]},{"id":"4734d57b.439c5c","type":"api-current-state","z":"b6733b7c.8faa28","name":"zmieszane","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.odpady_zmieszane","state_type":"str","state_location":"zmieszane1","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":580,"y":450,"wires":[["b4e1deb4.52d36"],["a0047343.b2fa7"]]},{"id":"ea547379.e795e","type":"api-current-state","z":"b6733b7c.8faa28","name":"papier","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.papier","state_type":"str","state_location":"papier1","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":560,"y":530,"wires":[["b4e1deb4.52d36"],["33fb813e.02e7de"]]},{"id":"33fb813e.02e7de","type":"api-current-state","z":"b6733b7c.8faa28","name":"Szkło","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.szklo","state_type":"str","state_location":"szklo1","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":560,"y":570,"wires":[["b4e1deb4.52d36"],["32568dd8.bfd002"]]},{"id":"32568dd8.bfd002","type":"api-current-state","z":"b6733b7c.8faa28","name":"Popiół","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.popiol","state_type":"str","state_location":"popiol1","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":560,"y":610,"wires":[["b4e1deb4.52d36"],["ebf9b8bc.d521e8"]]},{"id":"a0047343.b2fa7","type":"api-current-state","z":"b6733b7c.8faa28","name":"Śmieci textylia","server":"","version":1,"outputs":2,"halt_if":"0","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.plastik","state_type":"str","state_location":"plastik2","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":490,"wires":[["b4e1deb4.52d36"],["ea547379.e795e"]]},{"id":"ce0bf0b8.e4826","type":"function","z":"b6733b7c.8faa28","name":"Najbliższe zadanie poranne","func":"const date = new Date(msg.data.attributes.start_time);\n\nconsole.log(date.getDate());\nconsole.log(date.getMonth());\nconsole.log(date.getFullYear());\n\nconst isToday = (date) => {\n    const today = new Date();\n    return date.getDate() === today.getDate() &&\n        date.getMonth() === today.getMonth() &&\n        date.getFullYear() === today.getFullYear();\n}\n\nconst isTomorrow = (date) => {\n\tconst tomorrow = new Date(Date.now() + 86400000); // ms in one day\n  console.log(`Tomorrow: ${tomorrow}`);\n  return date.getDate() === tomorrow.getDate() &&\n    date.getMonth() === tomorrow.getMonth() &&\n    date.getFullYear() === tomorrow.getFullYear();\n}\n\nif (isToday(date)) {\n  msg.wiadomosc = msg.wiadomosc+\n    \" Pamiętaj, że dzisiaj w kalendarzu jest \"+msg.data.attributes.message+\".\";\n} else if (isTomorrow(date)) {\n\tmsg.wiadomosc = msg.wiadomosc+\n    \" Dzisiaj kalendarz jest pusty. Najbliższe to \"+msg.data.attributes.message+\". Jednak to dopiero jutro.\";\n} else {\n\tmsg.wiadomosc = msg.wiadomosc;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1450,"y":370,"wires":[["4734d57b.439c5c"]]},{"id":"7ffa7d8e.ea1724","type":"inject","z":"b6733b7c.8faa28","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":310,"y":250,"wires":[["2b1dd1e1.56e38e"]]}]
1 polubienie