Home Assistant: Ragtech Nobreak Easy Pro (UPS) Monitoring

em resumo, o primeiro comando recebe A0 FF FF FF FF 12 34 56 78

mas note que em meu nodered ele esta desligado!
aqui, apenas preciso mandar o comando AA 04 00 80 1E 9E e ele retorna
“aa 21 00 00 58 ff ff ff ff 00 da c6 70 06 06 3d f3 00 00 03 82 c2 01 a0 30 00 70 06 0a 00 d8”

faz o mesmo que eu fiz…
instala uma aplicacao pra monitorar a porta serial…
roda o aplicativo deles, e grava o que ele esta retornando…

usei esse app. a versão free ja resolveu.
https://www.hhdsoftware.com/serial-port-monitor

Me parece claro que o primeiro comando é o que pede algum tipo de identificação do nobreak e o restante traz outras informações. A resposta do meu para o primeiro comando é diferente do seu. Além disso testei com outro modelo que tenho aqui que tem comportamento bem diferente, ele dá algumas respostas no inicio e depois parece que se perde e só solta a responder se remover e colocar novamente o cabo USB.

vou ver se tento monitorar esses dois com o software deles em uma VM windows, quando tentei da ultima vez no linux o software nem instalava, quem sabe tem uma versão nova que funcione.

@gustavocmorais vi esse fluxo agora, show de bola. :clap:
Tenho um One Up Nitro que fica com os meus servidores aqui de casa.
Vou tentar instalar um linux local aqui num pc antigo e ver o que rola de descobrir. O osso é ficar decifrando bit haha

Oi! O modo que consegui descobrir algo minimo foi no windows. Instalei o sistema oficial dele e abrir um monitor da porta serial do lado. Coloquei pra filmar a tela e tirei da tomada por alguns minutos.

Depois, assistindo o video com calma, fui comparando os bytes que mudavam e tentando associar a carga da bateria e temperatura e voltagem de entrada.

Depois repeti alguns testes pra ver se o comportamento se repetia.

Totalmente baseado em metodo empirico. Hahahaha

2 Likes

Cara, eu não consegui fazer o nobreak se conectar aqui. Não sei se é algum problema no proxmox, na porta usb, no cabo, realmente não sei. No nodered ele até aparece conectado, pega o nome da porta no HA certinho, mas nada. Instalei o Supervise numa VM separada, mas tbm não consigo fazer ele se comunicar…
Entretanto achei um arquivo que pode ajudar. Tô tentando decifrá-lo…

Arquivo config nobreak

ai vai o video que fiz…
https://we.tl/t-IxNBGkq8Jp

1 Like

Alguém chegou a descobrir se existe algum comando pela serial para forçar o nobreak a DESLIGAR?

O video ficou indisponivel :frowning:

Tenho um Ragtech Senoidal NEP 1200VA, mas infelizmente não funcionou com o JSON do NodeRED. Está com o mesmo comportamento que foi relatado ai por alguns, aparece conectado mas não recebe nenhum dado do nobreak.

Se eu soubesse que essa comunicação proprietária da Ragtech era tão ruim de integrar eu tinha comprado outra marca :sweat_smile:

Olá pessoal!

Eu tenho um OneUp Nitro de 2000VA que há um tempo venho querendo integrar no HA. Segui os passos aqui, capturei as mensagens mas, o nobreak não responde da mesma forma quando eu mando os comandos manualmente.

Alguém passou por algo assim?

Segue o link dos arquivos READ e WRITE que capturei: Microsoft OneDrive

Se alguém puder me ajudar, eu agradeço muito :grinning:

Não sei em qual pé ficou isso, mas queria confirmar que consegui usar essa solução para usar o Home Assistant com meus nobreaks RagTech modelo 4162.

Meu setup ficou: o broker MQTT roda no HA como AddOn, o script que fica dentro de Proxy/server.py roda num Raspberry Pi e eu alterei o tópico do MQTT pra auto-configurar os dispositivos direto no HA e fazer as automações.

Ah, na hora de instalar o Paho-MQTT no venv, tem que usar a versão 1.6.1.

Opa. Meu Nobrek é o EasyPro também, plugado direto à uma das portas USB do meu Raspberry Pi, mas infelizmente aconteceu comigo o mesmo que aconteceu com o @marcelouw .

Gostaria de tentar esta integração HA_Ragtech_UPS mas não faço nem idéia de como instala. Poderia me ensinar por favor?

Primeiramente agradecer ao @gustavocmorais pela enorme ajuda!
Tenho um ONE UP 2000 NITRO TI comecei a inspecionar os dados seriais agora, ja vi que a taxa de boud é especifica e fora de padrão :@ 2560.
com isso o node-red ja consegue pegar esse 3 dados, quero continuar para ver se consigo pegar as outras informações.
vamos continuar a discussão aqui ou abrir uma só pra quem tem o ONE UP?

oi turma! eh uma luta integrar nesse ragtech… protocolo fechado sem necessidade…
me pergunto se não vale uma frente de tentar decompilar o sistema deles…

comparando minha solução do nodered com essa… parecem estar fazendo algo parecido…
o buffer enviado para pedir os dados eh o mesmo. e as posicoes que faço a leitura dos dados (pelo menos o % da bateria) esta parecido. vou ate ajustar meu nodered para ler todos os dados que esse script python le…

a magica de leitura esta nessa funcao:

def build_payload(buffer):
    iOut = linear(buffer[0x0D], 0.1152, 0, 2)

    vOut = linear(buffer[0x1E], 0.555, 0, 2)
    wOut = iOut*vOut

    vIn = linear(buffer[0x0C], 1.06, 0, 2)
    wIn = iOut*vIn # não tem "iIn"

    processPower(wOut, wIn)

    payload = {
        "Power_Out_Percent": {"value": linear(buffer[0x0E], 1, 0), "unit": "%"},
        "Current_Out": {"value": iOut, "unit": "A"},
        "Voltage_Out": {"value": round(vOut, 1), "unit": "V"},
        "Voltage_In": {"value": round(vIn, 1), "unit": "V"},
        "Power_Out": {"value": round(wOut, 1), "unit": "W"},
        "Power_In": {"value": round(wIn, 1), "unit": "W"},
        "Energy_Out": {"value": round(power_current_kwh_out, 2), "unit": "kWh"},
        "Energy_In": {"value": round(power_current_kwh_in, 2), "unit": "kWh"},
        "Temperature": {"value": linear(buffer[0x0F], 1, 0), "unit": "C"},
        "Battery_State": {"value": linear(buffer[0x08], 0.392, 0), "unit": "%"},
        "Battery_Voltage": {"value": linear(buffer[0x0B], 0.0671, 0), "unit": "V"},
        "Frequency": {"value": linear(buffer[0x18], -0.1152, 65), "unit": "Hz"},
    }

    return payload

Tentei essa Baud Rate de 2560 para o meu EasyPro mas infelizmente não adiantou. :frowning:

Continuando os estudos, achei nos aquivos do programa deles pra ruindows um xml que parece ter informares sobre endereçamento dos modelos.

Consegui os itens que eu mais queria

segue json pra quem tiver o ONE UP 2000 NITRO TI

[{"id":"537ff01a.d5694","type":"tab","label":"Ragtech Serial","disabled":false,"info":""},{"id":"44db0922d68e743c","type":"serial in","z":"537ff01a.d5694","name":"Ragtech","serial":"9b6c3c03.9253f","x":160,"y":660,"wires":[["759d1abb8ff48d3e","7e50e59b048c9e5f","d9fe51c95bd00e49","b51abc5ae6f768ac","c1ce722a1365464a","4ae839eb57b67127","8772a7fa9da5324f"]]},{"id":"cd434a7afe7b4320","type":"debug","z":"537ff01a.d5694","name":"debug Serial IN","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":820,"wires":[]},{"id":"e748060a380d9238","type":"inject","z":"537ff01a.d5694","name":"Request Data","props":[],"repeat":"10","crontab":"","once":false,"onceDelay":"1","topic":"","x":200,"y":80,"wires":[["0891718b676f7017"]]},{"id":"730f09a1629f5e24","type":"serial out","z":"537ff01a.d5694","name":"OUT","serial":"9b6c3c03.9253f","x":850,"y":80,"wires":[]},{"id":"0d05915730b253bb","type":"debug","z":"537ff01a.d5694","name":"debug OUT","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":180,"wires":[]},{"id":"0891718b676f7017","type":"function","z":"537ff01a.d5694","name":"Request INFO","func":"//PEDE STATS\nmsg.payload = Buffer.from(\"AA0400801E9E\", \"hex\")\nreturn msg;\n\n\n//PEDE STATS\n//msg.payload = Buffer.from(\"AA0400F301F4AA0401360138AA0402020206AA0400801E9E\", \"hex\")\n//return msg;\n\n\n//PEDE STATS\n//msg.payload = Buffer.from(\"AA0400F301F4\", \"hex\")\n//return msg;\n\n\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":80,"wires":[["730f09a1629f5e24","0d05915730b253bb"]]},{"id":"759d1abb8ff48d3e","type":"function","z":"537ff01a.d5694","name":"toHexString","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join(' ');\n};\n\nvar hexString = toHexString(msg.payload);\nmsg.payload = hexString;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":820,"wires":[["cd434a7afe7b4320"]]},{"id":"322f07daf1db6edb","type":"function","z":"537ff01a.d5694","name":"Primeiro Comando","func":"msg.payload = Buffer.from(\"A004FFE0088B\", \"hex\")\n//msg.payload = Buffer.from(\"FFFE008E018F\", \"hex\")\n//msg.payload = Buffer.from(\"AA0400801E9E\", \"hex\")\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":180,"wires":[["730f09a1629f5e24","0d05915730b253bb"]]},{"id":"b5c1fc1459a82dbc","type":"inject","z":"537ff01a.d5694","name":"Request Data","props":[],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","x":190,"y":180,"wires":[["322f07daf1db6edb"]]},{"id":"0a6f018e6e9854e3","type":"function","z":"537ff01a.d5694","name":"Segundo Comando","func":"msg.payload = Buffer.from(\"FFFE008E018F\", \"hex\")\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":260,"wires":[["0d05915730b253bb","730f09a1629f5e24"]]},{"id":"59c66a451c6dfe49","type":"inject","z":"537ff01a.d5694","name":"Request Data","props":[],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","x":190,"y":260,"wires":[["0a6f018e6e9854e3"]]},{"id":"7e50e59b048c9e5f","type":"function","z":"537ff01a.d5694","name":"getInputVoltage","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\n\nvar hexString = toHexString(msg.payload);\nvar temp = '0x' + hexString.substring(52, 54)\n//let inputVoltage = parseInt(temp, 16);\nlet inputVoltage = Math.round(parseInt(temp, 16)*1.06);\n  msg.payload = inputVoltage;\n  return msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":540,"wires":[["dac93a4d6c919bcb"]]},{"id":"d9fe51c95bd00e49","type":"function","z":"537ff01a.d5694","name":"getBattery","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\n\nvar hexString = toHexString(msg.payload);\n\nif (hexString.length == 62) {\n\n  var temp = '0x'+ hexString.substring(16,18)\n\n  //let batteryPercent = Math.round(parseInt(temp, 16)/2.55);\n  let batteryPercent = Math.round(parseInt(temp, 16)*0.393);\n\n  msg.payload = batteryPercent;\n  return msg;\n}\nelse {\n  return null;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":460,"wires":[["17b257f53136ef2e"]]},{"id":"b51abc5ae6f768ac","type":"function","z":"537ff01a.d5694","name":"getTemperature","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\n\n\nvar hexString = toHexString(msg.payload);\n\n\n\n  var temp = '0x'+ hexString.substring(30,32)\n\n  let temperature = parseInt(temp, 16);\n\n\n  msg.payload = temperature;\n  return msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":400,"wires":[["3ed2074b50a6439a"]]},{"id":"3ed2074b50a6439a","type":"ha-sensor","z":"537ff01a.d5694","name":"Ragtech Temperature","entityConfig":"5f030e19c85b66d7","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":740,"y":400,"wires":[[]]},{"id":"17b257f53136ef2e","type":"ha-sensor","z":"537ff01a.d5694","name":"Ragtech Battery","entityConfig":"da00fe0c0350830d","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":720,"y":460,"wires":[[]]},{"id":"dac93a4d6c919bcb","type":"ha-sensor","z":"537ff01a.d5694","name":"Ragtech Input Voltage","entityConfig":"a34e73146ca8b897","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":740,"y":540,"wires":[[]]},{"id":"c1ce722a1365464a","type":"function","z":"537ff01a.d5694","name":"getTeste","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\n\n\nvar hexString = toHexString(msg.payload);\n\n\n\n var temp = '0x'+ hexString.substring(28,30)\n\n  let temperature = parseInt(temp, 16);\n\n\n  msg.payload = temp;\n  return msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":1000,"wires":[["418807feb13bb145"]]},{"id":"418807feb13bb145","type":"ha-sensor","z":"537ff01a.d5694","name":"Ragtech Teste","entityConfig":"57a31147943cc3b6","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":720,"y":1000,"wires":[[]]},{"id":"4ae839eb57b67127","type":"function","z":"537ff01a.d5694","name":"getOutVoltage","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\n\n\nvar hexString = toHexString(msg.payload);\n\n\n\n  var temp = '0x'+ hexString.substring(60, 62)\n\n  let outVoltage = Math.round(parseInt(temp, 16)*0.5550);\nmsg.payload = outVoltage;\n  return msg;\n\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":620,"wires":[["12a472e16b9138cf"]]},{"id":"12a472e16b9138cf","type":"ha-sensor","z":"537ff01a.d5694","name":"Ragtech Out Voltage","entityConfig":"8aec9f766229732d","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":740,"y":620,"wires":[[]]},{"id":"8772a7fa9da5324f","type":"function","z":"537ff01a.d5694","name":"getUsagePencentage","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\n\n\nvar hexString = toHexString(msg.payload);\n\n\n\n var temp = '0x'+ hexString.substring(28,30)\n\n  let temperature = parseInt(temp, 16);\n\n\n  msg.payload = temperature;\n  return msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":700,"wires":[["1edc820a0a5c19c2"]]},{"id":"1edc820a0a5c19c2","type":"ha-sensor","z":"537ff01a.d5694","name":"Ragtech Usage Pencentage","entityConfig":"578928f3c679cd5c","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":760,"y":700,"wires":[[]]},{"id":"9b6c3c03.9253f","type":"serial-port","name":"Ragtech","serialport":"/dev/serial/by-id/usb-Ragtech_Sistemas_de_Energia_USB_Serial_Port-if00","serialbaud":"2560","databits":"8","parity":"none","stopbits":"1","waitfor":"0xaa","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"2000","bin":"bin","out":"time","addchar":"","responsetimeout":"5000"},{"id":"5f030e19c85b66d7","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Temperature","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Temperature"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"temperature"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"da00fe0c0350830d","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Battery","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Battery"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"battery"},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"a34e73146ca8b897","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Tensao de Entrada","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Tensao de Entrada"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"voltage"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"57a31147943cc3b6","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"TESTE","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":""},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"8aec9f766229732d","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Out Voltage","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Tensao de Saida"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"voltage"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"578928f3c679cd5c","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Usage Pencentage","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Usage Pencentage"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"9074df74.a057","type":"server","name":"Home Assistant","addon":true}]

ate

Meus amigos, graças a troca de conhecimento dos senhores e com uma forcinha da IA Deepseek (porque eu não manjo nada de programação :sweat_smile:), finalmente consegui comunicar com o meu EasyPro 2000 também. :tada::tada::tada::tada:

No meu caso eu só consegui depois de monitorar a porta serial também enquanto comunicava ele com o software Supervise. Nisso a Deepseek me mostrou que o Request para o meu No-break era na verdade “AA0400801E9E”, que o Baud Rate era 2560 e que precisava aumentar o timeout para 20000ms, porque meu No-break aparentemente é mais lento para responder.

Segue aí o JSON do meu para quem eventualmente precisar:

[{"id":"030623897a882b69","type":"tab","label":"Ragtech Serial","disabled":false,"info":""},{"id":"c8cc45365e0b38b3","type":"serial in","z":"030623897a882b69","name":"Ragtech","serial":"9b6c3c03.9253f","x":160,"y":660,"wires":[["3bf5365c5bd6c267","8cd0e341a2bb65d5","2e89f878d2897c7a","7bc1c3af92f1a013","90489703016e8723","d3e62b1c72af5918","338e985940a39b62"]]},{"id":"2e157b754229cc93","type":"debug","z":"030623897a882b69","name":"debug Serial IN","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":820,"wires":[]},{"id":"73c03a8db29c12e7","type":"inject","z":"030623897a882b69","name":"Request Data","props":[],"repeat":"10","crontab":"","once":false,"onceDelay":"1","topic":"","x":200,"y":80,"wires":[["659ba28b3498c59c"]]},{"id":"87aa8b9d0e5c0051","type":"serial out","z":"030623897a882b69","name":"OUT","serial":"9b6c3c03.9253f","x":850,"y":80,"wires":[]},{"id":"01aec16e8c22af5d","type":"debug","z":"030623897a882b69","name":"debug OUT","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":180,"wires":[]},{"id":"659ba28b3498c59c","type":"function","z":"030623897a882b69","name":"Request INFO","func":"msg.payload = Buffer.from(\"AA0400801E9E\", \"hex\");\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":80,"wires":[["87aa8b9d0e5c0051","01aec16e8c22af5d"]]},{"id":"3bf5365c5bd6c267","type":"function","z":"030623897a882b69","name":"toHexString","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join(' ');\n};\nvar hexString = toHexString(msg.payload);\nmsg.payload = hexString;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":820,"wires":[["2e157b754229cc93"]]},{"id":"8cd0e341a2bb65d5","type":"function","z":"030623897a882b69","name":"getInputVoltage","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\nvar hexString = toHexString(msg.payload);\nif (hexString.startsWith(\"aa21\") && hexString.length >= 62) {\n  var temp = '0x' + hexString.substring(52, 54);\n  let inputVoltage = Math.round(parseInt(temp, 16) * 1.06);\n  msg.payload = inputVoltage;\n  return msg;\n} else {\n  return null;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":540,"wires":[["4c0ced3ce126ad64"]]},{"id":"2e89f878d2897c7a","type":"function","z":"030623897a882b69","name":"getBattery","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\nvar hexString = toHexString(msg.payload);\nif (hexString.startsWith(\"aa21\") && hexString.length >= 62) {\n  var temp = '0x' + hexString.substring(16, 18);\n  let batteryPercent = Math.round(parseInt(temp, 16) * 0.393);\n  msg.payload = batteryPercent;\n  return msg;\n} else {\n  return null;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":460,"wires":[["d235792934695972"]]},{"id":"7bc1c3af92f1a013","type":"function","z":"030623897a882b69","name":"getTemperature","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\nvar hexString = toHexString(msg.payload);\nif (hexString.startsWith(\"aa21\") && hexString.length >= 62) {\n  var temp = '0x' + hexString.substring(30, 32);\n  let temperature = parseInt(temp, 16);\n  msg.payload = temperature;\n  return msg;\n} else {\n  return null;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":400,"wires":[["df956f7c1fc648fc"]]},{"id":"df956f7c1fc648fc","type":"ha-sensor","z":"030623897a882b69","name":"Ragtech Temperature","entityConfig":"5f030e19c85b66d7","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":740,"y":400,"wires":[[]]},{"id":"d235792934695972","type":"ha-sensor","z":"030623897a882b69","name":"Ragtech Battery","entityConfig":"da00fe0c0350830d","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":720,"y":460,"wires":[[]]},{"id":"4c0ced3ce126ad64","type":"ha-sensor","z":"030623897a882b69","name":"Ragtech Input Voltage","entityConfig":"e359e4d04b90f4e3","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":740,"y":540,"wires":[[]]},{"id":"90489703016e8723","type":"function","z":"030623897a882b69","name":"getTeste","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\nvar hexString = toHexString(msg.payload);\nif (hexString.startsWith(\"aa21\") && hexString.length >= 62) {\n  var temp = '0x' + hexString.substring(28, 30);\n  msg.payload = temp;\n  return msg;\n} else {\n  return null;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":1000,"wires":[["aac12c86b09e8c5d"]]},{"id":"aac12c86b09e8c5d","type":"ha-sensor","z":"030623897a882b69","name":"Ragtech Teste","entityConfig":"4f2a6c9c7892e824","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":720,"y":1000,"wires":[[]]},{"id":"d3e62b1c72af5918","type":"function","z":"030623897a882b69","name":"getOutVoltage","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\nvar hexString = toHexString(msg.payload);\nif (hexString.startsWith(\"aa21\") && hexString.length >= 62) {\n  var temp = '0x' + hexString.substring(60, 62);\n  let outVoltage = Math.round(parseInt(temp, 16) * 0.5550);\n  msg.payload = outVoltage;\n  return msg;\n} else {\n  return null;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":620,"wires":[["d8f4e54a8e7dc92a"]]},{"id":"d8f4e54a8e7dc92a","type":"ha-sensor","z":"030623897a882b69","name":"Ragtech Out Voltage","entityConfig":"9bd637719773872a","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":740,"y":620,"wires":[[]]},{"id":"338e985940a39b62","type":"function","z":"030623897a882b69","name":"getUsagePencentage","func":"const toHexString = (bytes) => {\n  return Array.from(bytes, (byte) => {\n    return ('0' + (byte & 0xff).toString(16)).slice(-2);\n  }).join('');\n};\nvar hexString = toHexString(msg.payload);\nif (hexString.startsWith(\"aa21\") && hexString.length >= 62) {\n  var temp = '0x' + hexString.substring(28, 30);\n  let usagePercent = parseInt(temp, 16);\n  msg.payload = usagePercent;\n  return msg;\n} else {\n  return null;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":700,"wires":[["da96f6cb2d1999c0"]]},{"id":"da96f6cb2d1999c0","type":"ha-sensor","z":"030623897a882b69","name":"Ragtech Usage Pencentage","entityConfig":"78667b32f0121597","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":760,"y":700,"wires":[[]]},{"id":"9b6c3c03.9253f","type":"serial-port","name":"Ragtech","serialport":"/dev/serial/by-id/usb-Ragtech_Sistemas_de_Energia_USB_Serial_Port-if00","serialbaud":"2560","databits":"8","parity":"none","stopbits":"1","waitfor":"0xaa","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"2000","bin":"bin","out":"time","addchar":"","responsetimeout":"5000"},{"id":"5f030e19c85b66d7","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Temperature","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Temperature"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"temperature"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"da00fe0c0350830d","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Battery","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Battery"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"battery"},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"e359e4d04b90f4e3","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Tensao de Entrada","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Tensao de Entrada"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"voltage"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"4f2a6c9c7892e824","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"TESTE","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":""},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"9bd637719773872a","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Out Voltage","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Tensao de Saida"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"voltage"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"78667b32f0121597","type":"ha-entity-config","server":"9074df74.a057","deviceConfig":"","name":"Ragtech Usage Pencentage","version":6,"entityType":"sensor","haConfig":[{"property":"name","value":"Ragtech Usage Pencentage"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"9074df74.a057","type":"server","name":"Home Assistant","addon":true}]