Pessoal, meu objetivo é automatizar um ventilador de teto (não smart) que tem apenas 1 botão (on/off), a partir da temperatura do ambiente entre um determinado período do dia.
Venho trocando minhas automações nativas do HA adaptando ao Node-red e assim será.
O fluxo que atualmente já tenho é este mas como é apenas 1 botão (on/off) no controle a automatização sempre liga mas também desliga:
(Explicando):
No melhor dos mundos deveria funcionar da seguinte maneira:
Entre 11:00 e 04:00 é verificado a temperatura do ambiente. E uma condicional com 3 saídas é criada (switch):
Caso 1 = Se a temperatura é > 29 uma função com Broadlink aciona o ventilador (para ligar);
Caso 3 = Se a temperatura é < 29 uma função com Broadlink desligará o ventilador
Problema (mecânico):
1 - O ventilador de teto é de tipo “dummy”, ou seja, o liga/desliga é acinado por apenas 1 botão, que é enviado por IR para ligar e desligar. Então o Broadlink só reconhece 1 código para as duas ações;
Problema (no meu fluxo do Node-red)
2 - A cada hora é feita a checagem por temperatura e, se a temperatura continua sendo > 29, o Broadlink envia o comando, com isso o ventilador desliga.
Objetivo:
1 - A cada checagem por temperatura, se a temperatura for => 29 não desligar;
2 - Se a temperatura for <29C desligar o ventilador.
[{"id":"a7beae16a2cf71ba","type":"template","z":"a6321e24fe878b7f","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.data}}","output":"str","x":1320,"y":240,"wires":[[]]},{"id":"70f1c3961295f9f1","type":"RM","z":"a6321e24fe878b7f","name":"Broadlink Sala","device":"ffe5cd1d42c3079a","action":"_msg_","remote":"","button":"","fix":1,"RFSweep":"false","x":1160,"y":240,"wires":[["a7beae16a2cf71ba"]]},{"id":"930e1934eb96e6c4","type":"function","z":"a6321e24fe878b7f","name":"function: Ventilador","func":"//Insert learned data object here\nvar data = [38,0,104,0,0,1,38,148,18,19,18,19,19,55,18,19,19,19,18,19,18,19,18,19,18,56,18,56,18,19,18,56,18,56,19,55,19,55,18,56,18,56,19,19,17,20,18,56,18,19,17,20,17,20,18,19,17,20,17,57,18,56,19,18,19,55,18,56,19,55,19,56,18,0,5,35,0,1,40,75,18,0,12,96,0,1,39,75,18,0,12,96,0,1,40,74,19,0,12,96,0,1,38,75,19,0,13,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];\n// or Base64 encoded format from other source\n//var data = \"JgBMAnM3ECkQKRANEAwRDQ8pEAwQDRApDyoQDQ8pEA0QDRAoECkQDRAoEigQDBEMECkRDBAMECkQDRAMEA0QDRAMEA0QDRANDw4PDQ8NEA0PDRANEA0RDA8NEAwRDBAMESgQDRAMEA0QDRAMESgQKRANEAwRDBApDyoQDBApEA4PDBILEQwQDRAoESgRDBApECkQDBANECkQDBANECgRDBANECkQDBEoEQwQKQ8NEA0QKQ8qEAwQDRAMEA0QDQ8NEA0QDBEMEAwRDQ8ODwwRDBAMEA0QDRAMEA0QDBANEQwQDRAMEA4PDRANEAwQDBANEA0QDBEMEAwQDRAMEA4PDBEMEA0PDRANEAwRDQ4OEAwRDBEMEAwQDRANECgQKRApECkQDBEMEAACMnc4ECgQKRANEQwQDQ8pEQwQDQ8qECgQDRApEA0QDBEoECkQDBEoECkQDRAMECkQDRAMECkQDRANEAwQDRANDw0QDQ8NEQwQDBEMEA0PDRENDw0QDBANDw0QDRANECgRDBAMEA0QDRAMECkRKBANEAwRDBApECkQDBEoEQwQDRAMEA0QDBApECkQDRApECgQDRANECgRDBANECgRDBANECgRDBApEAwQKRANEAwRKBApEQwQDBEMEA0QDBEMEA0QDQ8NDw0RDBAMEQwQDRAMEA0QDBEMEA0QDBANEAwQDRANEAwQDRANEAwQDRAMEA0QDRAMEA0QDBANEA0RCxILEQwQDBEMEA0QDBEMEA0QDQ8NEQwQDBANECkPKhApECkQDBANEAANBQAAAAAAAAAAAAAAAA==\"\n\nmsg.payload={\n //\"mac\":\"MAC address of your broadlink rm\", // Optional if configured in the RM node\n //\"host\":\"IP address of your broadlink rm\", // Optional if configured in the RM node\n \"action\":\"send\",\n \"data\":data,\n \"repeat\":0\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":950,"y":240,"wires":[["70f1c3961295f9f1"]]},{"id":"0efbd21f791182c0","type":"comment","z":"a6321e24fe878b7f","name":"Ventilador da sala liga após passar de 29C","info":"","x":200,"y":80,"wires":[]},{"id":"9c61d478159557ae","type":"api-current-state","z":"a6321e24fe878b7f","name":"Obter temperatura","server":"b771286b.8c8f28","version":3,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.a440002283_temperature","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"str"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":150,"y":240,"wires":[["4133150cec3f483f"]]},{"id":"b9a90b047427f9a6","type":"telegrambot-notify","z":"a6321e24fe878b7f","name":"","bot":"f783de8c8a9692c3","chatId":"1535233309","message":"Ligando ventilador da sala","parseMode":"","x":940,"y":300,"wires":[]},{"id":"0a3710ffc7de95f8","type":"inject","z":"a6321e24fe878b7f","name":"11:00 as 00:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"0 11-23 * * *","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":120,"y":140,"wires":[["9c61d478159557ae"]]},{"id":"a5f42a62c914b866","type":"inject","z":"a6321e24fe878b7f","name":"01:00 as 04:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"0 1-3 * * *","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":340,"y":140,"wires":[["9c61d478159557ae"]]},{"id":"b45537af24ae4cd1","type":"telegrambot-notify","z":"a6321e24fe878b7f","name":"","bot":"f783de8c8a9692c3","chatId":"1535233309","message":"Desligando ventilador da sala","parseMode":"","x":940,"y":360,"wires":[]},{"id":"9aa2a17918d32018","type":"switch","z":"a6321e24fe878b7f","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"29","vt":"str"},{"t":"lt","v":"29","vt":"str"},{"t":"gt","v":"29","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":690,"y":240,"wires":[["08deda5487678f26"],["930e1934eb96e6c4","b9a90b047427f9a6","08deda5487678f26"],["930e1934eb96e6c4","b45537af24ae4cd1","08deda5487678f26"]]},{"id":"4133150cec3f483f","type":"api-current-state","z":"a6321e24fe878b7f","name":"","server":"b771286b.8c8f28","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.a440002283_temperature","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":420,"y":300,"wires":[["9aa2a17918d32018"]]},{"id":"08deda5487678f26","type":"debug","z":"a6321e24fe878b7f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1140,"y":100,"wires":[]},{"id":"ffe5cd1d42c3079a","type":"rmdevice","folder":"","mac":"A043B0147BED","host":"192.168.0.105","devType":"5f36"},{"id":"b771286b.8c8f28","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30"},{"id":"f783de8c8a9692c3","type":"telegrambot-config","botname":"Neuber_bot","usernames":"","chatIds":"","pollInterval":"300"}]
Alguém pode me ajudar?