CORREIOS - Sistema de rastreio no Home Assistant + adicionar, excluir e notificações telegram (nodered+card homeassistant)

Boa!

Para apagar vc precisa do token, fez isso? Ele precisa remover do HA o sensor então é necessário.

nao sei exatamente oque aconteceu, mais deu certo, estava pensando em adicionar via telegram, mais e meio complexo, como o exemplo desse tutorail → Rastrear objetos Correios - #42 por Rafael123, antes estava usando ele, so deu problena pk aqui nao esta lendo o arquivo

Você diz adicionar um rastreio pelo telegram?

#######################################################################

** ATUALIZAÇÃO**

  • Após a última versão do HA e Nodered foram alteradas algumas coisas e os sensores não estavam sendo adicionados em arquivo ou excluídos. Arrumei isso, qualquer outro bug me reportem.

#######################################################################

AÇÕES NECESSÁRIAS

  • Importar novo código abaixo:
[{"id":"d813744a14e47c58","type":"subflow","name":"Deletar sensor","info":"","category":"","in":[{"x":200,"y":180,"wires":[{"id":"ae10af25d3d15ad8"}]}],"out":[{"x":800,"y":180,"wires":[{"id":"65b45ea853786f14","port":0}]},{"x":800,"y":120,"wires":[{"id":"5f3f6de174795b6b","port":0}]}],"env":[{"name":"entity_id","type":"str","value":"null"}],"meta":{},"color":"#DDAA99"},{"id":"cf360f03230d69d3","type":"function","z":"d813744a14e47c58","name":"caminho","func":"msg.entity_id = env.get('entity_id')\nvar minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.filename = \"/homeassistant/.dados/sensores/\"+msg.entity_id\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":200,"wires":[["65b45ea853786f14"]]},{"id":"ae10af25d3d15ad8","type":"switch","z":"d813744a14e47c58","name":"entity_id= null != null","property":"entity_id","propertyType":"env","rules":[{"t":"neq","v":"null","vt":"str"},{"t":"eq","v":"null","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":340,"y":180,"wires":[["816daab8ca46d270","228fdb66c65e57ad"],["cf360f03230d69d3","228fdb66c65e57ad"]]},{"id":"65b45ea853786f14","type":"fs-ops-delete","z":"d813744a14e47c58","name":"Deletar dados","path":"","pathType":"str","filename":"filename","filenameType":"msg","x":680,"y":180,"wires":[[]]},{"id":"816daab8ca46d270","type":"function","z":"d813744a14e47c58","name":"caminho","func":"var minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.filename = \"/homeassistant/.dados/sensores/\" + msg.entity_id\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":160,"wires":[["65b45ea853786f14"]]},{"id":"228fdb66c65e57ad","type":"function","z":"d813744a14e47c58","name":"Filtro","func":"msg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    \"Authorization\": \"Bearer \" + global.get(\"token\"),\n}\n\nmsg.url = 'http://' + global.get(\"ip\") + '/api/states/' + msg.entity_id\n\n\nreturn msg\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":120,"wires":[["5f3f6de174795b6b"]]},{"id":"5f3f6de174795b6b","type":"http request","z":"d813744a14e47c58","name":"Deleta sensor","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":660,"y":120,"wires":[[]]},{"id":"5082e6363013a9b9","type":"subflow","name":"Salvar lista","info":"","category":"","in":[{"x":260,"y":80,"wires":[{"id":"7a20bf6c15af3428"}]}],"out":[{"x":800,"y":80,"wires":[{"id":"2670d819f772ac37","port":0}]}],"env":[{"name":"No nó call-service em Output properties, colocar msg.entity_id e selecionar send data","type":"str","value":"","ui":{"type":"none"}}],"meta":{},"color":"#DDAA99"},{"id":"2670d819f772ac37","type":"file","z":"5082e6363013a9b9","name":"salvar lista","filename":"filename","filenameType":"msg","appendNewline":true,"createDir":true,"overwriteFile":"true","encoding":"none","x":690,"y":80,"wires":[[]]},{"id":"7a20bf6c15af3428","type":"function","z":"5082e6363013a9b9","name":"caminho","func":"msg.filename = \"/homeassistant/.dados/input_select/\" + msg.entity_id\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":80,"wires":[["e447d88e8f1ace5b"]]},{"id":"e447d88e8f1ace5b","type":"change","z":"5082e6363013a9b9","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":80,"wires":[["2670d819f772ac37"]]},{"id":"359c8b708d6774da","type":"subflow","name":"Criar sensor","category":"","in":[{"x":60,"y":140,"wires":[{"id":"498ed4c0923e3280"}]}],"out":[{"x":1060,"y":140,"wires":[{"id":"e009fa126ba7773f","port":0}]}],"env":[{"name":"entity_id","type":"str","value":"sensor.","ui":{"label":{"en-US":"entity_id"}}},{"name":"Deixar null para utilizar variaveis externas, msg.entity_id, msg.state, msg.attributes","type":"str","value":"","ui":{"type":"none"}},{"name":"state","type":"str","value":"null","ui":{"label":{"en-US":"state"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","cred"]}}},{"name":"attributes","type":"json","value":"{\"friendly_name\":\"nome_teste\",\"state_class\":\"measurement\",\"device_class\":\"temperature\",\"unit_of_measurement\":\"°C\",\"icon\":\"mdi:information\"}","ui":{"label":{"en-US":"attributes"}}}],"meta":{},"color":"#DDAA99"},{"id":"423c1f073312c853","type":"function","z":"359c8b708d6774da","name":"Criar sensor ","func":"function removerAcentosECedilhas(texto) {\n    var mapaAcentosHex = {\n        a: /[\\xE0-\\xE6]/g,\n        e: /[\\xE8-\\xEB]/g,\n        i: /[\\xEC-\\xEF]/g,\n        o: /[\\xF2-\\xF6]/g,\n        u: /[\\xF9-\\xFC]/g,\n        c: /\\xE7/g,\n        n: /\\xF1/g,\n    };\n\n    for (var letra in mapaAcentosHex) {\n        var expressaoRegular = mapaAcentosHex[letra];\n        texto = texto.replace(expressaoRegular, letra);\n    }\n\n    // Remover \"-\" e substituir por \"_\"\n    texto = texto.replace(/-/g, 'e');\n\n    texto = texto.replace(/\\|/g, 'e');\n\n    return texto;\n}\n\nvar textoComAcentosECedilhas = msg.entity_id;\nvar textoSemAcentosECedilhas = removerAcentosECedilhas(textoComAcentosECedilhas.toLowerCase());\n\nmsg.entity_id = textoSemAcentosECedilhas;\nmsg.payload = {\n    data: {\n        state: msg.state,\n        attributes: msg.attributes\n    }\n};\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":120,"wires":[["44084de7e58a9f18"]]},{"id":"498ed4c0923e3280","type":"switch","z":"359c8b708d6774da","name":"state = null != null","property":"state","propertyType":"env","rules":[{"t":"eq","v":"null","vt":"str"},{"t":"neq","v":"null","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":140,"wires":[["423c1f073312c853"],["431104959050d8bc"]]},{"id":"431104959050d8bc","type":"function","z":"359c8b708d6774da","name":"Criar sensor ","func":"msg.entity_id = env.get('entity_id')\nvar minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.payload = {\n    data: {\n        state: env.get(\"state\"),\n        attributes: env.get('attributes')\n    }\n };\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":160,"wires":[["44084de7e58a9f18"]]},{"id":"c8a7d575f65ec599","type":"function","z":"359c8b708d6774da","name":"adicionar arquivo na pasta","func":"msg.filename = \"/homeassistant/.dados/sensores/\"+msg.entity_id\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":140,"wires":[["e009fa126ba7773f"]],"info":"``msg.entity_id = 'sensor.game_' + msg.game;``\r\n``msg.state = msg.game,``\r\n    ``msg.attributes = {``\r\n        ``\"friendly_name\": msg.game,``\r\n        \"preco_justo\": msg.preco_justo,\r\n        \"platform\": msg.platform,\r\n        \"data\": [\r\n            {\r\n                \"title_default\": \"$title\",\r\n                \"line1_default\": \"$rating\",\r\n                \"line2_default\": msg.release[1],\r\n                \"line3_default\": \"$release\",\r\n                \"line4_default\": \"$studio\",\r\n            },\r\n            {\r\n                \"title\": msg.title,\r\n                \"poster\": msg.image[\"data-src\"],\r\n                \"rating\": \"Atual: \" + msg.price[0],\r\n                \"runtime\": msg.release[1],\r\n                \"studio\": \"MPH: \" + msg.lowest_price[2],\r\n                \"release\": msg.promo,\r\n                \"airdate\": msg.data_atual,\r\n            }\r\n        ]\r\n    }\r\nreturn msg;\r\n"},{"id":"e009fa126ba7773f","type":"file","z":"359c8b708d6774da","name":"save file","filename":"filename","filenameType":"msg","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":960,"y":140,"wires":[[]]},{"id":"b46fb34108187436","type":"function","z":"359c8b708d6774da","name":"Template sensor","func":"msg.entity_id = 'sensor.game_' + msg.game;\nmsg.state = msg.game,\n    msg.attributes = {\n        \"friendly_name\": msg.game,\n        \"preco_justo\": msg.preco_justo,\n        \"platform\": msg.platform,\n        \"data\": [\n            {\n                \"title_default\": \"$title\",\n                \"line1_default\": \"$rating\",\n                \"line2_default\": msg.release[1],\n                \"line3_default\": \"$release\",\n                \"line4_default\": \"$studio\",\n            },\n            {\n                \"title\": msg.title,\n                \"poster\": msg.image[\"data-src\"],\n                \"rating\": \"Atual: \" + msg.price[0],\n                \"runtime\": msg.release[1],\n                \"studio\": \"MPH: \" + msg.lowest_price[2],\n                \"release\": msg.promo,\n                \"airdate\": msg.data_atual,\n            }\n        ]\n    }\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":40,"wires":[[]]},{"id":"44084de7e58a9f18","type":"ha-api","z":"359c8b708d6774da","name":"","server":"db1ab0af.caa65","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"/api/states/{{entity_id}}","data":"","dataType":"json","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":570,"y":140,"wires":[["c8a7d575f65ec599"]]},{"id":"db1ab0af.caa65","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"e3f8c2a2b98f267c","type":"tab","label":"-Correios","disabled":false,"info":"","env":[]},{"id":"02a0e821c7fb8050","type":"group","z":"e3f8c2a2b98f267c","name":"Criando sensor de contagem ","style":{"label":true},"nodes":["7516e46afa6375aa","52354fa2985d27ca","b3260b98a51ef85c","743507b184757c78"],"x":44,"y":79,"w":402,"h":82},{"id":"140eafa3088f68d7","type":"group","z":"e3f8c2a2b98f267c","name":"Incluir rastreio","style":{"label":true},"nodes":["496e80d3a579c86c","91aa642df462cdd9","344d75c36480f997","147f521d4c2f2712","2940126187bdc08f","aedf37f5fd936478","e8975cf4aa13c03b","8460376b8e7f5cde","c16c3ca6a62b96c8","75eefdbd4360e282","0b35ee3ad31047d7","2f97b9e8ec585e30","78e6c92c05e41e57","79265861f92ee670","7c402b1f495e2279","19066586202c87a5","752aebd455055b85","f79d31758add7cb1","3701484f9d1d237a","478ee071fe1278d2","c6ea2b012fb6eb5b"],"x":34,"y":199,"w":1682,"h":202},{"id":"1b821dabf9f69c7b","type":"group","z":"e3f8c2a2b98f267c","name":"Excluir rastreio","style":{"label":true},"nodes":["dd266606d76b496b","ad9136ec07c3b51e","a068014999a36ca3","706d96a2c023e955","b0bc1c419cd3065c","27d3e1404b17643e","f7255c2a5d4c8321","9e65487e0358dccc","fd6bad1366aef9c6","a46c80027e65e950","308577f1195c5ba7","248c23d92eed4667","e047356332816ef9","e2227d7f54befd7c","e47704876389b2a6","3493a16f4c9284e6","b1f996f490fc5e56","055881704657d380","65b646228d08a8bd","28778b44cf8a912a"],"x":34,"y":419,"w":1452,"h":222},{"id":"7ba03e375f10a57f","type":"group","z":"e3f8c2a2b98f267c","name":"DEV","style":{"label":true},"nodes":["0504b628c1c154c4","f70de4302e9955b2","3c4aff81b6f65806","4ee42357efb0f549","225183653d37f5b1","56e48028d6e5b5ca","5cd4c57688c1798e","c141e82b28724825","58c9f97dfb2fec65","60a19b9ada44795b","8fb4e2cd9882eb58","aadab2cb86f61a98","666e01ffc77e40a4"],"x":34,"y":959,"w":752,"h":262},{"id":"f0887a3414e2a284","type":"group","z":"e3f8c2a2b98f267c","name":"Atualizações dos rastreios ","style":{"label":true},"nodes":["6a0b667b01597535","d6d783fbe58a8e3a","72aae8f2a54e2121","1a91a779d7d97d53","2b1f01ed97bfc0db","218ffb6d09436d5d","c2802caeb39d1ba6","3c9ad822115133ea","d74b570f28a1074b","28d653cbe7ff1433","540f4d06c1743248"],"x":44,"y":859,"w":1502,"h":82},{"id":"31bffe4a6c92a1c9","type":"group","z":"e3f8c2a2b98f267c","name":"Mudança de status","style":{"label":true},"nodes":["6ee5df1fc82a464d","6e6a13212fb24740","dfe312dd97c0a97e","0764074f927b168f","b1a939efdc3e01cd","2f5da89c104b37e7","0627ddfc79e1b798","c87610891f3339d1","68421d4aa0a39092","f999c9b9b7f08136","2dd53bf2796bed92"],"x":34,"y":679,"w":1342,"h":162},{"id":"063b53cb52dae517","type":"group","z":"e3f8c2a2b98f267c","name":"","style":{"label":true},"nodes":["5c6597a57ec39b15","1047d2dda55378c4","08501313fa1793a0"],"x":544,"y":39,"w":342,"h":122},{"id":"7516e46afa6375aa","type":"inject","z":"e3f8c2a2b98f267c","g":"02a0e821c7fb8050","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"15","topic":"","payload":"","payloadType":"date","x":105,"y":120,"wires":[["52354fa2985d27ca"]],"l":false},{"id":"52354fa2985d27ca","type":"function","z":"e3f8c2a2b98f267c","g":"02a0e821c7fb8050","name":"function 32","func":"msg.state = flow.get(\"rastreio\").length\n\nif (msg.state > 0){\n    msg.entity_id = \"sensor.count_correios\"\n    \n    return [msg,null];\n} \nelse {\n    msg.entity_id = \"sensor.count_correios\"\n    msg.state = 0\n\n    return [null,msg]\n}\n\n","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":215,"y":120,"wires":[["743507b184757c78"],["743507b184757c78"]],"l":false},{"id":"b3260b98a51ef85c","type":"link in","z":"e3f8c2a2b98f267c","g":"02a0e821c7fb8050","name":"link in 54","links":["79265861f92ee670","a46c80027e65e950","fd6bad1366aef9c6"],"x":165,"y":120,"wires":[["52354fa2985d27ca"]]},{"id":"496e80d3a579c86c","type":"function","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Headers","func":"msg.url = \"https://www.linkcorreios.com.br/?id=\" + msg.rastreio\nmsg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n}\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":300,"wires":[["91aa642df462cdd9"]]},{"id":"91aa642df462cdd9","type":"http request","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":300,"wires":[["344d75c36480f997"]]},{"id":"344d75c36480f997","type":"html","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Status","property":"payload","outproperty":"status","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(1) > b","ret":"text","as":"single","x":870,"y":300,"wires":[["8460376b8e7f5cde"]]},{"id":"e8975cf4aa13c03b","type":"function","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"dados sensor","func":"let arrayRastreio = flow.get(\"rastreio\") || [];\narrayRastreio.push(msg.rastreio);\nflow.set(\"rastreio\", arrayRastreio);\n\n\nlet arrayObjeto = flow.get(\"nome_objeto\") || [];\narrayObjeto.push(msg.nome_objeto);\nflow.set(\"nome_objeto\", arrayObjeto);\n\nlet arrayNotificacao = flow.get(\"notificacao\") || [];\narrayNotificacao.push(msg.notificacao);\nflow.set(\"notificacao\", arrayNotificacao);\n\nmsg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase()\nmsg.state =  msg.status\nmsg.attributes = {\n    rastreio: msg.rastreio,\n    status: msg.status,\n    notificacao: msg.notificacao,\n    data: msg.data,\n    local: msg.local,\n    destino: msg.destino,\n    friendly_name: msg.nome_objeto.toUpperCase() + ' - ' + msg.rastreio.toUpperCase(),\n}\nreturn msg\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1400,"y":300,"wires":[["478ee071fe1278d2"]]},{"id":"8460376b8e7f5cde","type":"html","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Data","property":"payload","outproperty":"data","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(2)","ret":"text","as":"single","x":990,"y":300,"wires":[["c16c3ca6a62b96c8"]]},{"id":"c16c3ca6a62b96c8","type":"html","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Local","property":"payload","outproperty":"local","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(3)","ret":"text","as":"single","x":1110,"y":300,"wires":[["0b35ee3ad31047d7"]]},{"id":"0b35ee3ad31047d7","type":"html","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Destino","property":"payload","outproperty":"destino","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(4)","ret":"text","as":"single","x":1240,"y":300,"wires":[["e8975cf4aa13c03b"]]},{"id":"79265861f92ee670","type":"link out","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"link out 75","mode":"link","links":["392e29fa7c841991","4889d89cd6c1f2c0","b3260b98a51ef85c"],"x":1675,"y":300,"wires":[]},{"id":"7c402b1f495e2279","type":"delay","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"","pauseType":"delay","timeout":"6","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":235,"y":240,"wires":[["19066586202c87a5"]],"l":false},{"id":"752aebd455055b85","type":"function","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"function","func":"// Inicializar o array de opções\nvar options = [];\n\n// Loop através do array msg.sensores\nfor (var i = 0; i < msg.sensores.length; i++) {\n    // Adicionar o valor atual de msg.sensores[i].entity_id ao array de opções\n    options.push(msg.sensores[i].attributes.friendly_name);\n}\n\n// Definir as opções no objeto msg.payload.data\nmsg.payload = {\n    data: {\n        \"options\": options\n    }\n}\n\n// Enviar a mensagem modificada para o próximo nó\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":240,"wires":[["f79d31758add7cb1"]]},{"id":"3701484f9d1d237a","type":"link in","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"link in 55","links":["a46c80027e65e950","fd6bad1366aef9c6"],"x":325,"y":240,"wires":[["19066586202c87a5"]]},{"id":"dd266606d76b496b","type":"function","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Headers","func":"let partes = msg.rastreio.split('-');\nlet resultado = partes.pop().trim().toUpperCase();\nmsg.rastreio = resultado;\n\n\nvar index = flow.get(\"rastreio\").indexOf(msg.rastreio);\nvar rastreio = flow.get(\"rastreio\");\nvar nome_objeto = flow.get(\"nome_objeto\");\nvar notificacao = flow.get(\"notificacao\")\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\", rastreio)\n    nome_objeto.splice(index, 1);\n    flow.set(\"nome_objeto\",nome_objeto)\n    notificacao.splice(index, 1);\n    flow.set(\"notificacao\", notificacao)\n}\n\nmsg.entity_id = 'sensor.correios_' + msg.rastreio\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":460,"wires":[["b1f996f490fc5e56"]]},{"id":"b0bc1c419cd3065c","type":"switch","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"= Objeto entregue ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto entregue ao destinatário']","vt":"str"},{"t":"eq","v":"['Objeto entregue ao remetente']","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":440,"y":600,"wires":[["f7255c2a5d4c8321"],["f7255c2a5d4c8321"]]},{"id":"27d3e1404b17643e","type":"function","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Headers","func":"var index = flow.get(\"rastreio\").indexOf(msg.data.new_state.attributes.rastreio);\nvar rastreio = flow.get(\"rastreio\");\nvar nome_objeto = flow.get(\"nome_objeto\");\nvar notificacao = flow.get(\"notificacao\");\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\", rastreio)\n    nome_objeto.splice(index, 1);\n    flow.set(\"nome_objeto\", nome_objeto)\n    notificacao.splice(index, 1);\n    flow.set(\"notificacao\", notificacao)\n}\n\nmsg.entity_id = 'sensor.correios_' + msg.data.new_state.attributes.rastreio\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":600,"wires":[["3493a16f4c9284e6"]]},{"id":"f7255c2a5d4c8321","type":"delay","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":625,"y":600,"wires":[["27d3e1404b17643e"]],"l":false},{"id":"fd6bad1366aef9c6","type":"link out","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"link out 74","mode":"link","links":["3701484f9d1d237a","b3260b98a51ef85c"],"x":995,"y":600,"wires":[]},{"id":"a46c80027e65e950","type":"link out","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"link out 73","mode":"link","links":["3701484f9d1d237a","b3260b98a51ef85c"],"x":705,"y":500,"wires":[]},{"id":"248c23d92eed4667","type":"function","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"function","func":"// Inicializar o array de opções\nvar options = [];\n\nif (msg.sensores[0] != ''){\n    // Loop através do array msg.sensores\n    for (var i = 0; i < msg.sensores.length; i++) {\n        // Adicionar o valor atual de msg.sensores[i].entity_id ao array de opções\n        options.push(msg.sensores[i].attributes.friendly_name);\n    }\n}\nelse {\n    options = msg.sensores[0];\n}\n\n// Definir as opções no objeto msg.payload.data\nmsg.payload = {\n    data: {\n        \"options\": options\n    }\n}\n\n// Enviar a mensagem modificada para o próximo nó\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1100,"y":460,"wires":[["28778b44cf8a912a"]]},{"id":"e047356332816ef9","type":"function","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"function 33","func":"if (msg.sensores.length === 0) {\n    msg.sensores[0] = \"\";\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":975,"y":460,"wires":[["248c23d92eed4667"],["248c23d92eed4667"]],"l":false},{"id":"e2227d7f54befd7c","type":"delay","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":705,"y":460,"wires":[["308577f1195c5ba7"]],"l":false},{"id":"0504b628c1c154c4","type":"inject","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Revemor Rastreio","props":[{"p":"rastreio","v":"abre e fecha tuya","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":1000,"wires":[["f70de4302e9955b2"]]},{"id":"f70de4302e9955b2","type":"function","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Remover do array","func":"var index = flow.get(\"rastreio\").indexOf(msg.rastreio);\nvar rastreio = flow.get(\"rastreio\")\n\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\",rastreio)\n}\nreturn msg;\n\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":1000,"wires":[["3c4aff81b6f65806"]]},{"id":"3c4aff81b6f65806","type":"debug","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"remover array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":1000,"wires":[]},{"id":"4ee42357efb0f549","type":"inject","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Listar","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":1060,"wires":[["225183653d37f5b1"]]},{"id":"225183653d37f5b1","type":"template","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Listar array","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{flow.rastreio}}\n{{flow.nome_objeto}}\n{{flow.notificacao}}","output":"str","x":290,"y":1060,"wires":[["56e48028d6e5b5ca"]]},{"id":"56e48028d6e5b5ca","type":"debug","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"listar array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":1060,"wires":[]},{"id":"5cd4c57688c1798e","type":"inject","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Zerar Array","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":1120,"wires":[["c141e82b28724825"]]},{"id":"c141e82b28724825","type":"function","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Limpar  array","func":"var clear_rastreio = flow.get(\"rastreio\");\nclear_rastreio = [] || [];\nflow.set(\"rastreio\", clear_rastreio);\n\nvar clear_nome_objeto = flow.get(\"nome_objeto\");\nclear_nome_objeto = [] || [];\nflow.set(\"nome_objeto\", clear_nome_objeto);\n\nvar clear_notificacao = flow.get(\"notificacao\");\nclear_notificacao = [] || [];\nflow.set(\"notificacao\", clear_notificacao);\n\nreturn msg;\n\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":1120,"wires":[["58c9f97dfb2fec65"]]},{"id":"58c9f97dfb2fec65","type":"debug","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"array limpo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":1120,"wires":[]},{"id":"60a19b9ada44795b","type":"function","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Headers","func":"msg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    \"Authorization\": \"Bearer \"+global.get(\"token\"),\n}\n\nmsg.url = 'http://'+global.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":1180,"wires":[["8fb4e2cd9882eb58"]]},{"id":"8fb4e2cd9882eb58","type":"http request","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":490,"y":1180,"wires":[["aadab2cb86f61a98"]]},{"id":"aadab2cb86f61a98","type":"debug","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"remover sensor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":1180,"wires":[]},{"id":"666e01ffc77e40a4","type":"inject","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Deletar sensor","props":[{"p":"rastreio","v":"NL658154191BR","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":1180,"wires":[["60a19b9ada44795b"]]},{"id":"6a0b667b01597535","type":"function","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Headers","func":"for (var i = 0; i < flow.get(\"rastreio\").length; i++) {\n    msg.url = \"https://www.linkcorreios.com.br/?id=\" + flow.get(\"rastreio\")[i]\n    msg.headers = {\n        \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    }\n\n    msg.rastreio = flow.get(\"rastreio\")[i]\n    msg.nome_objeto = flow.get(\"nome_objeto\")[i]\n    msg.notificacao = flow.get(\"notificacao\")[i]\n\n    flow.get(\"rastreio\")[i] + 1;\n\n    node.send([msg]); \n}\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":900,"wires":[["d6d783fbe58a8e3a"]]},{"id":"d6d783fbe58a8e3a","type":"http request","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":330,"y":900,"wires":[["d74b570f28a1074b"]]},{"id":"72aae8f2a54e2121","type":"html","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Status","property":"payload","outproperty":"status","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(1) > b","ret":"text","as":"single","x":630,"y":900,"wires":[["1a91a779d7d97d53"]]},{"id":"1a91a779d7d97d53","type":"html","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Data","property":"payload","outproperty":"data","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(2)","ret":"text","as":"single","x":750,"y":900,"wires":[["2b1f01ed97bfc0db"]]},{"id":"2b1f01ed97bfc0db","type":"html","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Local","property":"payload","outproperty":"local","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(3)","ret":"text","as":"single","x":870,"y":900,"wires":[["218ffb6d09436d5d"]]},{"id":"218ffb6d09436d5d","type":"html","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Destino","property":"payload","outproperty":"destino","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(4)","ret":"text","as":"single","x":1000,"y":900,"wires":[["28d653cbe7ff1433"]]},{"id":"c2802caeb39d1ba6","type":"inject","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Atualiza de 1 em 1 min ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"120","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":105,"y":900,"wires":[["6a0b667b01597535"]],"l":false},{"id":"3c9ad822115133ea","type":"function","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"dados sensor","func":"msg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase();\nmsg.state = msg.status,\nmsg.attributes = {\n    rastreio: msg.rastreio,\n    status: msg.status,\n    data: msg.data,\n    notificacao: msg.notificacao,\n    local: msg.local,\n    destino: msg.destino,\n    friendly_name: msg.nome_objeto.toUpperCase() + ' - ' + msg.rastreio.toUpperCase(),\n}\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1280,"y":900,"wires":[["540f4d06c1743248"]]},{"id":"d74b570f28a1074b","type":"delay","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"","pauseType":"rate","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"3","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":480,"y":900,"wires":[["72aae8f2a54e2121"]]},{"id":"28d653cbe7ff1433","type":"function","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"!= Null","func":"if (msg.data.length === 0) {\n    msg.data[0] = null;\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1130,"y":900,"wires":[[],["3c9ad822115133ea"]]},{"id":"6e6a13212fb24740","type":"switch","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Notificacao = Sim / Saiu para entrega","property":"data.new_state.attributes.notificacao","propertyType":"msg","rules":[{"t":"eq","v":"Sim","vt":"str"},{"t":"eq","v":"Saiu para entrega","vt":"str"},{"t":"eq","v":"Objeto entregue","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":570,"y":760,"wires":[["0764074f927b168f"],["b1a939efdc3e01cd"],["c87610891f3339d1"]]},{"id":"dfe312dd97c0a97e","type":"link out","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"link out 19","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":975,"y":720,"wires":[]},{"id":"0764074f927b168f","type":"template","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Todas notificações","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":850,"y":720,"wires":[["dfe312dd97c0a97e"]]},{"id":"b1a939efdc3e01cd","type":"switch","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"= Objeto saiu para entrega ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto saiu para entrega ao destinatário']","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":920,"y":760,"wires":[["2f5da89c104b37e7"]]},{"id":"2f5da89c104b37e7","type":"template","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Saiu para entrega","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":1210,"y":760,"wires":[["f999c9b9b7f08136"]]},{"id":"0627ddfc79e1b798","type":"function","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"!= Null","func":"if (msg.data.new_state.attributes.data.length === 0) {\n    msg.data.new_state.attributes.data[0] = null;\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":760,"wires":[[],["6e6a13212fb24740"]]},{"id":"c87610891f3339d1","type":"switch","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"= Objeto entregue ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto entregue ao destinatário']","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":900,"y":800,"wires":[["68421d4aa0a39092"]]},{"id":"68421d4aa0a39092","type":"template","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Objeto entregue","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":1200,"y":800,"wires":[["2dd53bf2796bed92"]]},{"id":"f999c9b9b7f08136","type":"link out","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"link out 76","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":760,"wires":[]},{"id":"2dd53bf2796bed92","type":"link out","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"link out 77","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":800,"wires":[]},{"id":"478ee071fe1278d2","type":"subflow:359c8b708d6774da","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"","env":[{"name":"entity_id","value":"","type":"str"},{"name":"attributes","value":"","type":"str"}],"x":1570,"y":300,"wires":[["79265861f92ee670"]]},{"id":"e47704876389b2a6","type":"subflow:5082e6363013a9b9","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","x":1390,"y":460,"wires":[[]]},{"id":"c6ea2b012fb6eb5b","type":"subflow:5082e6363013a9b9","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"","x":950,"y":240,"wires":[[]]},{"id":"540f4d06c1743248","type":"subflow:359c8b708d6774da","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"","env":[{"name":"entity_id","value":"","type":"str"},{"name":"attributes","value":"","type":"str"}],"x":1450,"y":900,"wires":[[]]},{"id":"3493a16f4c9284e6","type":"subflow:d813744a14e47c58","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":880,"y":600,"wires":[[],["fd6bad1366aef9c6","65b646228d08a8bd"]]},{"id":"b1f996f490fc5e56","type":"subflow:d813744a14e47c58","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":580,"y":460,"wires":[[],["a46c80027e65e950","e2227d7f54befd7c"]]},{"id":"055881704657d380","type":"link in","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"link in 58","links":["65b646228d08a8bd"],"x":755,"y":460,"wires":[["308577f1195c5ba7"]]},{"id":"65b646228d08a8bd","type":"link out","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"link out 84","mode":"link","links":["055881704657d380"],"x":995,"y":560,"wires":[]},{"id":"aedf37f5fd936478","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Limpar texto","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.correios_nome_objeto","input_text.correios_rastreio"],"data":"{\"value\":\"\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":130,"y":360,"wires":[["78e6c92c05e41e57"]]},{"id":"78e6c92c05e41e57","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Limpar select","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":["input_select.correios_notificacao"],"data":"{\"option\":\"Sim\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":370,"y":360,"wires":[[]]},{"id":"f79d31758add7cb1","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Criar lista","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_select","service":"set_options","areaId":[],"deviceId":[],"entityId":["input_select.rastreio"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"data"},{"property":"entity_id","propertyType":"msg","value":"input_select.rastreio","valueType":"str"}],"queue":"none","x":780,"y":240,"wires":[["c6ea2b012fb6eb5b"]]},{"id":"706d96a2c023e955","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Limpar texto","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.correios_nome_objeto","input_text.correios_rastreio"],"data":"{\"value\":\"\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":130,"y":520,"wires":[[]]},{"id":"147f521d4c2f2712","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Rastreio","server":"db1ab0af.caa65","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_text.correios_rastreio","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"rastreio","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":120,"y":300,"wires":[["aedf37f5fd936478","2f97b9e8ec585e30"]]},{"id":"75eefdbd4360e282","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Nome objeto","server":"db1ab0af.caa65","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_text.correios_nome_objeto","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"nome_objeto","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":470,"y":300,"wires":[["496e80d3a579c86c"]]},{"id":"2f97b9e8ec585e30","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Notificação","server":"db1ab0af.caa65","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.correios_notificacao","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"notificacao","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":310,"y":300,"wires":[["75eefdbd4360e282"]]},{"id":"a068014999a36ca3","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Rastreio","server":"db1ab0af.caa65","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.rastreio","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"rastreio","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":280,"y":460,"wires":[["dd266606d76b496b"]]},{"id":"2940126187bdc08f","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"SALVAR","server":"db1ab0af.caa65","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.correios_salvar","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":120,"y":240,"wires":[["147f521d4c2f2712","7c402b1f495e2279"]]},{"id":"ad9136ec07c3b51e","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"EXCLUIR","server":"db1ab0af.caa65","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.correios_excluir","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":460,"wires":[["706d96a2c023e955","a068014999a36ca3"]]},{"id":"9e65487e0358dccc","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Excluir automaticamente","server":"db1ab0af.caa65","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.correios_","entityIdType":"regex","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":600,"wires":[["b0bc1c419cd3065c"]]},{"id":"6ee5df1fc82a464d","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Aviso mudança de status","server":"db1ab0af.caa65","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.correios_","entityIdType":"regex","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":760,"wires":[["0627ddfc79e1b798"]]},{"id":"19066586202c87a5","type":"ha-get-entities","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Pegar sensores","server":"db1ab0af.caa65","version":1,"rules":[{"property":"entity_id","logic":"starts_with","value":"sensor.correios_","valueType":"str"}],"outputType":"array","outputEmptyResults":false,"outputLocationType":"msg","outputLocation":"sensores","outputResultsCount":1,"x":480,"y":240,"wires":[["752aebd455055b85"]]},{"id":"308577f1195c5ba7","type":"ha-get-entities","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Pegar sensores","server":"db1ab0af.caa65","version":1,"rules":[{"property":"entity_id","logic":"starts_with","value":"sensor.correios_","valueType":"str"}],"outputType":"array","outputEmptyResults":true,"outputLocationType":"msg","outputLocation":"sensores","outputResultsCount":1,"x":860,"y":460,"wires":[["e047356332816ef9"]]},{"id":"743507b184757c78","type":"subflow:359c8b708d6774da","z":"e3f8c2a2b98f267c","g":"02a0e821c7fb8050","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":350,"y":120,"wires":[[]]},{"id":"28778b44cf8a912a","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Criar lista","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_select","service":"set_options","areaId":[],"deviceId":[],"entityId":["input_select.rastreio"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"data"},{"property":"entity_id","propertyType":"msg","value":"input_select.rastreio","valueType":"str"}],"queue":"none","x":1240,"y":460,"wires":[["e47704876389b2a6"]]},{"id":"5c6597a57ec39b15","type":"inject","z":"e3f8c2a2b98f267c","g":"063b53cb52dae517","name":"Digitar Chave token e IP","props":[{"p":"payload"}],"repeat":"1800","crontab":"","once":false,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":615,"y":120,"wires":[["1047d2dda55378c4"]],"l":false},{"id":"1047d2dda55378c4","type":"change","z":"e3f8c2a2b98f267c","g":"063b53cb52dae517","name":"Digitar Chave token e IP","rules":[{"t":"set","p":"token","pt":"global","to":"","tot":"str"},{"t":"set","p":"ip","pt":"global","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":120,"wires":[[]]},{"id":"08501313fa1793a0","type":"comment","z":"e3f8c2a2b98f267c","g":"063b53cb52dae517","name":"IP + Token","info":"","x":630,"y":80,"wires":[]}]

@kelvinrafaeli

pode explicar quais sensores vai aqui
Capture

eu mudei o nome do meus sensores para a inicial rastreamento_* os demais está ok, mais me surgiu essa duvida, pq aqui ainda da a mensagem de nestes nó na saide != Null

TypeError: Cannot read properties of undefined (reading ‘length’)

estou fazendo algo errado e não vejo onde.

Esses sensores são criados automaticamente pelo resto do flow, se vc mudar o nome vai ter que abrir todos os nós que contenham o nome antigo e alterar também.

1 Like

@kelvinrafaeli tudo bem?
Estou testando aqui e consigo adicionar os rastreios sem problema, mas não consigo apagar.
Alguma sugestão?

Criei os helpers abaixo (alguns devem ser das versões antigas)

Coloquei o token no NR, mas os rastreios não aparecem na lista para serem apagados:

Alguma sugestão?

Boa tarde, blz?

Chegou a instalar a versão atualizada? Mandei 3 conversas pra cima ali…

Se não aparece, acredito que não esta salvando os dados no arquivo, isso estava acontecendo antes de eu mandar essa atualização.

Usei esse código.

Vou dar uma olhada.

Quando vc cria os select é obrigado a adicionar uma opção, tirando o de notificação eu criei com um espaço apenas.
Como vc criou?

Isso mesmo. Como ele não deixar ficar zerado, eu criei o meu somente com um espaço. Ai após isso o proprio fluxo gerencia dai.

Você está com qual versão do HA, pois nessas últimas foi alterado a pasta local de config para homeassitant, e nesse código atualizado já esta para as últimas versões do HA

Estou na última versão de Janeiro

Alterei alguns nos para salvar em outra pasta. Os arquivos estão sendo criados.
Mas não achei nenhum no que faz a leitura do arquivo.
Aí quando reinicia perde os rastreios cadastrados.
Não está faltando nenhum sub flow?

Deveria ser importado os subflows também. Tenta esse, é versão que estou utilizando, o token estou pegando por get.global e não mais por get.flow

[{"id":"d813744a14e47c58","type":"subflow","name":"Deletar sensor","info":"","category":"","in":[{"x":200,"y":180,"wires":[{"id":"ae10af25d3d15ad8"}]}],"out":[{"x":800,"y":180,"wires":[{"id":"65b45ea853786f14","port":0}]},{"x":800,"y":120,"wires":[{"id":"5f3f6de174795b6b","port":0}]}],"env":[{"name":"entity_id","type":"str","value":"null"}],"meta":{},"color":"#DDAA99"},{"id":"cf360f03230d69d3","type":"function","z":"d813744a14e47c58","name":"caminho","func":"msg.entity_id = env.get('entity_id')\nvar minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.filename = \"/homeassistant/.dados/sensores/\"+msg.entity_id\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":200,"wires":[["65b45ea853786f14"]]},{"id":"ae10af25d3d15ad8","type":"switch","z":"d813744a14e47c58","name":"entity_id= null != null","property":"entity_id","propertyType":"env","rules":[{"t":"neq","v":"null","vt":"str"},{"t":"eq","v":"null","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":340,"y":180,"wires":[["816daab8ca46d270","228fdb66c65e57ad"],["cf360f03230d69d3","228fdb66c65e57ad"]]},{"id":"65b45ea853786f14","type":"fs-ops-delete","z":"d813744a14e47c58","name":"Deletar dados","path":"","pathType":"str","filename":"filename","filenameType":"msg","x":680,"y":180,"wires":[[]]},{"id":"816daab8ca46d270","type":"function","z":"d813744a14e47c58","name":"caminho","func":"var minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.filename = \"/homeassistant/.dados/sensores/\" + msg.entity_id\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":160,"wires":[["65b45ea853786f14"]]},{"id":"228fdb66c65e57ad","type":"function","z":"d813744a14e47c58","name":"Filtro","func":"msg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    \"Authorization\": \"Bearer \" + global.get(\"token\"),\n}\n\nmsg.url = 'http://' + global.get(\"ip\") + '/api/states/' + msg.entity_id\n\n\nreturn msg\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":120,"wires":[["5f3f6de174795b6b"]]},{"id":"5f3f6de174795b6b","type":"http request","z":"d813744a14e47c58","name":"Deleta sensor","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":660,"y":120,"wires":[[]]},{"id":"5082e6363013a9b9","type":"subflow","name":"Salvar lista","info":"","category":"","in":[{"x":260,"y":80,"wires":[{"id":"7a20bf6c15af3428"}]}],"out":[{"x":800,"y":80,"wires":[{"id":"2670d819f772ac37","port":0}]}],"env":[{"name":"No nó call-service em Output properties, colocar msg.entity_id e selecionar send data","type":"str","value":"","ui":{"type":"none"}}],"meta":{},"color":"#DDAA99"},{"id":"2670d819f772ac37","type":"file","z":"5082e6363013a9b9","name":"salvar lista","filename":"filename","filenameType":"msg","appendNewline":true,"createDir":true,"overwriteFile":"true","encoding":"none","x":690,"y":80,"wires":[[]]},{"id":"7a20bf6c15af3428","type":"function","z":"5082e6363013a9b9","name":"caminho","func":"msg.filename = \"/homeassistant/.dados/input_select/\" + msg.entity_id\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":80,"wires":[["e447d88e8f1ace5b"]]},{"id":"e447d88e8f1ace5b","type":"change","z":"5082e6363013a9b9","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":80,"wires":[["2670d819f772ac37"]]},{"id":"359c8b708d6774da","type":"subflow","name":"Criar sensor","category":"","in":[{"x":60,"y":140,"wires":[{"id":"498ed4c0923e3280"}]}],"out":[{"x":1060,"y":140,"wires":[{"id":"e009fa126ba7773f","port":0}]}],"env":[{"name":"entity_id","type":"str","value":"sensor.","ui":{"label":{"en-US":"entity_id"}}},{"name":"Deixar null para utilizar variaveis externas, msg.entity_id, msg.state, msg.attributes","type":"str","value":"","ui":{"type":"none"}},{"name":"state","type":"str","value":"null","ui":{"label":{"en-US":"state"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","cred"]}}},{"name":"attributes","type":"json","value":"{\"friendly_name\":\"nome_teste\",\"state_class\":\"measurement\",\"device_class\":\"temperature\",\"unit_of_measurement\":\"°C\",\"icon\":\"mdi:information\"}","ui":{"label":{"en-US":"attributes"}}}],"meta":{},"color":"#DDAA99"},{"id":"423c1f073312c853","type":"function","z":"359c8b708d6774da","name":"Criar sensor ","func":"function removerAcentosECedilhas(texto) {\n    var mapaAcentosHex = {\n        a: /[\\xE0-\\xE6]/g,\n        e: /[\\xE8-\\xEB]/g,\n        i: /[\\xEC-\\xEF]/g,\n        o: /[\\xF2-\\xF6]/g,\n        u: /[\\xF9-\\xFC]/g,\n        c: /\\xE7/g,\n        n: /\\xF1/g,\n    };\n\n    for (var letra in mapaAcentosHex) {\n        var expressaoRegular = mapaAcentosHex[letra];\n        texto = texto.replace(expressaoRegular, letra);\n    }\n\n    // Remover \"-\" e substituir por \"_\"\n    texto = texto.replace(/-/g, 'e');\n\n    texto = texto.replace(/\\|/g, 'e');\n\n    return texto;\n}\n\nvar textoComAcentosECedilhas = msg.entity_id;\nvar textoSemAcentosECedilhas = removerAcentosECedilhas(textoComAcentosECedilhas.toLowerCase());\n\nmsg.entity_id = textoSemAcentosECedilhas;\nmsg.payload = {\n    data: {\n        state: msg.state,\n        attributes: msg.attributes\n    }\n};\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":120,"wires":[["44084de7e58a9f18"]]},{"id":"498ed4c0923e3280","type":"switch","z":"359c8b708d6774da","name":"state = null != null","property":"state","propertyType":"env","rules":[{"t":"eq","v":"null","vt":"str"},{"t":"neq","v":"null","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":140,"wires":[["423c1f073312c853"],["431104959050d8bc"]]},{"id":"431104959050d8bc","type":"function","z":"359c8b708d6774da","name":"Criar sensor ","func":"msg.entity_id = env.get('entity_id')\nvar minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.payload = {\n    data: {\n        state: env.get(\"state\"),\n        attributes: env.get('attributes')\n    }\n };\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":160,"wires":[["44084de7e58a9f18"]]},{"id":"c8a7d575f65ec599","type":"function","z":"359c8b708d6774da","name":"adicionar arquivo na pasta","func":"msg.filename = \"/homeassistant/.dados/sensores/\"+msg.entity_id\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":140,"wires":[["e009fa126ba7773f"]],"info":"``msg.entity_id = 'sensor.game_' + msg.game;``\r\n``msg.state = msg.game,``\r\n    ``msg.attributes = {``\r\n        ``\"friendly_name\": msg.game,``\r\n        \"preco_justo\": msg.preco_justo,\r\n        \"platform\": msg.platform,\r\n        \"data\": [\r\n            {\r\n                \"title_default\": \"$title\",\r\n                \"line1_default\": \"$rating\",\r\n                \"line2_default\": msg.release[1],\r\n                \"line3_default\": \"$release\",\r\n                \"line4_default\": \"$studio\",\r\n            },\r\n            {\r\n                \"title\": msg.title,\r\n                \"poster\": msg.image[\"data-src\"],\r\n                \"rating\": \"Atual: \" + msg.price[0],\r\n                \"runtime\": msg.release[1],\r\n                \"studio\": \"MPH: \" + msg.lowest_price[2],\r\n                \"release\": msg.promo,\r\n                \"airdate\": msg.data_atual,\r\n            }\r\n        ]\r\n    }\r\nreturn msg;\r\n"},{"id":"e009fa126ba7773f","type":"file","z":"359c8b708d6774da","name":"save file","filename":"filename","filenameType":"msg","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":960,"y":140,"wires":[[]]},{"id":"b46fb34108187436","type":"function","z":"359c8b708d6774da","name":"Template sensor","func":"msg.entity_id = 'sensor.game_' + msg.game;\nmsg.state = msg.game,\n    msg.attributes = {\n        \"friendly_name\": msg.game,\n        \"preco_justo\": msg.preco_justo,\n        \"platform\": msg.platform,\n        \"data\": [\n            {\n                \"title_default\": \"$title\",\n                \"line1_default\": \"$rating\",\n                \"line2_default\": msg.release[1],\n                \"line3_default\": \"$release\",\n                \"line4_default\": \"$studio\",\n            },\n            {\n                \"title\": msg.title,\n                \"poster\": msg.image[\"data-src\"],\n                \"rating\": \"Atual: \" + msg.price[0],\n                \"runtime\": msg.release[1],\n                \"studio\": \"MPH: \" + msg.lowest_price[2],\n                \"release\": msg.promo,\n                \"airdate\": msg.data_atual,\n            }\n        ]\n    }\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":40,"wires":[[]]},{"id":"44084de7e58a9f18","type":"ha-api","z":"359c8b708d6774da","name":"","server":"db1ab0af.caa65","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"/api/states/{{entity_id}}","data":"","dataType":"json","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":570,"y":140,"wires":[["c8a7d575f65ec599"]]},{"id":"db1ab0af.caa65","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"e3f8c2a2b98f267c","type":"tab","label":"-Correios","disabled":false,"info":"","env":[]},{"id":"02a0e821c7fb8050","type":"group","z":"e3f8c2a2b98f267c","name":"Criando sensor de contagem ","style":{"label":true},"nodes":["7516e46afa6375aa","52354fa2985d27ca","b3260b98a51ef85c","743507b184757c78"],"x":44,"y":79,"w":402,"h":82},{"id":"140eafa3088f68d7","type":"group","z":"e3f8c2a2b98f267c","name":"Incluir rastreio","style":{"label":true},"nodes":["496e80d3a579c86c","91aa642df462cdd9","344d75c36480f997","147f521d4c2f2712","2940126187bdc08f","aedf37f5fd936478","e8975cf4aa13c03b","8460376b8e7f5cde","c16c3ca6a62b96c8","75eefdbd4360e282","0b35ee3ad31047d7","2f97b9e8ec585e30","78e6c92c05e41e57","79265861f92ee670","7c402b1f495e2279","19066586202c87a5","752aebd455055b85","f79d31758add7cb1","3701484f9d1d237a","478ee071fe1278d2","c6ea2b012fb6eb5b"],"x":34,"y":199,"w":1682,"h":202},{"id":"1b821dabf9f69c7b","type":"group","z":"e3f8c2a2b98f267c","name":"Excluir rastreio","style":{"label":true},"nodes":["dd266606d76b496b","ad9136ec07c3b51e","a068014999a36ca3","706d96a2c023e955","b0bc1c419cd3065c","27d3e1404b17643e","f7255c2a5d4c8321","9e65487e0358dccc","fd6bad1366aef9c6","a46c80027e65e950","308577f1195c5ba7","248c23d92eed4667","e047356332816ef9","e2227d7f54befd7c","e47704876389b2a6","3493a16f4c9284e6","b1f996f490fc5e56","055881704657d380","65b646228d08a8bd","28778b44cf8a912a"],"x":34,"y":419,"w":1452,"h":222},{"id":"7ba03e375f10a57f","type":"group","z":"e3f8c2a2b98f267c","name":"DEV","style":{"label":true},"nodes":["0504b628c1c154c4","f70de4302e9955b2","3c4aff81b6f65806","4ee42357efb0f549","225183653d37f5b1","56e48028d6e5b5ca","5cd4c57688c1798e","c141e82b28724825","58c9f97dfb2fec65","60a19b9ada44795b","8fb4e2cd9882eb58","aadab2cb86f61a98","666e01ffc77e40a4"],"x":34,"y":959,"w":752,"h":262},{"id":"f0887a3414e2a284","type":"group","z":"e3f8c2a2b98f267c","name":"Atualizações dos rastreios ","style":{"label":true},"nodes":["6a0b667b01597535","d6d783fbe58a8e3a","72aae8f2a54e2121","1a91a779d7d97d53","2b1f01ed97bfc0db","218ffb6d09436d5d","c2802caeb39d1ba6","3c9ad822115133ea","d74b570f28a1074b","28d653cbe7ff1433","540f4d06c1743248"],"x":44,"y":859,"w":1502,"h":82},{"id":"31bffe4a6c92a1c9","type":"group","z":"e3f8c2a2b98f267c","name":"Mudança de status","style":{"label":true},"nodes":["6ee5df1fc82a464d","6e6a13212fb24740","dfe312dd97c0a97e","0764074f927b168f","b1a939efdc3e01cd","2f5da89c104b37e7","0627ddfc79e1b798","c87610891f3339d1","68421d4aa0a39092","f999c9b9b7f08136","2dd53bf2796bed92"],"x":34,"y":679,"w":1342,"h":162},{"id":"7516e46afa6375aa","type":"inject","z":"e3f8c2a2b98f267c","g":"02a0e821c7fb8050","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"15","topic":"","payload":"","payloadType":"date","x":105,"y":120,"wires":[["52354fa2985d27ca"]],"l":false},{"id":"52354fa2985d27ca","type":"function","z":"e3f8c2a2b98f267c","g":"02a0e821c7fb8050","name":"function 32","func":"msg.state = flow.get(\"rastreio\").length\n\nif (msg.state > 0){\n    msg.entity_id = \"sensor.count_correios\"\n    \n    return [msg,null];\n} \nelse {\n    msg.entity_id = \"sensor.count_correios\"\n    msg.state = 0\n\n    return [null,msg]\n}\n\n","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":215,"y":120,"wires":[["743507b184757c78"],["743507b184757c78"]],"l":false},{"id":"b3260b98a51ef85c","type":"link in","z":"e3f8c2a2b98f267c","g":"02a0e821c7fb8050","name":"link in 54","links":["79265861f92ee670","a46c80027e65e950","fd6bad1366aef9c6"],"x":165,"y":120,"wires":[["52354fa2985d27ca"]]},{"id":"496e80d3a579c86c","type":"function","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Headers","func":"msg.url = \"https://www.linkcorreios.com.br/?id=\" + msg.rastreio\nmsg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n}\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":300,"wires":[["91aa642df462cdd9"]]},{"id":"91aa642df462cdd9","type":"http request","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":300,"wires":[["344d75c36480f997"]]},{"id":"344d75c36480f997","type":"html","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Status","property":"payload","outproperty":"status","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(1) > b","ret":"text","as":"single","x":870,"y":300,"wires":[["8460376b8e7f5cde"]]},{"id":"e8975cf4aa13c03b","type":"function","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"dados sensor","func":"let arrayRastreio = flow.get(\"rastreio\") || [];\narrayRastreio.push(msg.rastreio);\nflow.set(\"rastreio\", arrayRastreio);\n\n\nlet arrayObjeto = flow.get(\"nome_objeto\") || [];\narrayObjeto.push(msg.nome_objeto);\nflow.set(\"nome_objeto\", arrayObjeto);\n\nlet arrayNotificacao = flow.get(\"notificacao\") || [];\narrayNotificacao.push(msg.notificacao);\nflow.set(\"notificacao\", arrayNotificacao);\n\nmsg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase()\nmsg.state =  msg.status\nmsg.attributes = {\n    rastreio: msg.rastreio,\n    status: msg.status,\n    notificacao: msg.notificacao,\n    data: msg.data,\n    local: msg.local,\n    destino: msg.destino,\n    friendly_name: msg.nome_objeto.toUpperCase() + ' - ' + msg.rastreio.toUpperCase(),\n}\nreturn msg\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1400,"y":300,"wires":[["478ee071fe1278d2"]]},{"id":"8460376b8e7f5cde","type":"html","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Data","property":"payload","outproperty":"data","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(2)","ret":"text","as":"single","x":990,"y":300,"wires":[["c16c3ca6a62b96c8"]]},{"id":"c16c3ca6a62b96c8","type":"html","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Local","property":"payload","outproperty":"local","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(3)","ret":"text","as":"single","x":1110,"y":300,"wires":[["0b35ee3ad31047d7"]]},{"id":"0b35ee3ad31047d7","type":"html","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Destino","property":"payload","outproperty":"destino","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(4)","ret":"text","as":"single","x":1240,"y":300,"wires":[["e8975cf4aa13c03b"]]},{"id":"79265861f92ee670","type":"link out","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"link out 75","mode":"link","links":["392e29fa7c841991","4889d89cd6c1f2c0","b3260b98a51ef85c"],"x":1675,"y":300,"wires":[]},{"id":"7c402b1f495e2279","type":"delay","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"","pauseType":"delay","timeout":"6","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":235,"y":240,"wires":[["19066586202c87a5"]],"l":false},{"id":"752aebd455055b85","type":"function","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"function","func":"// Inicializar o array de opções\nvar options = [];\n\n// Loop através do array msg.sensores\nfor (var i = 0; i < msg.sensores.length; i++) {\n    // Adicionar o valor atual de msg.sensores[i].entity_id ao array de opções\n    options.push(msg.sensores[i].attributes.friendly_name);\n}\n\n// Definir as opções no objeto msg.payload.data\nmsg.payload = {\n    data: {\n        \"options\": options\n    }\n}\n\n// Enviar a mensagem modificada para o próximo nó\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":240,"wires":[["f79d31758add7cb1"]]},{"id":"3701484f9d1d237a","type":"link in","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"link in 55","links":["a46c80027e65e950","fd6bad1366aef9c6"],"x":325,"y":240,"wires":[["19066586202c87a5"]]},{"id":"dd266606d76b496b","type":"function","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Headers","func":"let partes = msg.rastreio.split('-');\nlet resultado = partes.pop().trim().toUpperCase();\nmsg.rastreio = resultado;\n\n\nvar index = flow.get(\"rastreio\").indexOf(msg.rastreio);\nvar rastreio = flow.get(\"rastreio\");\nvar nome_objeto = flow.get(\"nome_objeto\");\nvar notificacao = flow.get(\"notificacao\")\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\", rastreio)\n    nome_objeto.splice(index, 1);\n    flow.set(\"nome_objeto\",nome_objeto)\n    notificacao.splice(index, 1);\n    flow.set(\"notificacao\", notificacao)\n}\n\nmsg.entity_id = 'sensor.correios_' + msg.rastreio\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":460,"wires":[["b1f996f490fc5e56"]]},{"id":"b0bc1c419cd3065c","type":"switch","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"= Objeto entregue ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto entregue ao destinatário']","vt":"str"},{"t":"eq","v":"['Objeto entregue ao remetente']","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":440,"y":600,"wires":[["f7255c2a5d4c8321"],["f7255c2a5d4c8321"]]},{"id":"27d3e1404b17643e","type":"function","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Headers","func":"var index = flow.get(\"rastreio\").indexOf(msg.data.new_state.attributes.rastreio);\nvar rastreio = flow.get(\"rastreio\");\nvar nome_objeto = flow.get(\"nome_objeto\");\nvar notificacao = flow.get(\"notificacao\");\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\", rastreio)\n    nome_objeto.splice(index, 1);\n    flow.set(\"nome_objeto\", nome_objeto)\n    notificacao.splice(index, 1);\n    flow.set(\"notificacao\", notificacao)\n}\n\nmsg.entity_id = 'sensor.correios_' + msg.data.new_state.attributes.rastreio\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":600,"wires":[["3493a16f4c9284e6"]]},{"id":"f7255c2a5d4c8321","type":"delay","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":625,"y":600,"wires":[["27d3e1404b17643e"]],"l":false},{"id":"fd6bad1366aef9c6","type":"link out","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"link out 74","mode":"link","links":["3701484f9d1d237a","b3260b98a51ef85c"],"x":995,"y":600,"wires":[]},{"id":"a46c80027e65e950","type":"link out","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"link out 73","mode":"link","links":["3701484f9d1d237a","b3260b98a51ef85c"],"x":705,"y":500,"wires":[]},{"id":"248c23d92eed4667","type":"function","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"function","func":"// Inicializar o array de opções\nvar options = [];\n\nif (msg.sensores[0] != ''){\n    // Loop através do array msg.sensores\n    for (var i = 0; i < msg.sensores.length; i++) {\n        // Adicionar o valor atual de msg.sensores[i].entity_id ao array de opções\n        options.push(msg.sensores[i].attributes.friendly_name);\n    }\n}\nelse {\n    options = msg.sensores[0];\n}\n\n// Definir as opções no objeto msg.payload.data\nmsg.payload = {\n    data: {\n        \"options\": options\n    }\n}\n\n// Enviar a mensagem modificada para o próximo nó\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1100,"y":460,"wires":[["28778b44cf8a912a"]]},{"id":"e047356332816ef9","type":"function","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"function 33","func":"if (msg.sensores.length === 0) {\n    msg.sensores[0] = \"\";\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":975,"y":460,"wires":[["248c23d92eed4667"],["248c23d92eed4667"]],"l":false},{"id":"e2227d7f54befd7c","type":"delay","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":705,"y":460,"wires":[["308577f1195c5ba7"]],"l":false},{"id":"0504b628c1c154c4","type":"inject","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Revemor Rastreio","props":[{"p":"rastreio","v":"abre e fecha tuya","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":1000,"wires":[["f70de4302e9955b2"]]},{"id":"f70de4302e9955b2","type":"function","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Remover do array","func":"var index = flow.get(\"rastreio\").indexOf(msg.rastreio);\nvar rastreio = flow.get(\"rastreio\")\n\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\",rastreio)\n}\nreturn msg;\n\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":1000,"wires":[["3c4aff81b6f65806"]]},{"id":"3c4aff81b6f65806","type":"debug","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"remover array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":1000,"wires":[]},{"id":"4ee42357efb0f549","type":"inject","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Listar","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":1060,"wires":[["225183653d37f5b1"]]},{"id":"225183653d37f5b1","type":"template","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Listar array","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{flow.rastreio}}\n{{flow.nome_objeto}}\n{{flow.notificacao}}","output":"str","x":290,"y":1060,"wires":[["56e48028d6e5b5ca"]]},{"id":"56e48028d6e5b5ca","type":"debug","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"listar array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":1060,"wires":[]},{"id":"5cd4c57688c1798e","type":"inject","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Zerar Array","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":1120,"wires":[["c141e82b28724825"]]},{"id":"c141e82b28724825","type":"function","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Limpar  array","func":"var clear_rastreio = flow.get(\"rastreio\");\nclear_rastreio = [] || [];\nflow.set(\"rastreio\", clear_rastreio);\n\nvar clear_nome_objeto = flow.get(\"nome_objeto\");\nclear_nome_objeto = [] || [];\nflow.set(\"nome_objeto\", clear_nome_objeto);\n\nvar clear_notificacao = flow.get(\"notificacao\");\nclear_notificacao = [] || [];\nflow.set(\"notificacao\", clear_notificacao);\n\nreturn msg;\n\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":1120,"wires":[["58c9f97dfb2fec65"]]},{"id":"58c9f97dfb2fec65","type":"debug","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"array limpo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":1120,"wires":[]},{"id":"60a19b9ada44795b","type":"function","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Headers","func":"msg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    \"Authorization\": \"Bearer \"+global.get(\"token\"),\n}\n\nmsg.url = 'http://'+global.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":1180,"wires":[["8fb4e2cd9882eb58"]]},{"id":"8fb4e2cd9882eb58","type":"http request","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":490,"y":1180,"wires":[["aadab2cb86f61a98"]]},{"id":"aadab2cb86f61a98","type":"debug","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"remover sensor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":1180,"wires":[]},{"id":"666e01ffc77e40a4","type":"inject","z":"e3f8c2a2b98f267c","g":"7ba03e375f10a57f","name":"Deletar sensor","props":[{"p":"rastreio","v":"NL658154191BR","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":1180,"wires":[["60a19b9ada44795b"]]},{"id":"6a0b667b01597535","type":"function","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Headers","func":"for (var i = 0; i < flow.get(\"rastreio\").length; i++) {\n    msg.url = \"https://www.linkcorreios.com.br/?id=\" + flow.get(\"rastreio\")[i]\n    msg.headers = {\n        \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    }\n\n    msg.rastreio = flow.get(\"rastreio\")[i]\n    msg.nome_objeto = flow.get(\"nome_objeto\")[i]\n    msg.notificacao = flow.get(\"notificacao\")[i]\n\n    flow.get(\"rastreio\")[i] + 1;\n\n    node.send([msg]); \n}\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":900,"wires":[["d6d783fbe58a8e3a"]]},{"id":"d6d783fbe58a8e3a","type":"http request","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":330,"y":900,"wires":[["d74b570f28a1074b"]]},{"id":"72aae8f2a54e2121","type":"html","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Status","property":"payload","outproperty":"status","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(1) > b","ret":"text","as":"single","x":630,"y":900,"wires":[["1a91a779d7d97d53"]]},{"id":"1a91a779d7d97d53","type":"html","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Data","property":"payload","outproperty":"data","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(2)","ret":"text","as":"single","x":750,"y":900,"wires":[["2b1f01ed97bfc0db"]]},{"id":"2b1f01ed97bfc0db","type":"html","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Local","property":"payload","outproperty":"local","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(3)","ret":"text","as":"single","x":870,"y":900,"wires":[["218ffb6d09436d5d"]]},{"id":"218ffb6d09436d5d","type":"html","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Destino","property":"payload","outproperty":"destino","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(4)","ret":"text","as":"single","x":1000,"y":900,"wires":[["28d653cbe7ff1433"]]},{"id":"c2802caeb39d1ba6","type":"inject","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"Atualiza de 1 em 1 min ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"120","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":105,"y":900,"wires":[["6a0b667b01597535"]],"l":false},{"id":"3c9ad822115133ea","type":"function","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"dados sensor","func":"msg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase();\nmsg.state = msg.status,\nmsg.attributes = {\n    rastreio: msg.rastreio,\n    status: msg.status,\n    data: msg.data,\n    notificacao: msg.notificacao,\n    local: msg.local,\n    destino: msg.destino,\n    friendly_name: msg.nome_objeto.toUpperCase() + ' - ' + msg.rastreio.toUpperCase(),\n}\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1280,"y":900,"wires":[["540f4d06c1743248"]]},{"id":"d74b570f28a1074b","type":"delay","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"","pauseType":"rate","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"3","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":480,"y":900,"wires":[["72aae8f2a54e2121"]]},{"id":"28d653cbe7ff1433","type":"function","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"!= Null","func":"if (msg.data.length === 0) {\n    msg.data[0] = null;\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1130,"y":900,"wires":[[],["3c9ad822115133ea"]]},{"id":"6e6a13212fb24740","type":"switch","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Notificacao = Sim / Saiu para entrega","property":"data.new_state.attributes.notificacao","propertyType":"msg","rules":[{"t":"eq","v":"Sim","vt":"str"},{"t":"eq","v":"Saiu para entrega","vt":"str"},{"t":"eq","v":"Objeto entregue","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":570,"y":760,"wires":[["0764074f927b168f"],["b1a939efdc3e01cd"],["c87610891f3339d1"]]},{"id":"dfe312dd97c0a97e","type":"link out","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"link out 19","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":975,"y":720,"wires":[]},{"id":"0764074f927b168f","type":"template","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Todas notificações","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":850,"y":720,"wires":[["dfe312dd97c0a97e"]]},{"id":"b1a939efdc3e01cd","type":"switch","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"= Objeto saiu para entrega ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto saiu para entrega ao destinatário']","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":920,"y":760,"wires":[["2f5da89c104b37e7"]]},{"id":"2f5da89c104b37e7","type":"template","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Saiu para entrega","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":1210,"y":760,"wires":[["f999c9b9b7f08136"]]},{"id":"0627ddfc79e1b798","type":"function","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"!= Null","func":"if (msg.data.new_state.attributes.data.length === 0) {\n    msg.data.new_state.attributes.data[0] = null;\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":760,"wires":[[],["6e6a13212fb24740"]]},{"id":"c87610891f3339d1","type":"switch","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"= Objeto entregue ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto entregue ao destinatário']","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":900,"y":800,"wires":[["68421d4aa0a39092"]]},{"id":"68421d4aa0a39092","type":"template","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Objeto entregue","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":1200,"y":800,"wires":[["2dd53bf2796bed92"]]},{"id":"f999c9b9b7f08136","type":"link out","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"link out 76","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":760,"wires":[]},{"id":"2dd53bf2796bed92","type":"link out","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"link out 77","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":800,"wires":[]},{"id":"478ee071fe1278d2","type":"subflow:359c8b708d6774da","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"","env":[{"name":"entity_id","value":"","type":"str"},{"name":"attributes","value":"","type":"str"}],"x":1570,"y":300,"wires":[["79265861f92ee670"]]},{"id":"e47704876389b2a6","type":"subflow:5082e6363013a9b9","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","x":1390,"y":460,"wires":[[]]},{"id":"c6ea2b012fb6eb5b","type":"subflow:5082e6363013a9b9","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"","x":950,"y":240,"wires":[[]]},{"id":"540f4d06c1743248","type":"subflow:359c8b708d6774da","z":"e3f8c2a2b98f267c","g":"f0887a3414e2a284","name":"","env":[{"name":"entity_id","value":"","type":"str"},{"name":"attributes","value":"","type":"str"}],"x":1450,"y":900,"wires":[[]]},{"id":"3493a16f4c9284e6","type":"subflow:d813744a14e47c58","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":880,"y":600,"wires":[[],["fd6bad1366aef9c6","65b646228d08a8bd"]]},{"id":"b1f996f490fc5e56","type":"subflow:d813744a14e47c58","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":580,"y":460,"wires":[[],["a46c80027e65e950","e2227d7f54befd7c"]]},{"id":"055881704657d380","type":"link in","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"link in 58","links":["65b646228d08a8bd"],"x":755,"y":460,"wires":[["308577f1195c5ba7"]]},{"id":"65b646228d08a8bd","type":"link out","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"link out 84","mode":"link","links":["055881704657d380"],"x":995,"y":560,"wires":[]},{"id":"aedf37f5fd936478","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Limpar texto","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.correios_nome_objeto","input_text.correios_rastreio"],"data":"{\"value\":\"\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":130,"y":360,"wires":[["78e6c92c05e41e57"]]},{"id":"78e6c92c05e41e57","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Limpar select","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":["input_select.correios_notificacao"],"data":"{\"option\":\"Sim\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":370,"y":360,"wires":[[]]},{"id":"f79d31758add7cb1","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Criar lista","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_select","service":"set_options","areaId":[],"deviceId":[],"entityId":["input_select.rastreio"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"data"},{"property":"entity_id","propertyType":"msg","value":"input_select.rastreio","valueType":"str"}],"queue":"none","x":780,"y":240,"wires":[["c6ea2b012fb6eb5b"]]},{"id":"706d96a2c023e955","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Limpar texto","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.correios_nome_objeto","input_text.correios_rastreio"],"data":"{\"value\":\"\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":130,"y":520,"wires":[[]]},{"id":"147f521d4c2f2712","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Rastreio","server":"db1ab0af.caa65","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_text.correios_rastreio","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"rastreio","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":120,"y":300,"wires":[["aedf37f5fd936478","2f97b9e8ec585e30"]]},{"id":"75eefdbd4360e282","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Nome objeto","server":"db1ab0af.caa65","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_text.correios_nome_objeto","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"nome_objeto","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":470,"y":300,"wires":[["496e80d3a579c86c"]]},{"id":"2f97b9e8ec585e30","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Notificação","server":"db1ab0af.caa65","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.correios_notificacao","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"notificacao","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":310,"y":300,"wires":[["75eefdbd4360e282"]]},{"id":"a068014999a36ca3","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Rastreio","server":"db1ab0af.caa65","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.rastreio","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"rastreio","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":280,"y":460,"wires":[["dd266606d76b496b"]]},{"id":"2940126187bdc08f","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"SALVAR","server":"db1ab0af.caa65","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.correios_salvar","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":120,"y":240,"wires":[["147f521d4c2f2712","7c402b1f495e2279"]]},{"id":"ad9136ec07c3b51e","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"EXCLUIR","server":"db1ab0af.caa65","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.correios_excluir","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":460,"wires":[["706d96a2c023e955","a068014999a36ca3"]]},{"id":"9e65487e0358dccc","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Excluir automaticamente","server":"db1ab0af.caa65","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.correios_","entityIdType":"regex","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":600,"wires":[["b0bc1c419cd3065c"]]},{"id":"6ee5df1fc82a464d","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"31bffe4a6c92a1c9","name":"Aviso mudança de status","server":"db1ab0af.caa65","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.correios_","entityIdType":"regex","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":760,"wires":[["0627ddfc79e1b798"]]},{"id":"19066586202c87a5","type":"ha-get-entities","z":"e3f8c2a2b98f267c","g":"140eafa3088f68d7","name":"Pegar sensores","server":"db1ab0af.caa65","version":1,"rules":[{"property":"entity_id","logic":"starts_with","value":"sensor.correios_","valueType":"str"}],"outputType":"array","outputEmptyResults":false,"outputLocationType":"msg","outputLocation":"sensores","outputResultsCount":1,"x":480,"y":240,"wires":[["752aebd455055b85"]]},{"id":"308577f1195c5ba7","type":"ha-get-entities","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Pegar sensores","server":"db1ab0af.caa65","version":1,"rules":[{"property":"entity_id","logic":"starts_with","value":"sensor.correios_","valueType":"str"}],"outputType":"array","outputEmptyResults":true,"outputLocationType":"msg","outputLocation":"sensores","outputResultsCount":1,"x":860,"y":460,"wires":[["e047356332816ef9"]]},{"id":"743507b184757c78","type":"subflow:359c8b708d6774da","z":"e3f8c2a2b98f267c","g":"02a0e821c7fb8050","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":350,"y":120,"wires":[[]]},{"id":"28778b44cf8a912a","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"1b821dabf9f69c7b","name":"Criar lista","server":"db1ab0af.caa65","version":5,"debugenabled":false,"domain":"input_select","service":"set_options","areaId":[],"deviceId":[],"entityId":["input_select.rastreio"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"data"},{"property":"entity_id","propertyType":"msg","value":"input_select.rastreio","valueType":"str"}],"queue":"none","x":1240,"y":460,"wires":[["e47704876389b2a6"]]}]

Eu vi exemplos do NodeRed, e Codigos do Card, mas não entendi é onde está a integração com os Correios mesmo… alguem pode me auxiliar ?

o que o flow do nodered faz é ir no site linkcorreios.com.br/?id=NM1136873326BR onde id= é o rastreio que vc adiciona nos card, então ele vai notificando e avisando, excluindo automaticamente.

Alguns problemas resolvidos, aparentemente funcionando.

Em 2 instalações novas com tudo atualizado, o card não funcionou, ao clicar em “Novo” ou “Excluir” não abria as caixas de seleção, então voltei a fazer os testes somente no meu HA de produção.

@kelvinrafaeli a parte de excluir os rastreios não esta presente nos 2 últimos fluxos postados, achei que já tinha o complemento postado no dia 23/12.

Abaixo segue alguns problemas que detectei e talvez a ordem em que foram corrigidos poderia ter encurtado o tempo gasto para resolver. Talvez se atualizar o node-red-contrib-home-assistant-websocket antes de importar o fluxo resolva os problemas que tive.
Começando com fluxo do dia 12/01/2024 + complemento dia 23/12/2023:

1 - Por algum motivo, mesmo atualizando o Node Red, o node-red-contrib-home-assistant-websocket estava em uma versão antiga, mesmo eu tendo feito uma atualização hoje.

2 - Mesmo após atualizar o node-red-contrib-home-assistant-websocket alguns nós “Pegar sensores” e “Criar lista” estavam apresentando erro. Criei novos nós iguais ao original e resolveu o problema (bug no NR). Erro:

ValidationError: "outputResultsCount" must be a number

3 - O inject do token não estava habilitado para rodar após o deploy, dando erro na URL para apagar os sensores.

4 - Alterei 2 nós que davam erros quando não tinha nada na lista

5 - Alterei o caminho para salvar os sensores na pasta do Node-red

Depois faço um teste instalando os fluxos originais, para ver se era somente isso, já que o node-red-contrib-home-assistant-websocket está atualizado agora.

Mesmo após apagar o rastreio, ele ainda fica na caixa “excluir”, não sei se é o comportamento normal, ou ainda falta corrigir alguma coisa.

[{"id":"558bbafe7c61aa44","type":"subflow","name":"Ler lista","info":"","category":"","in":[{"x":100,"y":180,"wires":[{"id":"e36d879cec8dcfd1"}]}],"out":[{"x":940,"y":180,"wires":[{"id":"ab0a86371ec2c421","port":0}]}],"env":[{"name":"Deixar null se for utilizar variavavel externa msg.input_select, ou mudar null para input_selec.nome_lista","type":"str","value":"","ui":{"type":"none"}},{"name":"entity_id","type":"str","value":"null"}],"meta":{},"color":"#DDAA99"},{"id":"ab0a86371ec2c421","type":"function","z":"558bbafe7c61aa44","name":"Passando sensor","func":"var payload = JSON.parse(msg.payload);\nmsg.payload = payload;\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":810,"y":180,"wires":[[]]},{"id":"e36d879cec8dcfd1","type":"switch","z":"558bbafe7c61aa44","name":"input_select = null != null","property":"entity_id","propertyType":"env","rules":[{"t":"neq","v":"null","vt":"str"},{"t":"eq","v":"null","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":180,"wires":[["c2e63357cf754098"],["5aa8cf40c3c2f5e2"]]},{"id":"5aa8cf40c3c2f5e2","type":"function","z":"558bbafe7c61aa44","name":"caminho","func":"msg.entity_id = msg.entity_id\nmsg.filename = \"/config/node-red/correios/input_select/\" + msg.entity_id\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":200,"wires":[["b60f48b966ae6746"]]},{"id":"c2e63357cf754098","type":"function","z":"558bbafe7c61aa44","name":"caminho","func":"msg.entity_id = env.get('entity_id')\nmsg.filename = \"/config/node-red/correios/input_select/\" + msg.entity_id\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":160,"wires":[["b60f48b966ae6746"]]},{"id":"b60f48b966ae6746","type":"file in","z":"558bbafe7c61aa44","name":"Ler dados","filename":"filename","filenameType":"msg","format":"lines","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":640,"y":180,"wires":[["ab0a86371ec2c421"]]},{"id":"9e57d26033fa55bc","type":"subflow","name":"Ler sensor","info":"","category":"","in":[{"x":120,"y":240,"wires":[{"id":"eceb5ee014fdc831"}]}],"out":[{"x":920,"y":240,"wires":[{"id":"1d81d5ed9095f708","port":0}]}],"env":[{"name":"Deixar null se for utilizar variavavel externa msg.entity_id, ou mudar null para sensor.nome_sensor","type":"str","value":"","ui":{"type":"none"}},{"name":"entity_id","type":"str","value":"null"},{"name":"input_select","type":"str","value":"null"}],"meta":{},"color":"#DDAA99"},{"id":"0093b527858d8109","type":"file in","z":"9e57d26033fa55bc","name":"Ler dados","filename":"filename","filenameType":"msg","format":"lines","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":620,"y":240,"wires":[["1d81d5ed9095f708"]]},{"id":"1d81d5ed9095f708","type":"function","z":"9e57d26033fa55bc","name":"Passando sensor","func":"var payload = JSON.parse(msg.payload);\n\nmsg.entity_id = payload.entity_id\n\n// Remover informações indesejadas\ndelete payload.entity_id;\ndelete payload.last_changed;\ndelete payload.last_updated;\ndelete payload.context;\n\nmsg.payload = {\n    data: payload\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":240,"wires":[[]]},{"id":"20bf062b4a05e21b","type":"function","z":"9e57d26033fa55bc","name":"caminho","func":"msg.entity_id = msg.entity_id\nmsg.filename = \"/config/node-red/correios/sensores/\"+msg.entity_id\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":260,"wires":[["0093b527858d8109"]]},{"id":"eceb5ee014fdc831","type":"switch","z":"9e57d26033fa55bc","name":"entity_id= null != null","property":"entity_id","propertyType":"env","rules":[{"t":"neq","v":"null","vt":"str"},{"t":"eq","v":"null","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":240,"wires":[["68f6eb8e50946811"],["20bf062b4a05e21b"]]},{"id":"68f6eb8e50946811","type":"function","z":"9e57d26033fa55bc","name":"caminho","func":"msg.entity_id = env.get('entity_id')\nmsg.filename = \"/config/node-red/correios/sensores/\"+msg.entity_id\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":220,"wires":[["0093b527858d8109"]]},{"id":"f4d240c42f148509","type":"subflow","name":"Deletar sensor","info":"","category":"","in":[{"x":200,"y":180,"wires":[{"id":"b6a6e05895afba43"}]}],"out":[{"x":800,"y":180,"wires":[{"id":"5b4a621dcafc67eb","port":0}]},{"x":800,"y":120,"wires":[{"id":"9415556045992c6f","port":0}]}],"env":[{"name":"entity_id","type":"str","value":"null"}],"meta":{},"color":"#DDAA99"},{"id":"39bcc53cce3569df","type":"function","z":"f4d240c42f148509","name":"caminho","func":"msg.entity_id = env.get('entity_id')\nvar minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.filename = \"/config/node-red/correios/sensores/\"+msg.entity_id\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":200,"wires":[["5b4a621dcafc67eb"]]},{"id":"b6a6e05895afba43","type":"switch","z":"f4d240c42f148509","name":"entity_id= null != null","property":"entity_id","propertyType":"env","rules":[{"t":"neq","v":"null","vt":"str"},{"t":"eq","v":"null","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":340,"y":180,"wires":[["799dd48014be7e47","96d091d383f4292c"],["39bcc53cce3569df","96d091d383f4292c"]]},{"id":"5b4a621dcafc67eb","type":"fs-ops-delete","z":"f4d240c42f148509","name":"Deletar dados","path":"","pathType":"str","filename":"filename","filenameType":"msg","x":680,"y":180,"wires":[[]]},{"id":"799dd48014be7e47","type":"function","z":"f4d240c42f148509","name":"caminho","func":"var minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.filename = \"/config/node-red/correios/sensores/\" + msg.entity_id\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":160,"wires":[["5b4a621dcafc67eb"]]},{"id":"96d091d383f4292c","type":"function","z":"f4d240c42f148509","name":"Filtro","func":"msg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    \"Authorization\": \"Bearer \" + global.get(\"token\"),\n}\n\nmsg.url = 'http://' + global.get(\"ip\") + '/api/states/' + msg.entity_id\n\n\nreturn msg\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":120,"wires":[["9415556045992c6f"]]},{"id":"9415556045992c6f","type":"http request","z":"f4d240c42f148509","name":"Deleta sensor","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":660,"y":120,"wires":[[]]},{"id":"10cee52504db3830","type":"subflow","name":"Salvar lista","info":"","category":"","in":[{"x":260,"y":80,"wires":[{"id":"66f9b87eb6cc3c33"}]}],"out":[{"x":800,"y":80,"wires":[{"id":"be31012bd0b91ead","port":0}]}],"env":[{"name":"No nó call-service em Output properties, colocar msg.entity_id e selecionar send data","type":"str","value":"","ui":{"type":"none"}}],"meta":{},"color":"#DDAA99"},{"id":"be31012bd0b91ead","type":"file","z":"10cee52504db3830","name":"salvar lista","filename":"filename","filenameType":"msg","appendNewline":true,"createDir":true,"overwriteFile":"true","encoding":"none","x":690,"y":80,"wires":[[]]},{"id":"66f9b87eb6cc3c33","type":"function","z":"10cee52504db3830","name":"caminho","func":"msg.filename = \"/config/node-red/correios/input_select/\" + msg.entity_id\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":80,"wires":[["3e9abadbac4a3f53"]]},{"id":"3e9abadbac4a3f53","type":"change","z":"10cee52504db3830","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":80,"wires":[["be31012bd0b91ead"]]},{"id":"67ec3e5ceb42cb6d","type":"subflow","name":"Criar sensor","category":"","in":[{"x":60,"y":140,"wires":[{"id":"049c5d9bf02bf634"}]}],"out":[{"x":1060,"y":140,"wires":[{"id":"b78f5a1fa74e9d4e","port":0}]}],"env":[{"name":"entity_id","type":"str","value":"sensor.","ui":{"label":{"en-US":"entity_id"}}},{"name":"Deixar null para utilizar variaveis externas, msg.entity_id, msg.state, msg.attributes","type":"str","value":"","ui":{"type":"none"}},{"name":"state","type":"str","value":"null","ui":{"label":{"en-US":"state"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","cred"]}}},{"name":"attributes","type":"json","value":"{\"friendly_name\":\"nome_teste\",\"state_class\":\"measurement\",\"device_class\":\"temperature\",\"unit_of_measurement\":\"°C\",\"icon\":\"mdi:information\"}","ui":{"label":{"en-US":"attributes"}}}],"meta":{},"color":"#DDAA99"},{"id":"0c3e62c03bc26f2c","type":"function","z":"67ec3e5ceb42cb6d","name":"Criar sensor ","func":"function removerAcentosECedilhas(texto) {\n    var mapaAcentosHex = {\n        a: /[\\xE0-\\xE6]/g,\n        e: /[\\xE8-\\xEB]/g,\n        i: /[\\xEC-\\xEF]/g,\n        o: /[\\xF2-\\xF6]/g,\n        u: /[\\xF9-\\xFC]/g,\n        c: /\\xE7/g,\n        n: /\\xF1/g,\n    };\n\n    for (var letra in mapaAcentosHex) {\n        var expressaoRegular = mapaAcentosHex[letra];\n        texto = texto.replace(expressaoRegular, letra);\n    }\n\n    // Remover \"-\" e substituir por \"_\"\n    texto = texto.replace(/-/g, 'e');\n\n    texto = texto.replace(/\\|/g, 'e');\n\n    return texto;\n}\n\nvar textoComAcentosECedilhas = msg.entity_id;\nvar textoSemAcentosECedilhas = removerAcentosECedilhas(textoComAcentosECedilhas.toLowerCase());\n\nmsg.entity_id = textoSemAcentosECedilhas;\nmsg.payload = {\n    data: {\n        state: msg.state,\n        attributes: msg.attributes\n    }\n};\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":120,"wires":[["1ece7106f7bd64c0"]]},{"id":"049c5d9bf02bf634","type":"switch","z":"67ec3e5ceb42cb6d","name":"state = null != null","property":"state","propertyType":"env","rules":[{"t":"eq","v":"null","vt":"str"},{"t":"neq","v":"null","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":140,"wires":[["0c3e62c03bc26f2c"],["c616d0eda11bf91a"]]},{"id":"c616d0eda11bf91a","type":"function","z":"67ec3e5ceb42cb6d","name":"Criar sensor ","func":"msg.entity_id = env.get('entity_id')\nvar minuscula = msg.entity_id.toLowerCase();\nmsg.entity_id = minuscula\nmsg.payload = {\n    data: {\n        state: env.get(\"state\"),\n        attributes: env.get('attributes')\n    }\n };\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":160,"wires":[["1ece7106f7bd64c0"]]},{"id":"1cc8df26e68cbd2a","type":"function","z":"67ec3e5ceb42cb6d","name":"adicionar arquivo na pasta","func":"msg.filename = \"/config/node-red/correios/sensores/\"+msg.entity_id\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":140,"wires":[["b78f5a1fa74e9d4e"]],"info":"``msg.entity_id = 'sensor.game_' + msg.game;``\r\n``msg.state = msg.game,``\r\n    ``msg.attributes = {``\r\n        ``\"friendly_name\": msg.game,``\r\n        \"preco_justo\": msg.preco_justo,\r\n        \"platform\": msg.platform,\r\n        \"data\": [\r\n            {\r\n                \"title_default\": \"$title\",\r\n                \"line1_default\": \"$rating\",\r\n                \"line2_default\": msg.release[1],\r\n                \"line3_default\": \"$release\",\r\n                \"line4_default\": \"$studio\",\r\n            },\r\n            {\r\n                \"title\": msg.title,\r\n                \"poster\": msg.image[\"data-src\"],\r\n                \"rating\": \"Atual: \" + msg.price[0],\r\n                \"runtime\": msg.release[1],\r\n                \"studio\": \"MPH: \" + msg.lowest_price[2],\r\n                \"release\": msg.promo,\r\n                \"airdate\": msg.data_atual,\r\n            }\r\n        ]\r\n    }\r\nreturn msg;\r\n"},{"id":"b78f5a1fa74e9d4e","type":"file","z":"67ec3e5ceb42cb6d","name":"save file","filename":"filename","filenameType":"msg","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":960,"y":140,"wires":[[]]},{"id":"ca294ef8f533b7b8","type":"function","z":"67ec3e5ceb42cb6d","name":"Template sensor","func":"msg.entity_id = 'sensor.game_' + msg.game;\nmsg.state = msg.game,\n    msg.attributes = {\n        \"friendly_name\": msg.game,\n        \"preco_justo\": msg.preco_justo,\n        \"platform\": msg.platform,\n        \"data\": [\n            {\n                \"title_default\": \"$title\",\n                \"line1_default\": \"$rating\",\n                \"line2_default\": msg.release[1],\n                \"line3_default\": \"$release\",\n                \"line4_default\": \"$studio\",\n            },\n            {\n                \"title\": msg.title,\n                \"poster\": msg.image[\"data-src\"],\n                \"rating\": \"Atual: \" + msg.price[0],\n                \"runtime\": msg.release[1],\n                \"studio\": \"MPH: \" + msg.lowest_price[2],\n                \"release\": msg.promo,\n                \"airdate\": msg.data_atual,\n            }\n        ]\n    }\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":40,"wires":[[]]},{"id":"1ece7106f7bd64c0","type":"ha-api","z":"67ec3e5ceb42cb6d","name":"","server":"33803899.487d48","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"/api/states/{{entity_id}}","data":"","dataType":"json","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":570,"y":140,"wires":[["1cc8df26e68cbd2a"]]},{"id":"33803899.487d48","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"a7d248bcbb7263b0","type":"tab","label":"Correios","disabled":false,"info":"","env":[]},{"id":"c91e7a79d6449e85","type":"group","z":"a7d248bcbb7263b0","name":"Criando sensor de contagem ","style":{"label":true},"nodes":["58fb193b084a285d","a21ad94da59b9e8b","22f708e086056d47","4e7b15df55b9b416"],"x":44,"y":79,"w":402,"h":82},{"id":"17c39274dfde2601","type":"group","z":"a7d248bcbb7263b0","name":"Incluir rastreio","style":{"label":true},"nodes":["86f88adbb208d8bb","9e6faf7a8ac65250","752ddaf84f346612","9faee5f619da1541","395b607cbaf66fb7","237f0f1160fd90d2","a91d0373465af238","20c6bbb7cc6acf5a","3f4f397e054bc67f","b32d725b9c97f409","6cb18a4a9ba97d68","8ac55d001ed2d6df","e54efa88d59159ed","af399a8321148c54","e6bb92289a1c13cd","e99c5fee8ac455d7","8c0c17b35b4481a8","204c53c40a74134d","d0f624312d1deb6a","2b9ce4e2ea87c3b5","36b953d0372f9d63"],"x":34,"y":159,"w":1682,"h":242},{"id":"c025a4fda154de8e","type":"group","z":"a7d248bcbb7263b0","name":"Excluir rastreio","style":{"label":true},"nodes":["c699c6ab9d03f1a0","bca510ff1d3ca76c","9c321bb56548160e","99acc3e78ecc99f9","f1202f3ad3e6f974","a63aa08bfabd6ebb","0d31692371bacbba","6adf7a790e90a254","9b41e0d90bc9dad1","683688a0b84fab71","9831689d8269487e","b012263b46c66bc5","c2e02b402e6907b4","4186a8b562913425","8887385efc0f388c","1c82f1837df9c70f","d3bd4ca607da4882","022e158ba5d9efe2","a6ad21e70a8699ea","640428762a874c2c","90a51380129caf2f"],"x":34,"y":419,"w":1452,"h":222},{"id":"5ac2e68ec7f25715","type":"group","z":"a7d248bcbb7263b0","name":"DEV","style":{"label":true},"nodes":["5d53ade34e356c49","923732875bee1443","19fa24f29c11e09c","82e17a10726733c7","b452bcacb1145490","872a676c73225632","27ed12693b9ac70e","af2c533201632e20","1311debf75a84f8a","8c9e699289403d5f","ab3afc6b0b8b4760","5df2adf184af6d11","60bc392f32456913"],"x":34,"y":959,"w":752,"h":262},{"id":"9eaaa7e98dce281c","type":"group","z":"a7d248bcbb7263b0","name":"Atualizações dos rastreios ","style":{"label":true},"nodes":["aa6f84b72738b7cf","b0482748d6c5ee23","69a63d712ce9b050","aa6d024a07798e9b","c8414966e37712c9","a82fe00781f82f80","1a187d54eedb6bdf","e6e3afcffc7cdd53","cc0d230dbb9364b6","cc98a1d9ecfe6615","bc3907bc8ace72c3"],"x":44,"y":859,"w":1502,"h":82},{"id":"f82e7fcac77fcdce","type":"group","z":"a7d248bcbb7263b0","name":"Mudança de status","style":{"label":true},"nodes":["d5dbb2d4194044b4","5b9fee0119038753","2199f044b2974ac9","92d0758cf213c439","0a298f8855b24575","9407ea03efd567f3","f0a4e92c5c6d6fed","b40f832ae82b77e4","bea85712d4069697","bf478b4962d0081d","7918caa1b3e326e0"],"x":34,"y":679,"w":1342,"h":162},{"id":"312e60c216619f75","type":"group","z":"a7d248bcbb7263b0","name":"","style":{"label":true},"nodes":["8d25ef90a8e41ac8","dc076f7bc4f06074","f2d04ad7b278f30d"],"x":544,"y":39,"w":342,"h":122},{"id":"aaef3e5f23494904","type":"group","z":"a7d248bcbb7263b0","name":"","style":{"label":true},"nodes":["dca51185b66b18e4","64c02069b07364c7","2f4096629b19069f","68b449bffaa8eed7","4c9433bc8acfd5b0","5f8738b28924c566","3dba425df7b0fd88","8a1e06d6f7d05181","6d22970fdb3f9fce","87f778fce5a87355","fc37230f17867168","fac8b1fc8dd57be6","46bdc4eeccd6975c","db9ae1c46283c633","320e751a9ab3d0ed","89056bb779ec081f","faf985cc802317f3"],"x":34,"y":1259,"w":1172,"h":222},{"id":"58fb193b084a285d","type":"inject","z":"a7d248bcbb7263b0","g":"c91e7a79d6449e85","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"15","topic":"","payload":"","payloadType":"date","x":105,"y":120,"wires":[["a21ad94da59b9e8b"]],"l":false},{"id":"a21ad94da59b9e8b","type":"function","z":"a7d248bcbb7263b0","g":"c91e7a79d6449e85","name":"function 32","func":"if (typeof flow.get(\"rastreio\") !== 'undefined') {\n    msg.state = flow.get(\"rastreio\").length;\n\n    if (msg.state > 0) {\n        msg.entity_id = \"sensor.count_correios\";\n\n        return [msg, null];\n    }\n    else {\n        msg.entity_id = \"sensor.count_correios\";\n        msg.state = 0;\n\n        return [null, msg]\n    }\n\n}","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":215,"y":120,"wires":[["4e7b15df55b9b416"],["4e7b15df55b9b416"]],"l":false},{"id":"22f708e086056d47","type":"link in","z":"a7d248bcbb7263b0","g":"c91e7a79d6449e85","name":"link in 54","links":["af399a8321148c54","683688a0b84fab71","9b41e0d90bc9dad1"],"x":165,"y":120,"wires":[["a21ad94da59b9e8b"]]},{"id":"86f88adbb208d8bb","type":"function","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Headers","func":"msg.url = \"https://www.linkcorreios.com.br/?id=\" + msg.rastreio\nmsg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n}\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":300,"wires":[["9e6faf7a8ac65250"]]},{"id":"9e6faf7a8ac65250","type":"http request","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":300,"wires":[["752ddaf84f346612"]]},{"id":"752ddaf84f346612","type":"html","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Status","property":"payload","outproperty":"status","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(1) > b","ret":"text","as":"single","x":870,"y":300,"wires":[["20c6bbb7cc6acf5a"]]},{"id":"a91d0373465af238","type":"function","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"dados sensor","func":"let arrayRastreio = flow.get(\"rastreio\") || [];\narrayRastreio.push(msg.rastreio);\nflow.set(\"rastreio\", arrayRastreio);\n\n\nlet arrayObjeto = flow.get(\"nome_objeto\") || [];\narrayObjeto.push(msg.nome_objeto);\nflow.set(\"nome_objeto\", arrayObjeto);\n\nlet arrayNotificacao = flow.get(\"notificacao\") || [];\narrayNotificacao.push(msg.notificacao);\nflow.set(\"notificacao\", arrayNotificacao);\n\nmsg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase()\nmsg.state =  msg.status\nmsg.attributes = {\n    rastreio: msg.rastreio,\n    status: msg.status,\n    notificacao: msg.notificacao,\n    data: msg.data,\n    local: msg.local,\n    destino: msg.destino,\n    friendly_name: msg.nome_objeto.toUpperCase() + ' - ' + msg.rastreio.toUpperCase(),\n}\nreturn msg\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1400,"y":300,"wires":[["d0f624312d1deb6a"]]},{"id":"20c6bbb7cc6acf5a","type":"html","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Data","property":"payload","outproperty":"data","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(2)","ret":"text","as":"single","x":990,"y":300,"wires":[["3f4f397e054bc67f"]]},{"id":"3f4f397e054bc67f","type":"html","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Local","property":"payload","outproperty":"local","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(3)","ret":"text","as":"single","x":1110,"y":300,"wires":[["6cb18a4a9ba97d68"]]},{"id":"6cb18a4a9ba97d68","type":"html","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Destino","property":"payload","outproperty":"destino","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(4)","ret":"text","as":"single","x":1240,"y":300,"wires":[["a91d0373465af238"]]},{"id":"af399a8321148c54","type":"link out","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"link out 75","mode":"link","links":["392e29fa7c841991","4889d89cd6c1f2c0","22f708e086056d47"],"x":1675,"y":300,"wires":[]},{"id":"e6bb92289a1c13cd","type":"delay","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"","pauseType":"delay","timeout":"6","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":255,"y":220,"wires":[["36b953d0372f9d63"]],"l":false},{"id":"e99c5fee8ac455d7","type":"function","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"function","func":"// Inicializar o array de opções\nvar options = [];\n\n// Loop através do array msg.sensores\nfor (var i = 0; i < msg.sensores.length; i++) {\n    // Adicionar o valor atual de msg.sensores[i].entity_id ao array de opções\n    options.push(msg.sensores[i].attributes.friendly_name);\n}\n\n// Definir as opções no objeto msg.payload.data\nmsg.payload = {\n    data: {\n        \"options\": options\n    }\n}\n\n// Enviar a mensagem modificada para o próximo nó\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":240,"wires":[["8c0c17b35b4481a8"]]},{"id":"204c53c40a74134d","type":"link in","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"link in 55","links":["683688a0b84fab71","9b41e0d90bc9dad1"],"x":325,"y":200,"wires":[["36b953d0372f9d63"]]},{"id":"c699c6ab9d03f1a0","type":"function","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"Headers","func":"let partes = msg.rastreio.split('-');\nlet resultado = partes.pop().trim().toUpperCase();\nmsg.rastreio = resultado;\n\n\nvar index = flow.get(\"rastreio\").indexOf(msg.rastreio);\nvar rastreio = flow.get(\"rastreio\");\nvar nome_objeto = flow.get(\"nome_objeto\");\nvar notificacao = flow.get(\"notificacao\")\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\", rastreio)\n    nome_objeto.splice(index, 1);\n    flow.set(\"nome_objeto\",nome_objeto)\n    notificacao.splice(index, 1);\n    flow.set(\"notificacao\", notificacao)\n}\n\nmsg.entity_id = 'sensor.correios_' + msg.rastreio\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":460,"wires":[["1c82f1837df9c70f"]]},{"id":"f1202f3ad3e6f974","type":"switch","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"= Objeto entregue ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto entregue ao destinatário']","vt":"str"},{"t":"eq","v":"['Objeto entregue ao remetente']","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":440,"y":600,"wires":[["0d31692371bacbba"],["0d31692371bacbba"]]},{"id":"a63aa08bfabd6ebb","type":"function","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"Headers","func":"var index = flow.get(\"rastreio\").indexOf(msg.data.new_state.attributes.rastreio);\nvar rastreio = flow.get(\"rastreio\");\nvar nome_objeto = flow.get(\"nome_objeto\");\nvar notificacao = flow.get(\"notificacao\");\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\", rastreio)\n    nome_objeto.splice(index, 1);\n    flow.set(\"nome_objeto\", nome_objeto)\n    notificacao.splice(index, 1);\n    flow.set(\"notificacao\", notificacao)\n}\n\nmsg.entity_id = 'sensor.correios_' + msg.data.new_state.attributes.rastreio\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":600,"wires":[["8887385efc0f388c"]]},{"id":"0d31692371bacbba","type":"delay","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":625,"y":600,"wires":[["a63aa08bfabd6ebb"]],"l":false},{"id":"9b41e0d90bc9dad1","type":"link out","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"link out 74","mode":"link","links":["204c53c40a74134d","22f708e086056d47"],"x":995,"y":600,"wires":[]},{"id":"683688a0b84fab71","type":"link out","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"link out 73","mode":"link","links":["204c53c40a74134d","22f708e086056d47"],"x":705,"y":500,"wires":[]},{"id":"9831689d8269487e","type":"function","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"function","func":"// Inicializar o array de opções\nvar options = [];\n\nif (msg.sensores[0] != ''){\n    // Loop através do array msg.sensores\n    for (var i = 0; i < msg.sensores.length; i++) {\n        // Adicionar o valor atual de msg.sensores[i].entity_id ao array de opções\n        options.push(msg.sensores[i].attributes.friendly_name);\n    }\n}\nelse {\n    options = msg.sensores[0];\n}\n\n// Definir as opções no objeto msg.payload.data\nmsg.payload = {\n    data: {\n        \"options\": options\n    }\n}\n\n// Enviar a mensagem modificada para o próximo nó\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1100,"y":460,"wires":[["640428762a874c2c"]]},{"id":"b012263b46c66bc5","type":"function","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"function 33","func":"if (msg.sensores.length === 0) {\n    msg.sensores[0] = \"\";\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":975,"y":460,"wires":[["9831689d8269487e"],["9831689d8269487e"]],"l":false},{"id":"c2e02b402e6907b4","type":"delay","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":705,"y":460,"wires":[["a6ad21e70a8699ea"]],"l":false},{"id":"5d53ade34e356c49","type":"inject","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"Revemor Rastreio","props":[{"p":"rastreio","v":"abre e fecha tuya","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":1000,"wires":[["923732875bee1443"]]},{"id":"923732875bee1443","type":"function","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"Remover do array","func":"var index = flow.get(\"rastreio\").indexOf(msg.rastreio);\nvar rastreio = flow.get(\"rastreio\")\n\n\nif (index !== -1) {\n    rastreio.splice(index, 1);\n    flow.set(\"rastreio\",rastreio)\n}\nreturn msg;\n\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":1000,"wires":[["19fa24f29c11e09c"]]},{"id":"19fa24f29c11e09c","type":"debug","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"remover array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":1000,"wires":[]},{"id":"82e17a10726733c7","type":"inject","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"Listar","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":1060,"wires":[["b452bcacb1145490"]]},{"id":"b452bcacb1145490","type":"template","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"Listar array","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{flow.rastreio}}\n{{flow.nome_objeto}}\n{{flow.notificacao}}","output":"str","x":290,"y":1060,"wires":[["872a676c73225632"]]},{"id":"872a676c73225632","type":"debug","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"listar array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":1060,"wires":[]},{"id":"27ed12693b9ac70e","type":"inject","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"Zerar Array","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":1120,"wires":[["af2c533201632e20"]]},{"id":"af2c533201632e20","type":"function","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"Limpar  array","func":"var clear_rastreio = flow.get(\"rastreio\");\nclear_rastreio = [] || [];\nflow.set(\"rastreio\", clear_rastreio);\n\nvar clear_nome_objeto = flow.get(\"nome_objeto\");\nclear_nome_objeto = [] || [];\nflow.set(\"nome_objeto\", clear_nome_objeto);\n\nvar clear_notificacao = flow.get(\"notificacao\");\nclear_notificacao = [] || [];\nflow.set(\"notificacao\", clear_notificacao);\n\nreturn msg;\n\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":1120,"wires":[["1311debf75a84f8a"]]},{"id":"1311debf75a84f8a","type":"debug","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"array limpo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":1120,"wires":[]},{"id":"8c9e699289403d5f","type":"function","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"Headers","func":"msg.headers = {\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    \"Authorization\": \"Bearer \"+global.get(\"token\"),\n}\n\nmsg.url = 'http://'+global.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\n\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":1180,"wires":[["ab3afc6b0b8b4760"]]},{"id":"ab3afc6b0b8b4760","type":"http request","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":490,"y":1180,"wires":[["5df2adf184af6d11"]]},{"id":"5df2adf184af6d11","type":"debug","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"remover sensor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":1180,"wires":[]},{"id":"60bc392f32456913","type":"inject","z":"a7d248bcbb7263b0","g":"5ac2e68ec7f25715","name":"Deletar sensor","props":[{"p":"rastreio","v":"NL658154191BR","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":1180,"wires":[["8c9e699289403d5f"]]},{"id":"aa6f84b72738b7cf","type":"function","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"Headers","func":"if (typeof flow.get(\"rastreio\") !== 'undefined') {\n  for (var i = 0; i < flow.get(\"rastreio\").length; i++) {\n    msg.url = \"https://www.linkcorreios.com.br/?id=\" + flow.get(\"rastreio\")[i];\n    msg.headers = {\n\"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/50.0.2661.102 Safari/537.36\",\n    }\n\n    msg.rastreio = flow.get(\"rastreio\")[i];\n    msg.nome_objeto = flow.get(\"nome_objeto\")[i];\n    msg.notificacao = flow.get(\"notificacao\")[i];\n\n    flow.get(\"rastreio\")[i] + 1;\n\n    node.send([msg]);\n  }\n\n}","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":900,"wires":[["b0482748d6c5ee23"]]},{"id":"b0482748d6c5ee23","type":"http request","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":330,"y":900,"wires":[["cc0d230dbb9364b6"]]},{"id":"69a63d712ce9b050","type":"html","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"Status","property":"payload","outproperty":"status","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(1) > b","ret":"text","as":"single","x":630,"y":900,"wires":[["aa6d024a07798e9b"]]},{"id":"aa6d024a07798e9b","type":"html","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"Data","property":"payload","outproperty":"data","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(2)","ret":"text","as":"single","x":750,"y":900,"wires":[["c8414966e37712c9"]]},{"id":"c8414966e37712c9","type":"html","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"Local","property":"payload","outproperty":"local","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(3)","ret":"text","as":"single","x":870,"y":900,"wires":[["a82fe00781f82f80"]]},{"id":"a82fe00781f82f80","type":"html","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"Destino","property":"payload","outproperty":"destino","tag":"#page > main > div.container.margin_30_5 > div > div > div.singlepost > ul:nth-child(3) > li:nth-child(4)","ret":"text","as":"single","x":1000,"y":900,"wires":[["cc98a1d9ecfe6615"]]},{"id":"1a187d54eedb6bdf","type":"inject","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"Atualiza de 1 em 1 min ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"120","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":105,"y":900,"wires":[["aa6f84b72738b7cf"]],"l":false},{"id":"e6e3afcffc7cdd53","type":"function","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"dados sensor","func":"msg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase();\nmsg.state = msg.status,\nmsg.attributes = {\n    rastreio: msg.rastreio,\n    status: msg.status,\n    data: msg.data,\n    notificacao: msg.notificacao,\n    local: msg.local,\n    destino: msg.destino,\n    friendly_name: msg.nome_objeto.toUpperCase() + ' - ' + msg.rastreio.toUpperCase(),\n}\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1280,"y":900,"wires":[["bc3907bc8ace72c3"]]},{"id":"cc0d230dbb9364b6","type":"delay","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"","pauseType":"rate","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"3","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":480,"y":900,"wires":[["69a63d712ce9b050"]]},{"id":"cc98a1d9ecfe6615","type":"function","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"!= Null","func":"if (msg.data.length === 0) {\n    msg.data[0] = null;\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1130,"y":900,"wires":[[],["e6e3afcffc7cdd53"]]},{"id":"5b9fee0119038753","type":"switch","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"Notificacao = Sim / Saiu para entrega","property":"data.new_state.attributes.notificacao","propertyType":"msg","rules":[{"t":"eq","v":"Sim","vt":"str"},{"t":"eq","v":"Saiu para entrega","vt":"str"},{"t":"eq","v":"Objeto entregue","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":570,"y":760,"wires":[["92d0758cf213c439"],["0a298f8855b24575"],["b40f832ae82b77e4"]]},{"id":"2199f044b2974ac9","type":"link out","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"link out 19","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":975,"y":720,"wires":[]},{"id":"92d0758cf213c439","type":"template","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"Todas notificações","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":850,"y":720,"wires":[["2199f044b2974ac9"]]},{"id":"0a298f8855b24575","type":"switch","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"= Objeto saiu para entrega ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto saiu para entrega ao destinatário']","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":920,"y":760,"wires":[["9407ea03efd567f3"]]},{"id":"9407ea03efd567f3","type":"template","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"Saiu para entrega","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":1210,"y":760,"wires":[["bf478b4962d0081d"]]},{"id":"f0a4e92c5c6d6fed","type":"function","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"!= Null","func":"if (msg.data.new_state.attributes.data.length === 0) {\n    msg.data.new_state.attributes.data[0] = null;\n    return [msg, null];\n}\nelse {\n    return [null, msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":760,"wires":[[],["5b9fee0119038753"]]},{"id":"b40f832ae82b77e4","type":"switch","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"= Objeto entregue ao destinatário","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"['Objeto entregue ao destinatário']","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":900,"y":800,"wires":[["bea85712d4069697"]]},{"id":"bea85712d4069697","type":"template","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"Objeto entregue","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"📦 {{{data.new_state.attributes.friendly_name}}} \n__\n\n{{{data.new_state.attributes.status}}}\n\n{{{data.new_state.attributes.data}}}\n\n{{{data.new_state.attributes.destino}}}\n\n{{{data.new_state.attributes.local}}}\n\n\n","output":"str","x":1200,"y":800,"wires":[["7918caa1b3e326e0"]]},{"id":"bf478b4962d0081d","type":"link out","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"link out 76","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":760,"wires":[]},{"id":"7918caa1b3e326e0","type":"link out","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"link out 77","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":800,"wires":[]},{"id":"d0f624312d1deb6a","type":"subflow:67ec3e5ceb42cb6d","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"","env":[{"name":"entity_id","value":"","type":"str"},{"name":"attributes","value":"","type":"str"}],"x":1570,"y":300,"wires":[["af399a8321148c54"]]},{"id":"4186a8b562913425","type":"subflow:10cee52504db3830","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"","x":1390,"y":460,"wires":[[]]},{"id":"2b9ce4e2ea87c3b5","type":"subflow:10cee52504db3830","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"","x":950,"y":240,"wires":[[]]},{"id":"bc3907bc8ace72c3","type":"subflow:67ec3e5ceb42cb6d","z":"a7d248bcbb7263b0","g":"9eaaa7e98dce281c","name":"","env":[{"name":"entity_id","value":"","type":"str"},{"name":"attributes","value":"","type":"str"}],"x":1450,"y":900,"wires":[[]]},{"id":"8887385efc0f388c","type":"subflow:f4d240c42f148509","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":880,"y":600,"wires":[[],["9b41e0d90bc9dad1","022e158ba5d9efe2"]]},{"id":"1c82f1837df9c70f","type":"subflow:f4d240c42f148509","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":580,"y":460,"wires":[[],["683688a0b84fab71","c2e02b402e6907b4"]]},{"id":"d3bd4ca607da4882","type":"link in","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"link in 58","links":["022e158ba5d9efe2"],"x":755,"y":460,"wires":[["a6ad21e70a8699ea"]]},{"id":"022e158ba5d9efe2","type":"link out","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"link out 84","mode":"link","links":["d3bd4ca607da4882"],"x":995,"y":560,"wires":[]},{"id":"237f0f1160fd90d2","type":"api-call-service","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Limpar texto","server":"33803899.487d48","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.correios_nome_objeto","input_text.correios_rastreio"],"data":"{\"value\":\"\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":130,"y":360,"wires":[["e54efa88d59159ed"]]},{"id":"e54efa88d59159ed","type":"api-call-service","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Limpar select","server":"33803899.487d48","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":["input_select.correios_notificacao"],"data":"{\"option\":\"Sim\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":370,"y":360,"wires":[[]]},{"id":"8c0c17b35b4481a8","type":"api-call-service","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Criar lista","server":"33803899.487d48","version":5,"debugenabled":false,"domain":"input_select","service":"set_options","areaId":[],"deviceId":[],"entityId":["input_select.rastreio"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"data"},{"property":"entity_id","propertyType":"msg","value":"input_select.rastreio","valueType":"str"}],"queue":"none","x":780,"y":240,"wires":[["2b9ce4e2ea87c3b5"]]},{"id":"99acc3e78ecc99f9","type":"api-call-service","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"Limpar texto","server":"33803899.487d48","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.correios_nome_objeto","input_text.correios_rastreio"],"data":"{\"value\":\"\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":130,"y":520,"wires":[[]]},{"id":"9faee5f619da1541","type":"api-current-state","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Rastreio","server":"33803899.487d48","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_text.correios_rastreio","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"rastreio","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":120,"y":300,"wires":[["237f0f1160fd90d2","8ac55d001ed2d6df"]]},{"id":"b32d725b9c97f409","type":"api-current-state","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Nome objeto","server":"33803899.487d48","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_text.correios_nome_objeto","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"nome_objeto","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":470,"y":300,"wires":[["86f88adbb208d8bb"]]},{"id":"8ac55d001ed2d6df","type":"api-current-state","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Notificação","server":"33803899.487d48","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.correios_notificacao","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"notificacao","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":310,"y":300,"wires":[["b32d725b9c97f409"]]},{"id":"9c321bb56548160e","type":"api-current-state","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"Rastreio","server":"33803899.487d48","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.rastreio","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"rastreio","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":280,"y":460,"wires":[["c699c6ab9d03f1a0"]]},{"id":"395b607cbaf66fb7","type":"server-state-changed","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"SALVAR","server":"33803899.487d48","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.correios_salvar","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":120,"y":240,"wires":[["9faee5f619da1541","e6bb92289a1c13cd"]]},{"id":"bca510ff1d3ca76c","type":"server-state-changed","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"EXCLUIR","server":"33803899.487d48","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_button.correios_excluir","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":460,"wires":[["99acc3e78ecc99f9","9c321bb56548160e"]]},{"id":"6adf7a790e90a254","type":"server-state-changed","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"Excluir automaticamente","server":"33803899.487d48","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.correios_","entityIdType":"regex","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":600,"wires":[["f1202f3ad3e6f974"]]},{"id":"d5dbb2d4194044b4","type":"server-state-changed","z":"a7d248bcbb7263b0","g":"f82e7fcac77fcdce","name":"Aviso mudança de status","server":"33803899.487d48","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.correios_","entityIdType":"regex","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":760,"wires":[["f0a4e92c5c6d6fed"]]},{"id":"4e7b15df55b9b416","type":"subflow:67ec3e5ceb42cb6d","z":"a7d248bcbb7263b0","g":"c91e7a79d6449e85","name":"","env":[{"name":"entity_id","value":"","type":"str"}],"x":350,"y":120,"wires":[[]]},{"id":"8d25ef90a8e41ac8","type":"inject","z":"a7d248bcbb7263b0","g":"312e60c216619f75","name":"Digitar Chave token e IP","props":[{"p":"payload"}],"repeat":"1800","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":615,"y":120,"wires":[["dc076f7bc4f06074"]],"l":false},{"id":"dc076f7bc4f06074","type":"change","z":"a7d248bcbb7263b0","g":"312e60c216619f75","name":"Digitar Chave token e IP","rules":[{"t":"set","p":"token","pt":"global","to":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYTAxMzIyMGIxNmY0YjM1YmZhNTA5ZjM5Y2Q1MGRlNyIsImlhdCI6MTcwNzU4ODExOCwiZXhwIjoyMDIyOTQ4MTE4fQ.4bRp03JtCk2WKJ5keOJ6ipYq4l-0NucXfislsQww1F8","tot":"str"},{"t":"set","p":"ip","pt":"global","to":"192.168.0.6:3815","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":120,"wires":[[]]},{"id":"f2d04ad7b278f30d","type":"comment","z":"a7d248bcbb7263b0","g":"312e60c216619f75","name":"IP + Token","info":"","x":630,"y":80,"wires":[]},{"id":"dca51185b66b18e4","type":"fs-ops-dir","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"","path":"/config/node-red/correios/sensores/","pathType":"str","filter":"*","filterType":"str","dir":"entity_id","dirType":"msg","x":400,"y":1340,"wires":[["2f4096629b19069f"]]},{"id":"64c02069b07364c7","type":"subflow:9e57d26033fa55bc","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"","x":970,"y":1340,"wires":[["fc37230f17867168"]]},{"id":"2f4096629b19069f","type":"function","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"function ","func":"msg.payload = []\nfor (var i = 0; i < msg.entity_id.length; i++) {\n    msg.payload[i] = msg.entity_id[i] \n    msg.entity_id[i]+1;\n}\n\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":1340,"wires":[["68b449bffaa8eed7"]]},{"id":"68b449bffaa8eed7","type":"split","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":670,"y":1340,"wires":[["4c9433bc8acfd5b0"]]},{"id":"4c9433bc8acfd5b0","type":"change","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"set entity_id","rules":[{"t":"set","p":"entity_id","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":1340,"wires":[["64c02069b07364c7"]]},{"id":"5f8738b28924c566","type":"fs-ops-dir","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"","path":"/config/node-red/correios/input_select/","pathType":"str","filter":"*","filterType":"str","dir":"entity_id","dirType":"msg","x":400,"y":1440,"wires":[["8a1e06d6f7d05181"]]},{"id":"3dba425df7b0fd88","type":"split","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":670,"y":1440,"wires":[["87f778fce5a87355"]]},{"id":"8a1e06d6f7d05181","type":"function","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"function ","func":"msg.payload = []\nfor (var i = 0; i < msg.entity_id.length; i++) {\n    msg.payload[i] = msg.entity_id[i]\n    msg.entity_id[i] + 1;\n}\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":1440,"wires":[["3dba425df7b0fd88"]]},{"id":"6d22970fdb3f9fce","type":"subflow:558bbafe7c61aa44","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"","x":960,"y":1440,"wires":[["fac8b1fc8dd57be6"]]},{"id":"87f778fce5a87355","type":"change","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"set entity_id","rules":[{"t":"set","p":"entity_id","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":1440,"wires":[["6d22970fdb3f9fce"]]},{"id":"fc37230f17867168","type":"ha-api","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"","server":"33803899.487d48","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"/api/states/{{entity_id}}","data":"","dataType":"json","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":1110,"y":1340,"wires":[[]]},{"id":"fac8b1fc8dd57be6","type":"api-call-service","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"input_select","server":"33803899.487d48","version":5,"debugenabled":false,"domain":"","service":"","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1110,"y":1440,"wires":[[]]},{"id":"46bdc4eeccd6975c","type":"server-events","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"HA Restart","server":"33803899.487d48","version":3,"exposeAsEntityConfig":"","eventType":"home_assistant_client","eventData":"","waitForRunning":true,"outputProperties":[{"property":"entity_id","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"},{"property":"event_type","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":120,"y":1380,"wires":[["db9ae1c46283c633"]]},{"id":"db9ae1c46283c633","type":"switch","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ready","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":1380,"wires":[["dca51185b66b18e4","5f8738b28924c566","faf985cc802317f3"]]},{"id":"320e751a9ab3d0ed","type":"inject","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"Start manual","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":1440,"wires":[["dca51185b66b18e4","5f8738b28924c566","faf985cc802317f3"]]},{"id":"89056bb779ec081f","type":"comment","z":"a7d248bcbb7263b0","g":"aaef3e5f23494904","name":"Após reiniciar ler os sensores gravados","info":"","x":210,"y":1300,"wires":[]},{"id":"faf985cc802317f3","type":"api-call-service","z":"a7d248bcbb7263b0","d":true,"g":"aaef3e5f23494904","name":"Pergunta default reset looping","server":"33803899.487d48","version":5,"debugenabled":false,"domain":"script","service":"activate_alexa_actionable_notification","areaId":[],"deviceId":[],"entityId":[],"data":"{\"text\":\"O que deseja que eu faça?\",\"event_id\":\"id_resposta\",\"alexa_device\":\"media_player.default\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":355,"y":1380,"wires":[[]],"l":false},{"id":"36b953d0372f9d63","type":"ha-get-entities","z":"a7d248bcbb7263b0","g":"17c39274dfde2601","name":"Pegar sensores","server":"33803899.487d48","version":1,"rules":[{"property":"entity_id","logic":"starts_with","value":"sensor.correios_","valueType":"str"}],"outputType":"array","outputEmptyResults":false,"outputLocationType":"msg","outputLocation":"sensores","outputResultsCount":1,"x":480,"y":240,"wires":[["e99c5fee8ac455d7"]]},{"id":"a6ad21e70a8699ea","type":"ha-get-entities","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"Pegar sensores","server":"33803899.487d48","version":1,"rules":[{"property":"entity_id","logic":"starts_with","value":"sensor.correios_","valueType":"str"}],"outputType":"array","outputEmptyResults":false,"outputLocationType":"msg","outputLocation":"sensores","outputResultsCount":1,"x":860,"y":460,"wires":[["b012263b46c66bc5"]]},{"id":"640428762a874c2c","type":"api-call-service","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"Criar lista","server":"33803899.487d48","version":5,"debugenabled":false,"domain":"input_select","service":"set_options","areaId":[],"deviceId":[],"entityId":["input_select.rastreio"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"data"},{"property":"entity_id","propertyType":"msg","value":"input_select.rastreio","valueType":"str"}],"queue":"none","x":1240,"y":460,"wires":[["4186a8b562913425"]]},{"id":"90a51380129caf2f","type":"api-call-service","z":"a7d248bcbb7263b0","g":"c025a4fda154de8e","name":"Criar lista","server":"33803899.487d48","version":5,"debugenabled":false,"domain":"input_select","service":"set_options","areaId":[],"deviceId":[],"entityId":["input_select.rastreio"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"data"},{"property":"entity_id","propertyType":"msg","value":"input_select.rastreio","valueType":"str"}],"queue":"none","x":1260,"y":580,"wires":[[]]}]

Pode ser então a questão do websocket mesmo. O fato de não excluir o sensor da lista, ainda deve ser pq não esta salvando a lista em arquivo no HA, ou salva a lista no arquivo mas não apaga a lista após excluir ele. Quem faz todo esse processo é os subflows, criar e apagar… Estou só com meu nodered de produção então não tenho como testar em um zerado para saber se é algum bug na importação, da mais uma conferida nos subflow eu utilizei o caminho /homeassistant/.dados/sensores/ se você alterou precisa alterar em todo o lugar que aparece esse caminho

Eu alterei todos os caminhos, procurei a referencia deles direto no json.
Mas esta funcionando, inclusive apaga o rastreio, apenas o ultimo rastreio (se apagar todos) fica na lista para excluir, mesmo que não seja o comportamento esperado, não é um problema.

Sobre não rodar em instalação nova eu descobri que é problema de BIOS. (bicho idiota operando sistema)

1 Like

Ainda estou confuso, não entendi foi nada.

O que vc não entendeu?

Pra resumir a instalação:
1 - Atualize o node-red (addon ou docker)
2 - Nas paletas do node-red atualize o node-red-contrib-home-assistant-websocket e instale o node-red-contrib-fs-ops
3 - Instalar via HACS:
3.1 - integração: browser_mod
3.2 - Frontend: auto-entities, Mushroom, Button Card e card-mod
4 - Crie os ajudantes abaixo:

Correios Excluir
input_button.correios_excluir
Button

Correios Nome Objeto
input_text.correios_nome_objeto
Text

Correios Notificação
input_select.correios_notificacao
Dropdown
Com opções Sim e Não

Correios Rastreio
input_text.correios_rastreio
Text

Correios Salvar
input_button.correios_salvar
Button

Rastreio
input_select.rastreio
Dropdown
Adicionar uma opção apenas com 1 espaço " "

5 - Importe os 2 fluxos:
5.1 - CORREIOS - Sistema de rastreio no Home Assistant + adicionar, excluir e notificações telegram (nodered+card homeassistant) - #88 por kelvinrafaeli

5.2 - CORREIOS - Sistema de rastreio no Home Assistant + adicionar, excluir e notificações telegram (nodered+card homeassistant) - #80 por kelvinrafaeli

6 - Adicione o card:

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        primary: Novo
        badge_icon: mdi:plus
        secondary: Rastreamento
        icon: mdi:package-variant-closed-plus
        fill_container: true
        layout: horizontal
        icon_color: green
        tap_action:
          action: fire-dom-event
          browser_mod:
            service: browser_mod.popup
            data:
              title: Adicionar Rastreio
              right_button: Salvar
              right_button_action:
                service: input_button.press
                data:
                  entity_id: input_button.correios_salvar
              content:
                type: entities
                entities:
                  - entity: input_select.correios_notificacao
                    name: Deseja receber notificações?
                    icon: mdi:bell-ring
                  - entity: input_text.correios_rastreio
                    name: Qual o Código de Rastreamento?
                    icon: mdi:package-variant-closed
                  - entity: input_text.correios_nome_objeto
                    name: Qual nome do Objeto?
                    icon: mdi:form-textbox
        card_mod:
          style: |
            ha-card { 
              --ha-card-background: white;
            }
      - type: custom:mushroom-template-card
        primary: Excluir
        secondary: Rastreamento
        icon: mdi:package-variant-closed-remove
        icon_color: red
        badge_icon: mdi:delete
        layout: horizontal
        multiline_secondary: false
        tap_action:
          action: fire-dom-event
          browser_mod:
            service: browser_mod.popup
            data:
              title: Excluir Rastreio
              right_button: Excluir
              right_button_action:
                service: input_button.press
                data:
                  entity_id: input_button.correios_excluir
              content:
                type: entities
                entities:
                  - entity: input_select.rastreio
                    name: Qual o Código de Rastreamento?
                    icon: mdi:package-variant-closed
                card_mod:
                  style: |
                    ha-card { 
                      height: 200px !important;
                    } 
        card_mod:
          style: |
            ha-card { 
              --ha-card-background: white;
            }  
  - type: custom:button-card
    layout: icon_name
    name: Objetos Cadastrados
    icon: mdi:package-variant-closed
    styles:
      grid:
        - grid-template-areas: '"n i"'
        - grid-template-columns: 1fr 20%
      icon:
        - align-self: end
        - color: var(--text-primary-color)
        - height: 35px
      card:
        - padding: 4px
        - height: 40px
        - background: var(--primary-color)
      name:
        - color: var(--text-primary-color)
        - justify-self: start
        - padding-left: 10%
        - font-weight: 400
        - font-size: 18px
  - type: custom:auto-entities
    card:
      type: grid
      columns: 1
      square: false
    card_param: cards
    show_empty: false
    filter:
      include:
        - entity_id: sensor.correios_*
          options:
            type: custom:mushroom-template-card
            card_mod:
              style: |
                ha-card { 
                  --ha-card-background: white ;
                }
            entity: this.entity_id
            primary: '{{ state_attr(''this.entity_id'', ''friendly_name'') }}'
            secondary: >-
              {% if states['this.entity_id'].state == '[]' %} Objeto aguardando
              postagem nos Correios.   {% elif states['this.entity_id'].state ==
              "[{}]" %}Sincronizando com sistema dos correios  {% else
              %}              {{ state_attr('this.entity_id', 'status')|join()
              }}

              {{ state_attr('this.entity_id', 'data')|join() }}

              {{ state_attr('this.entity_id', 'local')|join() }}

              {{ state_attr('this.entity_id', 'destino')|join() }}

              {% endif %}
            icon: >-
              {% if states['this.entity_id'].state == "['Objeto entregue ao
              destinatário']" %} mdi:package-variant-closed-check   {% elif
              states['this.entity_id'].state == "['Objeto entregue ao
              remetente']"%} mdi:package-variant-closed-check  {% elif
              states['this.entity_id'].state == "['Objeto postado']"%}
              mdi:store-plus   {% elif states['this.entity_id'].state == "[]"
              %}mdi:package-variant-closed-remove   {% elif
              states['this.entity_id'].state == "[{}]" %}mdi:refresh   {% elif
              states['this.entity_id'].state == "['Objeto saiu para entrega ao
              destinatário']" %}mdi:human-dolly  {% elif
              states['this.entity_id'].state == "['Objeto está em rota de
              entrega']" %}mdi:human-dolly    {% elif
              states['this.entity_id'].state == "['Objeto recebido pelos
              Correios do Brasil']" %}mdi:flag-variant   {% elif
              states['this.entity_id'].state == "['Objeto em trânsito - por
              favor aguarde']" %}mdi:truck  {% endif %}
            icon_color: >-
              {% if states['this.entity_id'].state == "['Objeto entregue ao
              destinatário']" %}green    {% elif states['this.entity_id'].state
              == "[]" %}red    {% elif states['this.entity_id'].state == "[{}]"
              %}red  {% elif states['this.entity_id'].state == "['Objeto saiu
              para entrega ao destinatário']" %}orange {% elif
              states['this.entity_id'].state == "['Objeto está em rota de
              entrega']" %}orange    {% elif states['this.entity_id'].state ==
              "['Objeto entregue ao remetente']" %}black    {% elif
              states['this.entity_id'].state != "['Objeto entregue ao
              destinatário']" %}yellow   {% endif %}
            multiline_secondary: true
            badge_icon: >-
              {% if states['this.entity_id'].state == "['Objeto entregue ao
              destinatário']" %}mdi:check-bold   {% elif
              states['this.entity_id'].state == "['Objeto postado']"
              %}mdi:share  {% elif states['this.entity_id'].state == "['Objeto
              entregue ao remetente']" %}mdi:share  {% elif
              states['this.entity_id'].state == "[]" %}mdi:alert-box   {% elif
              states['this.entity_id'].state == "['Objeto saiu para entrega ao
              destinatário']" %}mdi:share {% elif states['this.entity_id'].state
              == "['Objeto está em rota de entrega']" %}mdi:share     {% elif
              states['this.entity_id'].state == "['Objeto recebido pelos
              Correios do Brasil']" %}mdi:map-marker   {% elif
              states['this.entity_id'].state == "['Objeto em trânsito - por
              favor aguarde']" %}mdi:share  {% endif %}
            badge_color: >-
              {% if states['this.entity_id'].state == "['Objeto entregue ao
              destinatário']" %}green  {% elif states['this.entity_id'].state ==
              "['Objeto entregue ao remetente']" %}green   {% elif
              states['this.entity_id'].state != "['Objeto entregue ao
              destinatário']" %}grey  {% endif %}
            tap_action:
              action: more-info
            order_by:
              last_changed: asc
    sort:
      method: last_changed
      count: 10
      reverse: true