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

Esse aqui é o codigo do cartão que utilizo
*Não se esqueça de alterar os inputs e sensores… eu precisei alterar os mesmos para outros nomes para funcionar melhor no meu HA.

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: Quem vai receber as 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
      - 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_text.correios_rastreio
                    name: Qual o Código de Rastreamento?
                    icon: mdi:package-variant-closed
  - type: custom:gap-card
    height: 15
  - 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.correiosobjeto_*
          options:
            type: custom:mushroom-template-card
            card_mod:
              style: |
                ha-card { 
                  --ha-card-background: none; 
                }
            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 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 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 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 == "[]" %}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 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 destinatário']" %}grey{% endif %}
            tap_action:
              action: more-info
    sort:
      method: last_changed
      count: 10
      reverse: true

Quanto ao fluxo está igual siim, foi alguma coisa que alterei que fod*** com as notificações :man_facepalming:

Eu implementei um atributo “notificação” quanto cadastrado um novo objeto. Esse atributo é preenchido com uma campo de select e possui três opções:
1-) Sim (para notificar todas atualização)
2-) Não (para não notificar)
3-) Saiu para entrega (para notificar apenas quando sair para entrega)

Problema é que não sei como capturar esse atributo e repassar ele quando tem atualização no objeto.

Com esse atributo funcional é só filtrar com uma function ou switch antes de enviar a notificação.

1 curtida

@guilherme-cespedes entendi, acho que é bem tranquilo de fazer. Vou utilizar seu card e tendo montar essa opção, porém acho que mais para semana que vem como estou viajando a trabalho, não vou ter tempo.

Além de colocar um atributo em cada sensor dos objetos, utilizei o input select para direcionar as notificações… Então antes de enviar ele faz a leitura do status do input.

Bom que se der algum erro também e começar a gerar notificações basta selecionar no input “Nenhuma” que vai parar as notificações até que seja possível verificar o que está acontecendo.

@guilherme-cespedes fiz as alterações aqui, deu certinho com o debug, vou verificar com o rastreio real mas acho que funciona, teste ai e me avisa qualquer coisa:

[{"id":"9c2c50fdc6329aff","type":"group","z":"e3f8c2a2b98f267c","name":"Incluir rastreio","style":{"label":true},"nodes":["9549acd579d12e6d","5731e180e117e905","1574ea28746987cc","3571a466290dd999","ffe2a88abdc1039f","9cfcdeb8ece55726","aa96ba9a06a7ccb7","d1e012e2f876c02a","cb123282ef6ad690","5d32837d47a24b86","165707cbed3c57ba","7d7f8d54fc47be85","2ecdd1cb1b70d706","e909433d2148b52b"],"x":14,"y":79,"w":1572,"h":202},{"id":"9549acd579d12e6d","type":"function","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":180,"wires":[["5731e180e117e905"]]},{"id":"5731e180e117e905","type":"http request","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":730,"y":180,"wires":[["1574ea28746987cc"]]},{"id":"1574ea28746987cc","type":"html","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":850,"y":180,"wires":[["cb123282ef6ad690"]]},{"id":"3571a466290dd999","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":100,"y":180,"wires":[["9cfcdeb8ece55726","2ecdd1cb1b70d706"]]},{"id":"ffe2a88abdc1039f","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","name":"SALVAR","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.correios_salvar","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":100,"y":120,"wires":[["3571a466290dd999"]]},{"id":"9cfcdeb8ece55726","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":110,"y":240,"wires":[["e909433d2148b52b"]]},{"id":"aa96ba9a06a7ccb7","type":"function","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","name":"Criar 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()\n\nmsg.payload = {\n    data: {\n        state: msg.status,\n        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        }\n    }\n};\n\nreturn msg\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1370,"y":180,"wires":[["d1e012e2f876c02a"]]},{"id":"d1e012e2f876c02a","type":"ha-api","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":1510,"y":180,"wires":[[]]},{"id":"cb123282ef6ad690","type":"html","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":970,"y":180,"wires":[["5d32837d47a24b86"]]},{"id":"5d32837d47a24b86","type":"html","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":1090,"y":180,"wires":[["7d7f8d54fc47be85"]]},{"id":"165707cbed3c57ba","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":450,"y":180,"wires":[["9549acd579d12e6d"]]},{"id":"7d7f8d54fc47be85","type":"html","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":1220,"y":180,"wires":[["aa96ba9a06a7ccb7"]]},{"id":"2ecdd1cb1b70d706","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":290,"y":180,"wires":[["165707cbed3c57ba"]]},{"id":"e909433d2148b52b","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":290,"y":240,"wires":[[]]},{"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":"59c36af566d4029d","type":"group","z":"e3f8c2a2b98f267c","name":"Excluir rastreio","style":{"label":true},"nodes":["db5c987b7e696064","4febf3bd26fad49c","4b0ab60bec7f04fc","5d7bac7076c26c14","e5c9df6836b50f1d","8f7030e0d6bbba28","de8e4bb006d84feb","7cc65c764aa14994","efe0bc54cb85f05f","0fe4128c59a913e6"],"x":14,"y":319,"w":932,"h":222},{"id":"db5c987b7e696064","type":"http request","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":550,"y":360,"wires":[[]]},{"id":"4febf3bd26fad49c","type":"function","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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 \"+flow.get(\"token\"),\n}\n\nmsg.url = 'http://'+flow.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\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\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":360,"wires":[["db5c987b7e696064"]]},{"id":"4b0ab60bec7f04fc","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","name":"EXCLUIR","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.correios_excluir","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":100,"y":360,"wires":[["e5c9df6836b50f1d","5d7bac7076c26c14"]]},{"id":"5d7bac7076c26c14","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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":260,"y":360,"wires":[["4febf3bd26fad49c"]]},{"id":"e5c9df6836b50f1d","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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":110,"y":420,"wires":[[]]},{"id":"8f7030e0d6bbba28","type":"switch","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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":420,"y":500,"wires":[["efe0bc54cb85f05f"]]},{"id":"de8e4bb006d84feb","type":"function","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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 \" + flow.get(\"token\"),\n}\n\nmsg.url = 'http://' + flow.get(\"ip\") + '/api/states/sensor.correios_' + msg.data.new_state.attributes.rastreio\n\nvar index = flow.get(\"rastreio\").indexOf(msg.data.new_state.attributes.rastreio);\nvar rastreio = flow.get(\"rastreio\");\nvar nome_objeto = flow.get(\"nome_objeto\");\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\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":500,"wires":[["7cc65c764aa14994"]]},{"id":"7cc65c764aa14994","type":"http request","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":850,"y":500,"wires":[[]]},{"id":"efe0bc54cb85f05f","type":"delay","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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":595,"y":500,"wires":[["de8e4bb006d84feb"]],"l":false},{"id":"0fe4128c59a913e6","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","name":"Excluir automaticamente","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"correios_","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":150,"y":500,"wires":[["8f7030e0d6bbba28"]]},{"id":"070006aaf7517e6b","type":"group","z":"e3f8c2a2b98f267c","name":"DEV","style":{"label":true},"nodes":["fefff27a2a61466d","451572464a90aa8e","2c26becce38fc104","93e2b66f0ba9efd0","edb857bbce6ba34e","b256fa66553e9def","36bf0881461878b6","92a0738061c8c9a4","0f6b8aea8b3bccfd","1f13cde22ac1ebd0","53adf4fb7beb825c","cdf0cc7fedbc0b40","c0ad9eb653f545e8"],"x":14,"y":939,"w":752,"h":262},{"id":"fefff27a2a61466d","type":"inject","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Revemor Rastreio","props":[{"p":"rastreio","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":980,"wires":[["451572464a90aa8e"]]},{"id":"451572464a90aa8e","type":"function","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":980,"wires":[["2c26becce38fc104"]]},{"id":"2c26becce38fc104","type":"debug","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"remover array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":540,"y":980,"wires":[]},{"id":"93e2b66f0ba9efd0","type":"inject","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Listar","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":1040,"wires":[["edb857bbce6ba34e"]]},{"id":"edb857bbce6ba34e","type":"template","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Listar array","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{flow.rastreio}}\n{{flow.nome_objeto}}\n{{flow.notificacao}}","output":"str","x":270,"y":1040,"wires":[["b256fa66553e9def"]]},{"id":"b256fa66553e9def","type":"debug","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"listar array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":450,"y":1040,"wires":[]},{"id":"36bf0881461878b6","type":"inject","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Zerar Array","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":1100,"wires":[["92a0738061c8c9a4"]]},{"id":"92a0738061c8c9a4","type":"function","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":1100,"wires":[["0f6b8aea8b3bccfd"]]},{"id":"0f6b8aea8b3bccfd","type":"debug","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"array limpo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":1100,"wires":[]},{"id":"1f13cde22ac1ebd0","type":"function","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","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 \"+flow.get(\"token\"),\n}\n\nmsg.url = 'http://'+flow.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":1160,"wires":[["53adf4fb7beb825c"]]},{"id":"53adf4fb7beb825c","type":"http request","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":470,"y":1160,"wires":[["cdf0cc7fedbc0b40"]]},{"id":"cdf0cc7fedbc0b40","type":"debug","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"remover sensor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":1160,"wires":[]},{"id":"c0ad9eb653f545e8","type":"inject","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Deletar sensor","props":[{"p":"rastreio","v":"OX031380405BR","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":1160,"wires":[["1f13cde22ac1ebd0"]]},{"id":"a668d2a6552407c2","type":"group","z":"e3f8c2a2b98f267c","name":"Atualizações dos rastreios ","style":{"label":true},"nodes":["084b5f1332720326","8dde2aa9142e679e","f7a38f88dfdce579","ed0c702176a57b25","e65678a6745a86dd","9aa60d15af1779fa","8ed049d5c397ba19","dab835fedbea6607","f5db9a8fc64bcb77","a047528886a8b5a9","8f07d7dd95c95b25"],"x":4,"y":699,"w":1462,"h":82},{"id":"084b5f1332720326","type":"function","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":160,"y":740,"wires":[["8dde2aa9142e679e"]]},{"id":"8dde2aa9142e679e","type":"http request","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":290,"y":740,"wires":[["a047528886a8b5a9"]]},{"id":"f7a38f88dfdce579","type":"html","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":590,"y":740,"wires":[["ed0c702176a57b25"]]},{"id":"ed0c702176a57b25","type":"html","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":710,"y":740,"wires":[["e65678a6745a86dd"]]},{"id":"e65678a6745a86dd","type":"html","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":830,"y":740,"wires":[["9aa60d15af1779fa"]]},{"id":"9aa60d15af1779fa","type":"html","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":960,"y":740,"wires":[["8f07d7dd95c95b25"]]},{"id":"8ed049d5c397ba19","type":"ha-api","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":1390,"y":740,"wires":[[]]},{"id":"dab835fedbea6607","type":"inject","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","name":"Atualiza de 1 em 1 min ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":65,"y":740,"wires":[["084b5f1332720326"]],"l":false},{"id":"f5db9a8fc64bcb77","type":"function","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","name":"Atualizar sensor","func":"msg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase();\n\nmsg.payload = {\n    data: {\n        state: msg.status,\n        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        }\n    }\n};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":740,"wires":[["8ed049d5c397ba19"]]},{"id":"a047528886a8b5a9","type":"delay","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":440,"y":740,"wires":[["f7a38f88dfdce579"]]},{"id":"8f07d7dd95c95b25","type":"function","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":1090,"y":740,"wires":[[],["f5db9a8fc64bcb77"]]},{"id":"be8b76885aeaf41d","type":"group","z":"e3f8c2a2b98f267c","name":"Mudança de status","style":{"label":true},"nodes":["4aedb6c884bda563","2433e8dde2cbf370","6ffba8f50819f7a3","85fd666ef97460bb","68ad6a2786362f5b","4f26f8a762107df7","888005b681c08be4","4f26842d07fd7ff8"],"x":14,"y":559,"w":1332,"h":122},{"id":"4aedb6c884bda563","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","name":"Aviso mudança de status","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"correios_","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"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":150,"y":620,"wires":[["2433e8dde2cbf370"]]},{"id":"2433e8dde2cbf370","type":"function","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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":330,"y":620,"wires":[[],["6ffba8f50819f7a3"]]},{"id":"6ffba8f50819f7a3","type":"switch","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":620,"wires":[["68ad6a2786362f5b"],["4f26f8a762107df7"]]},{"id":"85fd666ef97460bb","type":"link out","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","name":"link out 19","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":955,"y":600,"wires":[]},{"id":"68ad6a2786362f5b","type":"template","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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":830,"y":600,"wires":[["85fd666ef97460bb"]]},{"id":"4f26f8a762107df7","type":"switch","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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":910,"y":640,"wires":[["888005b681c08be4"]]},{"id":"888005b681c08be4","type":"template","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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":1190,"y":640,"wires":[["4f26842d07fd7ff8"]]},{"id":"4f26842d07fd7ff8","type":"link out","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","name":"link out 20","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1305,"y":640,"wires":[]}]
1 curtida

@kelvinrafaeli parece que está funcionando bem… Pelo menos aqui pra mim…

Obrigado!

1 curtida

Show! Fiz estou utilizando em conjunto com os card que postou ficou muito bom.

Falando nisso, você tem outros cards “diferentões” com mushroom? Não usava ele mas vi que as possibilidades são infinitas rsrsrs

TOP… Funcionou aqui…

Como faço para receber notificações pelo telegram? (já tenho o mesmo configurado no HA). Porem, sou meio leigo ainda.,

Qual deles vc usa?

Eu tenho o node-red-contrib-telegrambot-home

Nele vc coloca o node notify:

image

Coloca no final do nó

image

Caraca, parabéns!
ficou demais isso.

Pensei em desenvolver um meio que com a mesma ideia, porque querendo ou não acabo utilizando os apps de mobile para ficar verificando as encomendas.
Que bom que pesquisei antes, me poupou muito tempo!

Só uma dúvida, no card, quando clico em novo ele não abre nada.
já revisei várias vezes e não consigo encontrar onde possa estar errado.
já vi as os inputs, estão corretos, pelo que entendi do código os sensors são criados dinamicamente, correto?

Top né!

Se você estiver querendo utilizar o de card pop-up que o Guilherme fez você vai precisar da integração browser mod, por isso ao clicar não abre.

putz, que vacilo.
nem prestei atenção na integração.
malz…

aproveitando, para quem achar interessante, integrei com o o notifyme da alexa, ficou zica!

muito obrigado e parabéns a todos que colaboraram.

2 curtidas

@kelvinrafaeli tentei usar esse ultimo codigo que compartilhou, mas nao estou achando o node onde devo configurar o IP e token. Pode me ajudar?

[{"id":"9c2c50fdc6329aff","type":"group","z":"e3f8c2a2b98f267c","name":"Incluir rastreio","style":{"label":true},"nodes":["9549acd579d12e6d","5731e180e117e905","1574ea28746987cc","3571a466290dd999","ffe2a88abdc1039f","9cfcdeb8ece55726","aa96ba9a06a7ccb7","d1e012e2f876c02a","cb123282ef6ad690","5d32837d47a24b86","165707cbed3c57ba","7d7f8d54fc47be85","2ecdd1cb1b70d706","e909433d2148b52b"],"x":14,"y":79,"w":1572,"h":202},{"id":"9549acd579d12e6d","type":"function","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":180,"wires":[["5731e180e117e905"]]},{"id":"5731e180e117e905","type":"http request","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":730,"y":180,"wires":[["1574ea28746987cc"]]},{"id":"1574ea28746987cc","type":"html","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":850,"y":180,"wires":[["cb123282ef6ad690"]]},{"id":"3571a466290dd999","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":100,"y":180,"wires":[["9cfcdeb8ece55726","2ecdd1cb1b70d706"]]},{"id":"ffe2a88abdc1039f","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","name":"SALVAR","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.correios_salvar","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":100,"y":120,"wires":[["3571a466290dd999"]]},{"id":"9cfcdeb8ece55726","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":110,"y":240,"wires":[["e909433d2148b52b"]]},{"id":"aa96ba9a06a7ccb7","type":"function","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","name":"Criar 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()\n\nmsg.payload = {\n    data: {\n        state: msg.status,\n        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        }\n    }\n};\n\nreturn msg\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1370,"y":180,"wires":[["d1e012e2f876c02a"]]},{"id":"d1e012e2f876c02a","type":"ha-api","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":1510,"y":180,"wires":[[]]},{"id":"cb123282ef6ad690","type":"html","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":970,"y":180,"wires":[["5d32837d47a24b86"]]},{"id":"5d32837d47a24b86","type":"html","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":1090,"y":180,"wires":[["7d7f8d54fc47be85"]]},{"id":"165707cbed3c57ba","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":450,"y":180,"wires":[["9549acd579d12e6d"]]},{"id":"7d7f8d54fc47be85","type":"html","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":1220,"y":180,"wires":[["aa96ba9a06a7ccb7"]]},{"id":"2ecdd1cb1b70d706","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":290,"y":180,"wires":[["165707cbed3c57ba"]]},{"id":"e909433d2148b52b","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"9c2c50fdc6329aff","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":290,"y":240,"wires":[[]]},{"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":"59c36af566d4029d","type":"group","z":"e3f8c2a2b98f267c","name":"Excluir rastreio","style":{"label":true},"nodes":["db5c987b7e696064","4febf3bd26fad49c","4b0ab60bec7f04fc","5d7bac7076c26c14","e5c9df6836b50f1d","8f7030e0d6bbba28","de8e4bb006d84feb","7cc65c764aa14994","efe0bc54cb85f05f","0fe4128c59a913e6"],"x":14,"y":319,"w":932,"h":222},{"id":"db5c987b7e696064","type":"http request","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":550,"y":360,"wires":[[]]},{"id":"4febf3bd26fad49c","type":"function","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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 \"+flow.get(\"token\"),\n}\n\nmsg.url = 'http://'+flow.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\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\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":360,"wires":[["db5c987b7e696064"]]},{"id":"4b0ab60bec7f04fc","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","name":"EXCLUIR","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.correios_excluir","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":100,"y":360,"wires":[["e5c9df6836b50f1d","5d7bac7076c26c14"]]},{"id":"5d7bac7076c26c14","type":"api-current-state","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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":260,"y":360,"wires":[["4febf3bd26fad49c"]]},{"id":"e5c9df6836b50f1d","type":"api-call-service","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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":110,"y":420,"wires":[[]]},{"id":"8f7030e0d6bbba28","type":"switch","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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":420,"y":500,"wires":[["efe0bc54cb85f05f"]]},{"id":"de8e4bb006d84feb","type":"function","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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 \" + flow.get(\"token\"),\n}\n\nmsg.url = 'http://' + flow.get(\"ip\") + '/api/states/sensor.correios_' + msg.data.new_state.attributes.rastreio\n\nvar index = flow.get(\"rastreio\").indexOf(msg.data.new_state.attributes.rastreio);\nvar rastreio = flow.get(\"rastreio\");\nvar nome_objeto = flow.get(\"nome_objeto\");\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\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":500,"wires":[["7cc65c764aa14994"]]},{"id":"7cc65c764aa14994","type":"http request","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":850,"y":500,"wires":[[]]},{"id":"efe0bc54cb85f05f","type":"delay","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","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":595,"y":500,"wires":[["de8e4bb006d84feb"]],"l":false},{"id":"0fe4128c59a913e6","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"59c36af566d4029d","name":"Excluir automaticamente","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"correios_","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":150,"y":500,"wires":[["8f7030e0d6bbba28"]]},{"id":"070006aaf7517e6b","type":"group","z":"e3f8c2a2b98f267c","name":"DEV","style":{"label":true},"nodes":["fefff27a2a61466d","451572464a90aa8e","2c26becce38fc104","93e2b66f0ba9efd0","edb857bbce6ba34e","b256fa66553e9def","36bf0881461878b6","92a0738061c8c9a4","0f6b8aea8b3bccfd","1f13cde22ac1ebd0","53adf4fb7beb825c","cdf0cc7fedbc0b40","c0ad9eb653f545e8"],"x":14,"y":939,"w":752,"h":262},{"id":"fefff27a2a61466d","type":"inject","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Revemor Rastreio","props":[{"p":"rastreio","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":980,"wires":[["451572464a90aa8e"]]},{"id":"451572464a90aa8e","type":"function","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":980,"wires":[["2c26becce38fc104"]]},{"id":"2c26becce38fc104","type":"debug","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"remover array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":540,"y":980,"wires":[]},{"id":"93e2b66f0ba9efd0","type":"inject","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Listar","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":1040,"wires":[["edb857bbce6ba34e"]]},{"id":"edb857bbce6ba34e","type":"template","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Listar array","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{flow.rastreio}}\n{{flow.nome_objeto}}\n{{flow.notificacao}}","output":"str","x":270,"y":1040,"wires":[["b256fa66553e9def"]]},{"id":"b256fa66553e9def","type":"debug","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"listar array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":450,"y":1040,"wires":[]},{"id":"36bf0881461878b6","type":"inject","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Zerar Array","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":1100,"wires":[["92a0738061c8c9a4"]]},{"id":"92a0738061c8c9a4","type":"function","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":1100,"wires":[["0f6b8aea8b3bccfd"]]},{"id":"0f6b8aea8b3bccfd","type":"debug","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"array limpo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":1100,"wires":[]},{"id":"1f13cde22ac1ebd0","type":"function","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","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 \"+flow.get(\"token\"),\n}\n\nmsg.url = 'http://'+flow.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":1160,"wires":[["53adf4fb7beb825c"]]},{"id":"53adf4fb7beb825c","type":"http request","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":470,"y":1160,"wires":[["cdf0cc7fedbc0b40"]]},{"id":"cdf0cc7fedbc0b40","type":"debug","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"remover sensor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":1160,"wires":[]},{"id":"c0ad9eb653f545e8","type":"inject","z":"e3f8c2a2b98f267c","g":"070006aaf7517e6b","name":"Deletar sensor","props":[{"p":"rastreio","v":"OX031380405BR","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":1160,"wires":[["1f13cde22ac1ebd0"]]},{"id":"a668d2a6552407c2","type":"group","z":"e3f8c2a2b98f267c","name":"Atualizações dos rastreios ","style":{"label":true},"nodes":["084b5f1332720326","8dde2aa9142e679e","f7a38f88dfdce579","ed0c702176a57b25","e65678a6745a86dd","9aa60d15af1779fa","8ed049d5c397ba19","dab835fedbea6607","f5db9a8fc64bcb77","a047528886a8b5a9","8f07d7dd95c95b25"],"x":4,"y":699,"w":1462,"h":82},{"id":"084b5f1332720326","type":"function","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":160,"y":740,"wires":[["8dde2aa9142e679e"]]},{"id":"8dde2aa9142e679e","type":"http request","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":290,"y":740,"wires":[["a047528886a8b5a9"]]},{"id":"f7a38f88dfdce579","type":"html","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":590,"y":740,"wires":[["ed0c702176a57b25"]]},{"id":"ed0c702176a57b25","type":"html","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":710,"y":740,"wires":[["e65678a6745a86dd"]]},{"id":"e65678a6745a86dd","type":"html","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":830,"y":740,"wires":[["9aa60d15af1779fa"]]},{"id":"9aa60d15af1779fa","type":"html","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":960,"y":740,"wires":[["8f07d7dd95c95b25"]]},{"id":"8ed049d5c397ba19","type":"ha-api","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":1390,"y":740,"wires":[[]]},{"id":"dab835fedbea6607","type":"inject","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","name":"Atualiza de 1 em 1 min ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":65,"y":740,"wires":[["084b5f1332720326"]],"l":false},{"id":"f5db9a8fc64bcb77","type":"function","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","name":"Atualizar sensor","func":"msg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase();\n\nmsg.payload = {\n    data: {\n        state: msg.status,\n        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        }\n    }\n};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":740,"wires":[["8ed049d5c397ba19"]]},{"id":"a047528886a8b5a9","type":"delay","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":440,"y":740,"wires":[["f7a38f88dfdce579"]]},{"id":"8f07d7dd95c95b25","type":"function","z":"e3f8c2a2b98f267c","g":"a668d2a6552407c2","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":1090,"y":740,"wires":[[],["f5db9a8fc64bcb77"]]},{"id":"be8b76885aeaf41d","type":"group","z":"e3f8c2a2b98f267c","name":"Mudança de status","style":{"label":true},"nodes":["4aedb6c884bda563","2433e8dde2cbf370","6ffba8f50819f7a3","85fd666ef97460bb","68ad6a2786362f5b","4f26f8a762107df7","888005b681c08be4","4f26842d07fd7ff8"],"x":14,"y":559,"w":1332,"h":122},{"id":"4aedb6c884bda563","type":"server-state-changed","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","name":"Aviso mudança de status","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"correios_","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"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":150,"y":620,"wires":[["2433e8dde2cbf370"]]},{"id":"2433e8dde2cbf370","type":"function","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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":330,"y":620,"wires":[[],["6ffba8f50819f7a3"]]},{"id":"6ffba8f50819f7a3","type":"switch","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":620,"wires":[["68ad6a2786362f5b"],["4f26f8a762107df7"]]},{"id":"85fd666ef97460bb","type":"link out","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","name":"link out 19","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":955,"y":600,"wires":[]},{"id":"68ad6a2786362f5b","type":"template","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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":830,"y":600,"wires":[["85fd666ef97460bb"]]},{"id":"4f26f8a762107df7","type":"switch","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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":910,"y":640,"wires":[["888005b681c08be4"]]},{"id":"888005b681c08be4","type":"template","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","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":1190,"y":640,"wires":[["4f26842d07fd7ff8"]]},{"id":"4f26842d07fd7ff8","type":"link out","z":"e3f8c2a2b98f267c","g":"be8b76885aeaf41d","name":"link out 20","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1305,"y":640,"wires":[]}]

No seu primeiro codigo tinha um node para colocar essas informacoes, nesse ultimo nao.

@jeanjnx segue o código completo:

[{"id":"64cb79ecf5c8ecce","type":"subflow","name":"Criar sensor","info":"","category":"","in":[{"x":340,"y":260,"wires":[{"id":"d18ded582deabed0"}]}],"out":[{"x":920,"y":260,"wires":[{"id":"bb5e79bf906c7fb5","port":0}]}],"env":[{"name":"entity_id","type":"str","value":"sensor.","ui":{"label":{"en-US":"entity_id"}}},{"name":"Utilizar msg.state como variavel para passar informação caso não use o state abaixo","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":"atributos","type":"json","value":"{\"friendly_name\":\"nome_teste\",\"state_class\":\"measurement\",\"device_class\":\"temperature\",\"unit_of_measurement\":\"°C\",\"icon\":\"mdi:information\"}","ui":{"label":{"en-US":"atributos"}}}],"meta":{},"color":"#DDAA99"},{"id":"bb5e79bf906c7fb5","type":"ha-api","z":"64cb79ecf5c8ecce","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":830,"y":260,"wires":[[]]},{"id":"dcf89365a58f93c3","type":"function","z":"64cb79ecf5c8ecce","name":"Criar sensor ","func":"\nmsg.entity_id = env.get('entity_id')\nmsg.payload = {\n    data: {\n        state: msg.state,\n        attributes: env.get('atributos')\n    }\n };\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":240,"wires":[["bb5e79bf906c7fb5"]]},{"id":"d18ded582deabed0","type":"switch","z":"64cb79ecf5c8ecce","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":490,"y":260,"wires":[["dcf89365a58f93c3"],["3f25c747efdd4a0d"]]},{"id":"3f25c747efdd4a0d","type":"function","z":"64cb79ecf5c8ecce","name":"Criar sensor ","func":"\nmsg.entity_id = env.get('entity_id')\nmsg.payload = {\n    data: {\n        state: env.get(\"state\"),\n        attributes: env.get('atributos')\n    }\n };\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":280,"wires":[["bb5e79bf906c7fb5"]]},{"id":"b9582ef2ea9e3864","type":"tab","label":"-Correios","disabled":false,"info":"","env":[]},{"id":"a045ffb3b5a021d3","type":"group","z":"b9582ef2ea9e3864","name":"Incluir rastreio","style":{"label":true},"nodes":["7936f81f6de42dfe","eeaa6fff269a7006","ebeaaa2802703ea3","03688ee982d7c0a4","93cadef6a9aba974","bfce22d231c23d4e","d015f05a2e586d33","86f72003e341c6a8","6661abf1b60a3a11","9e63fe864167fa06","affd3b94c06396c2","64d79d3fc15e8a27","45359b0fd981b719","c14fad98e19e3365","2d8e7990d46f04ef"],"x":34,"y":179,"w":1622,"h":202},{"id":"b297af5648ec4edb","type":"group","z":"b9582ef2ea9e3864","name":"Excluir rastreio","style":{"label":true},"nodes":["99295dcfd6bb18b0","e1846047abfeaf87","663eb7057bfefb38","98f951e7c3980b81","77bd85086df32023","71dd4716f7ab3060","f0de60cb8074bea3","b3758921f8a46c49","52187794371f3d7d","831c3b4555836652","4ceb30e3abc282cd","ab0b15a5fd55df4f"],"x":54,"y":399,"w":1022,"h":222},{"id":"4c0124ba259009d0","type":"group","z":"b9582ef2ea9e3864","name":"DEV","style":{"label":true},"nodes":["c7b5189183d3123f","2055398a2eb13d68","8c3d53b3a5898298","bf9f148dc3cbd9c4","a3147cb6061af5a2","46da90177262f18e","c1023a52af51700c","28c9f0537b02bd34","2fa319507525a55e","2d158f4567db0a22","923638902a2ee678","117e4b99de9a792c","c600cbb39dd83cc7"],"x":34,"y":939,"w":752,"h":262},{"id":"3d0c95b3b60d08c6","type":"group","z":"b9582ef2ea9e3864","name":"Atualizações dos rastreios ","style":{"label":true},"nodes":["defa5fdfefbd8459","37c46cbd88672e98","f3c66f987d3cf10a","bd8740ba41d78679","2cbdb8b91985e973","08850d3ac5564a6e","1fbde4c4fbec503e","0aab7fbf07ba2181","80e8660d80de58af","63722aef9438fb88","d68e7512776d8e9a"],"x":24,"y":839,"w":1462,"h":82},{"id":"eb3efd8759928917","type":"group","z":"b9582ef2ea9e3864","name":"Mudança de status","style":{"label":true},"nodes":["af667aab375d2559","7f18b3f0346ef59e","af1ca4afb73e2ff0","4167aad8bcaf4a5b","80f0fa07e7158e2f","9ec0c17af78d683c","9f54af6af41380f3","876eb93796ea3222","93142c1cb09fc4b9","70b2c7d8e953c613","e299d4caf7dbb133"],"x":34,"y":659,"w":1342,"h":162},{"id":"944382b757a7cf17","type":"group","z":"b9582ef2ea9e3864","name":"Criando sensor de contagem ","style":{"label":true},"nodes":["48190a1a9a4e23eb","cc07839e8163961d","c066c32d034cd7d4","3c6aed4003211ae7"],"x":34,"y":79,"w":362,"h":82},{"id":"a880951b66df2785","type":"inject","z":"b9582ef2ea9e3864","name":"Digitar Chave token e IP","props":[{"p":"payload"}],"repeat":"1800","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":75,"y":40,"wires":[["54d486301e2e0d81"]],"l":false},{"id":"54d486301e2e0d81","type":"change","z":"b9582ef2ea9e3864","name":"Digitar Chave token e IP","rules":[{"t":"set","p":"token","pt":"flow","to":"","tot":"str"},{"t":"set","p":"ip","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":40,"wires":[[]]},{"id":"7936f81f6de42dfe","type":"function","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":280,"wires":[["eeaa6fff269a7006"]]},{"id":"eeaa6fff269a7006","type":"http request","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":280,"wires":[["ebeaaa2802703ea3"]]},{"id":"ebeaaa2802703ea3","type":"html","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":280,"wires":[["6661abf1b60a3a11"]]},{"id":"03688ee982d7c0a4","type":"api-current-state","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":280,"wires":[["bfce22d231c23d4e","45359b0fd981b719"]]},{"id":"93cadef6a9aba974","type":"server-state-changed","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","name":"SALVAR","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.correios_salvar","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":220,"wires":[["03688ee982d7c0a4"]]},{"id":"bfce22d231c23d4e","type":"api-call-service","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":340,"wires":[["c14fad98e19e3365"]]},{"id":"d015f05a2e586d33","type":"function","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","name":"Criar 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()\n\nmsg.payload = {\n    data: {\n        state: msg.status,\n        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        }\n    }\n};\n\nreturn msg\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1390,"y":280,"wires":[["86f72003e341c6a8"]]},{"id":"86f72003e341c6a8","type":"ha-api","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":1530,"y":280,"wires":[["2d8e7990d46f04ef"]]},{"id":"6661abf1b60a3a11","type":"html","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":280,"wires":[["9e63fe864167fa06"]]},{"id":"9e63fe864167fa06","type":"html","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":280,"wires":[["64d79d3fc15e8a27"]]},{"id":"affd3b94c06396c2","type":"api-current-state","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":280,"wires":[["7936f81f6de42dfe"]]},{"id":"64d79d3fc15e8a27","type":"html","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":280,"wires":[["d015f05a2e586d33"]]},{"id":"45359b0fd981b719","type":"api-current-state","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":280,"wires":[["affd3b94c06396c2"]]},{"id":"c14fad98e19e3365","type":"api-call-service","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","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":340,"wires":[[]]},{"id":"99295dcfd6bb18b0","type":"http request","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":630,"y":440,"wires":[["ab0b15a5fd55df4f"]]},{"id":"e1846047abfeaf87","type":"function","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","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 \"+flow.get(\"token\"),\n}\n\nmsg.url = 'http://'+flow.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\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\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":440,"wires":[["99295dcfd6bb18b0"]]},{"id":"663eb7057bfefb38","type":"server-state-changed","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","name":"EXCLUIR","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.correios_excluir","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":140,"y":440,"wires":[["77bd85086df32023","98f951e7c3980b81"]]},{"id":"98f951e7c3980b81","type":"api-current-state","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","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":300,"y":440,"wires":[["e1846047abfeaf87"]]},{"id":"77bd85086df32023","type":"api-call-service","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","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":150,"y":500,"wires":[[]]},{"id":"71dd4716f7ab3060","type":"switch","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","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":520,"y":580,"wires":[["52187794371f3d7d"],["52187794371f3d7d"]]},{"id":"f0de60cb8074bea3","type":"function","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","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 \" + flow.get(\"token\"),\n}\n\nmsg.url = 'http://' + flow.get(\"ip\") + '/api/states/sensor.correios_' + msg.data.new_state.attributes.rastreio\n\nvar 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\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":580,"wires":[["b3758921f8a46c49"]]},{"id":"b3758921f8a46c49","type":"http request","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":930,"y":580,"wires":[["4ceb30e3abc282cd"]]},{"id":"52187794371f3d7d","type":"delay","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","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":695,"y":580,"wires":[["f0de60cb8074bea3"]],"l":false},{"id":"831c3b4555836652","type":"server-state-changed","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","name":"Excluir automaticamente","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.correios_","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":190,"y":580,"wires":[["71dd4716f7ab3060"]]},{"id":"c7b5189183d3123f","type":"inject","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"Revemor Rastreio","props":[{"p":"rastreio","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":980,"wires":[["2055398a2eb13d68"]]},{"id":"2055398a2eb13d68","type":"function","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":980,"wires":[["8c3d53b3a5898298"]]},{"id":"8c3d53b3a5898298","type":"debug","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"remover array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":980,"wires":[]},{"id":"bf9f148dc3cbd9c4","type":"inject","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"Listar","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":1040,"wires":[["a3147cb6061af5a2"]]},{"id":"a3147cb6061af5a2","type":"template","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","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":1040,"wires":[["46da90177262f18e"]]},{"id":"46da90177262f18e","type":"debug","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"listar array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":1040,"wires":[]},{"id":"c1023a52af51700c","type":"inject","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"Zerar Array","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":1100,"wires":[["28c9f0537b02bd34"]]},{"id":"28c9f0537b02bd34","type":"function","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":1100,"wires":[["2fa319507525a55e"]]},{"id":"2fa319507525a55e","type":"debug","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"array limpo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":1100,"wires":[]},{"id":"2d158f4567db0a22","type":"function","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","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 \"+flow.get(\"token\"),\n}\n\nmsg.url = 'http://'+flow.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":1160,"wires":[["923638902a2ee678"]]},{"id":"923638902a2ee678","type":"http request","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":490,"y":1160,"wires":[["117e4b99de9a792c"]]},{"id":"117e4b99de9a792c","type":"debug","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"remover sensor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":1160,"wires":[]},{"id":"c600cbb39dd83cc7","type":"inject","z":"b9582ef2ea9e3864","g":"4c0124ba259009d0","name":"Deletar sensor","props":[{"p":"rastreio","v":"OX031380405BR","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":1160,"wires":[["2d158f4567db0a22"]]},{"id":"defa5fdfefbd8459","type":"function","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":180,"y":880,"wires":[["37c46cbd88672e98"]]},{"id":"37c46cbd88672e98","type":"http request","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":310,"y":880,"wires":[["63722aef9438fb88"]]},{"id":"f3c66f987d3cf10a","type":"html","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","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":610,"y":880,"wires":[["bd8740ba41d78679"]]},{"id":"bd8740ba41d78679","type":"html","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","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":730,"y":880,"wires":[["2cbdb8b91985e973"]]},{"id":"2cbdb8b91985e973","type":"html","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","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":850,"y":880,"wires":[["08850d3ac5564a6e"]]},{"id":"08850d3ac5564a6e","type":"html","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","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":980,"y":880,"wires":[["d68e7512776d8e9a"]]},{"id":"1fbde4c4fbec503e","type":"ha-api","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","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":1410,"y":880,"wires":[[]]},{"id":"0aab7fbf07ba2181","type":"inject","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","name":"Atualiza de 1 em 1 min ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":85,"y":880,"wires":[["defa5fdfefbd8459"]],"l":false},{"id":"80e8660d80de58af","type":"function","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","name":"Atualizar sensor","func":"msg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase();\n\nmsg.payload = {\n    data: {\n        state: msg.status,\n        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        }\n    }\n};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1260,"y":880,"wires":[["1fbde4c4fbec503e"]]},{"id":"63722aef9438fb88","type":"delay","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","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":460,"y":880,"wires":[["f3c66f987d3cf10a"]]},{"id":"d68e7512776d8e9a","type":"function","z":"b9582ef2ea9e3864","g":"3d0c95b3b60d08c6","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":1110,"y":880,"wires":[[],["80e8660d80de58af"]]},{"id":"af667aab375d2559","type":"server-state-changed","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","name":"Aviso mudança de status","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.correios_","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":740,"wires":[["9f54af6af41380f3"]]},{"id":"7f18b3f0346ef59e","type":"switch","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","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":740,"wires":[["4167aad8bcaf4a5b"],["80f0fa07e7158e2f"],["876eb93796ea3222"]]},{"id":"af1ca4afb73e2ff0","type":"link out","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","name":"link out 19","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":975,"y":700,"wires":[]},{"id":"4167aad8bcaf4a5b","type":"template","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","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":700,"wires":[["af1ca4afb73e2ff0"]]},{"id":"80f0fa07e7158e2f","type":"switch","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","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":740,"wires":[["9ec0c17af78d683c"]]},{"id":"9ec0c17af78d683c","type":"template","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","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":740,"wires":[["70b2c7d8e953c613"]]},{"id":"9f54af6af41380f3","type":"function","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","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":740,"wires":[[],["7f18b3f0346ef59e"]]},{"id":"876eb93796ea3222","type":"switch","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","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":780,"wires":[["93142c1cb09fc4b9"]]},{"id":"93142c1cb09fc4b9","type":"template","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","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":780,"wires":[["e299d4caf7dbb133"]]},{"id":"48190a1a9a4e23eb","type":"inject","z":"b9582ef2ea9e3864","g":"944382b757a7cf17","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"15","topic":"","payload":"","payloadType":"date","x":95,"y":120,"wires":[["cc07839e8163961d"]],"l":false},{"id":"cc07839e8163961d","type":"function","z":"b9582ef2ea9e3864","g":"944382b757a7cf17","name":"function 32","func":"msg.state = flow.get(\"rastreio\").length;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":195,"y":120,"wires":[["c066c32d034cd7d4"]],"l":false},{"id":"c066c32d034cd7d4","type":"subflow:64cb79ecf5c8ecce","z":"b9582ef2ea9e3864","g":"944382b757a7cf17","name":"","env":[{"name":"entity_id","value":"sensor.count_correios","type":"str"},{"name":"atributos","value":"{\"friendly_name\":\"Contagem de Sensores Correios\"}","type":"json"}],"x":300,"y":120,"wires":[[]]},{"id":"ab0b15a5fd55df4f","type":"link out","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","name":"link out 73","mode":"link","links":["3c6aed4003211ae7"],"x":735,"y":440,"wires":[]},{"id":"3c6aed4003211ae7","type":"link in","z":"b9582ef2ea9e3864","g":"944382b757a7cf17","name":"link in 54","links":["ab0b15a5fd55df4f","2d8e7990d46f04ef","76326a97b7aeb2b8","4ceb30e3abc282cd"],"x":145,"y":120,"wires":[["cc07839e8163961d"]]},{"id":"4ceb30e3abc282cd","type":"link out","z":"b9582ef2ea9e3864","g":"b297af5648ec4edb","name":"link out 74","mode":"link","links":["3c6aed4003211ae7"],"x":1035,"y":580,"wires":[]},{"id":"2d8e7990d46f04ef","type":"link out","z":"b9582ef2ea9e3864","g":"a045ffb3b5a021d3","name":"link out 75","mode":"link","links":["3c6aed4003211ae7"],"x":1615,"y":280,"wires":[]},{"id":"70b2c7d8e953c613","type":"link out","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","name":"link out 76","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":740,"wires":[]},{"id":"e299d4caf7dbb133","type":"link out","z":"b9582ef2ea9e3864","g":"eb3efd8759928917","name":"link out 77","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":780,"wires":[]},{"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}]
1 curtida

Eu atualizei e recebi minha encomenda, debugando no node-red percebi que o array ja esta vazio e em Entidades Ajudante já nao tem mais o sensor.correios_*

Porem no meu painel do HA ainda consta o objeto. É algum cache do HA?
image

Meu card (igual o seu, senao me engano)

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: Quem vai receber as 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
      - 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_text.correios_rastreio
                    name: Qual o Código de Rastreamento?
                    icon: mdi:package-variant-closed
  - type: custom:gap-card
    height: 15
  - 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: none; 
                }
            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 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 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 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 == "[]" %}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 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 destinatário']" %}grey{% endif %}
            tap_action:
              action: more-info
    sort:
      method: last_changed
      count: 10
      reverse: true

Não deveria ser. Ele permanece um tempinho pois ta configurado no node red para manter uns 10min se nao me engano, depois apaga. Se o array esta vazio, provavelmente ele nao exluiu o sensor em si, ai pode ser por causa do token. Na parte de dev, limpa o array e exclui o sensor, e tenta verificar se vai

Realmente. Parece que o problema é o certificado. Eu uso https no HA, tentei alterar as URL no flow, porem ai da erro de certificado. Estou tentando descobrir como fazer o node-red ignorar erros de SSL ao realizar as http requests.

No próprio addon do nodered tem

Realmente, porem nao deu certo.
Apesar de eu ter configurado um DNS + SSL com o DuckDNS, nao consegui usar o https da maneira correta pois nao consigo abrir a porta 443 no meu roteador.
Entao voltei tudo para http e agora esta tudo funcionando.

Obrigado.

1 curtida

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

** ATUALIZAÇÃO**

  • Adicionado a função de remover o objeto através de um input_select

20230628092052

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

AÇÕES NECESSÁRIAS

  • Importar novo código abaixo:
[{"id":"0dace93f1c62e709","type":"tab","label":"-Correios","disabled":false,"info":"","env":[]},{"id":"ea071e8da9d39124","type":"group","z":"0dace93f1c62e709","name":"Incluir rastreio","style":{"label":true},"nodes":["f215688aac7e67bb","404d5b69c1e40af2","a600ebca20c0968b","b5ee5028792ea8ba","237f67f2ca4ab536","79fba58b01c11c87","ff53093e2e9155d2","cc72f9f1b7fda6fd","6c040845867ff6a8","2733cd67e1978769","b1ed375c92445889","b8475e64f4b3cb63","22ce5d1975abff1a","2c6d126be43a048f","e12ea3e4b120efac","c288b536137d8b7f","9f2530ef2c9c5426","25d0d5e83406a5ed","fd08bd6356577e16"],"x":34,"y":199,"w":1572,"h":202},{"id":"adb353b90d4bbedb","type":"group","z":"0dace93f1c62e709","name":"Excluir rastreio","style":{"label":true},"nodes":["04f55063a767d56e","d77b94517384bea3","c8249e43b7705297","bdabd4c81e1309ef","b1a2204e1e301956","5ae184bfa0ef8c3e","6cdec18df7cd0e52","4e7c42d01a3f26d6","d26cd1f99381882b","df9ec96ad35274ab","4315c71adaa2ad30","e94f5ee3c580f66f","ca3f516e4f0ee95d","5f37254d17edc2b4","c1efd4a606eb9588","2cbf0fc39024983d","7d30202b0766f77c"],"x":34,"y":419,"w":1252,"h":222},{"id":"86677324bf9ac5d5","type":"group","z":"0dace93f1c62e709","name":"DEV","style":{"label":true},"nodes":["8d3062d99d027706","d7c5785ecede29b7","6548be5899f59b91","0a7db1c063cfa5d7","c174c3b3101d4262","a947da941e97c655","7c62383f8de137ae","6094c75c2b4ea31c","46f3c22ae5e38e3a","b9737211cc4333fb","7883a2e578eb7ada","6b51a82b7083077f","12b9b0629c827122"],"x":34,"y":959,"w":752,"h":262},{"id":"91ea8b8ecc076fd8","type":"group","z":"0dace93f1c62e709","name":"Atualizações dos rastreios ","style":{"label":true},"nodes":["1600e2e5189d4151","9024c307453b89df","996091b7f3bec5b6","a614af9e407b0f79","62310de63bee4094","b517f75bbda0a73b","02a520b2ac3ae3c6","0afd745cb7d74494","75f4be3092a5efd8","ae75eeea82e9e31e","030dbae2bd6af67b"],"x":24,"y":859,"w":1462,"h":82},{"id":"e1c505609255ef96","type":"group","z":"0dace93f1c62e709","name":"Mudança de status","style":{"label":true},"nodes":["987d968b888972f4","4acf0b6e86c06cff","ece02265c4aba933","40467c538ceb786a","8bf30de06077ee63","93e3da0b98a668d1","a58efac89ff2450d","4215b6ab806a9d83","8382b3978128ee31","fa556b1a46bca79e","deabae80d553e27d"],"x":34,"y":679,"w":1342,"h":162},{"id":"2fee2da68df7bc00","type":"inject","z":"0dace93f1c62e709","name":"Digitar Chave token e IP","props":[{"p":"payload"}],"repeat":"1800","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":75,"y":40,"wires":[["965a10599f527867"]],"l":false},{"id":"965a10599f527867","type":"change","z":"0dace93f1c62e709","name":"Digitar Chave token e IP","rules":[{"t":"set","p":"token","pt":"flow","to":"","tot":"str"},{"t":"set","p":"ip","pt":"flow","to":"192.168.0.140:8123","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":40,"wires":[[]]},{"id":"f215688aac7e67bb","type":"function","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":300,"wires":[["404d5b69c1e40af2"]]},{"id":"404d5b69c1e40af2","type":"http request","z":"0dace93f1c62e709","g":"ea071e8da9d39124","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":750,"y":300,"wires":[["a600ebca20c0968b"]]},{"id":"a600ebca20c0968b","type":"html","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["6c040845867ff6a8"]]},{"id":"b5ee5028792ea8ba","type":"api-current-state","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["79fba58b01c11c87","22ce5d1975abff1a"]]},{"id":"237f67f2ca4ab536","type":"server-state-changed","z":"0dace93f1c62e709","g":"ea071e8da9d39124","name":"SALVAR","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.correios_salvar","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":[["b5ee5028792ea8ba","e12ea3e4b120efac"]]},{"id":"79fba58b01c11c87","type":"api-call-service","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["2c6d126be43a048f"]]},{"id":"ff53093e2e9155d2","type":"function","z":"0dace93f1c62e709","g":"ea071e8da9d39124","name":"Criar 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()\n\nmsg.payload = {\n    data: {\n        state: msg.status,\n        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        }\n    }\n};\n\nreturn msg\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1390,"y":300,"wires":[["cc72f9f1b7fda6fd"]]},{"id":"cc72f9f1b7fda6fd","type":"ha-api","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":1530,"y":300,"wires":[[]]},{"id":"6c040845867ff6a8","type":"html","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["2733cd67e1978769"]]},{"id":"2733cd67e1978769","type":"html","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["b8475e64f4b3cb63"]]},{"id":"b1ed375c92445889","type":"api-current-state","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["f215688aac7e67bb"]]},{"id":"b8475e64f4b3cb63","type":"html","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["ff53093e2e9155d2"]]},{"id":"22ce5d1975abff1a","type":"api-current-state","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["b1ed375c92445889"]]},{"id":"2c6d126be43a048f","type":"api-call-service","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":"e12ea3e4b120efac","type":"delay","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[["c288b536137d8b7f"]],"l":false},{"id":"c288b536137d8b7f","type":"ha-get-entities","z":"0dace93f1c62e709","g":"ea071e8da9d39124","name":"Pegar sensores","server":"db1ab0af.caa65","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"sensor.correios_","valueType":"str"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"sensores","output_results_count":1,"x":480,"y":240,"wires":[["9f2530ef2c9c5426"]]},{"id":"9f2530ef2c9c5426","type":"function","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":240,"wires":[["25d0d5e83406a5ed"]]},{"id":"25d0d5e83406a5ed","type":"api-call-service","z":"0dace93f1c62e709","g":"ea071e8da9d39124","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":[],"queue":"none","x":780,"y":240,"wires":[[]]},{"id":"fd08bd6356577e16","type":"link in","z":"0dace93f1c62e709","g":"ea071e8da9d39124","name":"link in 55","links":["e94f5ee3c580f66f","4315c71adaa2ad30"],"x":325,"y":240,"wires":[["c288b536137d8b7f"]]},{"id":"04f55063a767d56e","type":"http request","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":570,"y":460,"wires":[["e94f5ee3c580f66f","7d30202b0766f77c"]]},{"id":"d77b94517384bea3","type":"function","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","name":"Headers","func":"let partes = msg.rastreio.split('-');\nlet resultado = partes.pop().trim().toUpperCase();\nmsg.rastreio = resultado;\n\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    \"Authorization\": \"Bearer \"+flow.get(\"token\"),\n}\n\nmsg.url = 'http://'+flow.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\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\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":460,"wires":[["04f55063a767d56e"]]},{"id":"c8249e43b7705297","type":"server-state-changed","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","name":"EXCLUIR","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_button.correios_excluir","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":[["b1a2204e1e301956","bdabd4c81e1309ef"]]},{"id":"bdabd4c81e1309ef","type":"api-current-state","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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":[["d77b94517384bea3"]]},{"id":"b1a2204e1e301956","type":"api-call-service","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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":"5ae184bfa0ef8c3e","type":"switch","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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":[["d26cd1f99381882b"],["d26cd1f99381882b"]]},{"id":"6cdec18df7cd0e52","type":"function","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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 \" + flow.get(\"token\"),\n}\n\nmsg.url = 'http://' + flow.get(\"ip\") + '/api/states/sensor.correios_' + msg.data.new_state.attributes.rastreio\n\nvar 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\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":600,"wires":[["4e7c42d01a3f26d6"]]},{"id":"4e7c42d01a3f26d6","type":"http request","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":870,"y":600,"wires":[["4315c71adaa2ad30"]]},{"id":"d26cd1f99381882b","type":"delay","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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":[["6cdec18df7cd0e52"]],"l":false},{"id":"df9ec96ad35274ab","type":"server-state-changed","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","name":"Excluir automaticamente","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.correios_","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":[["5ae184bfa0ef8c3e"]]},{"id":"4315c71adaa2ad30","type":"link out","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","name":"link out 74","mode":"link","links":["392e29fa7c841991","4889d89cd6c1f2c0","fd08bd6356577e16","6a50ed49d7a7d474"],"x":975,"y":600,"wires":[]},{"id":"e94f5ee3c580f66f","type":"link out","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","name":"link out 73","mode":"link","links":["392e29fa7c841991","fd08bd6356577e16","6a50ed49d7a7d474"],"x":665,"y":460,"wires":[]},{"id":"ca3f516e4f0ee95d","type":"ha-get-entities","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","name":"Pegar sensores","server":"db1ab0af.caa65","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"sensor.correios_","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"sensores","output_results_count":1,"x":820,"y":460,"wires":[["2cbf0fc39024983d"]]},{"id":"5f37254d17edc2b4","type":"function","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":460,"wires":[["c1efd4a606eb9588"]]},{"id":"c1efd4a606eb9588","type":"api-call-service","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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":[],"queue":"none","x":1200,"y":460,"wires":[[]]},{"id":"2cbf0fc39024983d","type":"function","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":935,"y":460,"wires":[["5f37254d17edc2b4"]],"l":false},{"id":"7d30202b0766f77c","type":"delay","z":"0dace93f1c62e709","g":"adb353b90d4bbedb","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":[["ca3f516e4f0ee95d"]],"l":false},{"id":"8d3062d99d027706","type":"inject","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","name":"Revemor Rastreio","props":[{"p":"rastreio","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":1000,"wires":[["d7c5785ecede29b7"]]},{"id":"d7c5785ecede29b7","type":"function","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":1000,"wires":[["6548be5899f59b91"]]},{"id":"6548be5899f59b91","type":"debug","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","name":"remover array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":1000,"wires":[]},{"id":"0a7db1c063cfa5d7","type":"inject","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","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":[["c174c3b3101d4262"]]},{"id":"c174c3b3101d4262","type":"template","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","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":[["a947da941e97c655"]]},{"id":"a947da941e97c655","type":"debug","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","name":"listar array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":1060,"wires":[]},{"id":"7c62383f8de137ae","type":"inject","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","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":[["6094c75c2b4ea31c"]]},{"id":"6094c75c2b4ea31c","type":"function","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":1120,"wires":[["46f3c22ae5e38e3a"]]},{"id":"46f3c22ae5e38e3a","type":"debug","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","name":"array limpo","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":1120,"wires":[]},{"id":"b9737211cc4333fb","type":"function","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","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 \"+flow.get(\"token\"),\n}\n\nmsg.url = 'http://'+flow.get(\"ip\")+'/api/states/sensor.correios_' + msg.rastreio\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":1180,"wires":[["7883a2e578eb7ada"]]},{"id":"7883a2e578eb7ada","type":"http request","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","name":"","method":"DELETE","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":490,"y":1180,"wires":[["6b51a82b7083077f"]]},{"id":"6b51a82b7083077f","type":"debug","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","name":"remover sensor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":1180,"wires":[]},{"id":"12b9b0629c827122","type":"inject","z":"0dace93f1c62e709","g":"86677324bf9ac5d5","name":"Deletar sensor","props":[{"p":"rastreio","v":"NL658154191BR","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":1180,"wires":[["b9737211cc4333fb"]]},{"id":"1600e2e5189d4151","type":"function","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":180,"y":900,"wires":[["9024c307453b89df"]]},{"id":"9024c307453b89df","type":"http request","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","name":"Site","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":310,"y":900,"wires":[["ae75eeea82e9e31e"]]},{"id":"996091b7f3bec5b6","type":"html","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","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":610,"y":900,"wires":[["a614af9e407b0f79"]]},{"id":"a614af9e407b0f79","type":"html","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","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":730,"y":900,"wires":[["62310de63bee4094"]]},{"id":"62310de63bee4094","type":"html","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","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":850,"y":900,"wires":[["b517f75bbda0a73b"]]},{"id":"b517f75bbda0a73b","type":"html","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","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":980,"y":900,"wires":[["030dbae2bd6af67b"]]},{"id":"02a520b2ac3ae3c6","type":"ha-api","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","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":1410,"y":900,"wires":[[]]},{"id":"0afd745cb7d74494","type":"inject","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","name":"Atualiza de 1 em 1 min ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":85,"y":900,"wires":[["1600e2e5189d4151"]],"l":false},{"id":"75f4be3092a5efd8","type":"function","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","name":"Atualizar sensor","func":"msg.entity_id = 'sensor.correios_' + msg.rastreio.toUpperCase();\n\nmsg.payload = {\n    data: {\n        state: msg.status,\n        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        }\n    }\n};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1260,"y":900,"wires":[["02a520b2ac3ae3c6"]]},{"id":"ae75eeea82e9e31e","type":"delay","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","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":460,"y":900,"wires":[["996091b7f3bec5b6"]]},{"id":"030dbae2bd6af67b","type":"function","z":"0dace93f1c62e709","g":"91ea8b8ecc076fd8","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":1110,"y":900,"wires":[[],["75f4be3092a5efd8"]]},{"id":"987d968b888972f4","type":"server-state-changed","z":"0dace93f1c62e709","g":"e1c505609255ef96","name":"Aviso mudança de status","server":"db1ab0af.caa65","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.correios_","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":[["a58efac89ff2450d"]]},{"id":"4acf0b6e86c06cff","type":"switch","z":"0dace93f1c62e709","g":"e1c505609255ef96","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":[["40467c538ceb786a"],["8bf30de06077ee63"],["4215b6ab806a9d83"]]},{"id":"ece02265c4aba933","type":"link out","z":"0dace93f1c62e709","g":"e1c505609255ef96","name":"link out 19","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":975,"y":720,"wires":[]},{"id":"40467c538ceb786a","type":"template","z":"0dace93f1c62e709","g":"e1c505609255ef96","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":[["ece02265c4aba933"]]},{"id":"8bf30de06077ee63","type":"switch","z":"0dace93f1c62e709","g":"e1c505609255ef96","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":[["93e3da0b98a668d1"]]},{"id":"93e3da0b98a668d1","type":"template","z":"0dace93f1c62e709","g":"e1c505609255ef96","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":[["fa556b1a46bca79e"]]},{"id":"a58efac89ff2450d","type":"function","z":"0dace93f1c62e709","g":"e1c505609255ef96","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":[[],["4acf0b6e86c06cff"]]},{"id":"4215b6ab806a9d83","type":"switch","z":"0dace93f1c62e709","g":"e1c505609255ef96","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":[["8382b3978128ee31"]]},{"id":"8382b3978128ee31","type":"template","z":"0dace93f1c62e709","g":"e1c505609255ef96","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":[["deabae80d553e27d"]]},{"id":"fa556b1a46bca79e","type":"link out","z":"0dace93f1c62e709","g":"e1c505609255ef96","name":"link out 76","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":760,"wires":[]},{"id":"deabae80d553e27d","type":"link out","z":"0dace93f1c62e709","g":"e1c505609255ef96","name":"link out 77","mode":"link","links":["0d20d93e76ce11d7","f04403206e76f318"],"x":1335,"y":800,"wires":[]},{"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}]

OBS: o código acima já esta com o nó do token, então se forem atualizar o código façam um backup do token de vocês para não precisar gerar um novo.

  • Ir em Configurações > Dispositivos > Entidades Ajudantes e criar um select com o nome de rastreio, a entidade tem que ficar input_select.correios

  • Importar o novo código do cartão:

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

1 curtida

Cara, atualizei aqui para esse novo padrão de excluir e ficou muito bom o funcionamento!

Só fiquei desanimado com o CARD de POP-UP que está todo bugado nessas ultimas atualizações e parece que o desenvolvedor deu uma abandonada no projeto! Preciso encontrar outra solução para meu dash :disappointed_relieved:

1 curtida