twocolors / esphome-native-api

MIT License
5 stars 6 forks source link

Log missing in frameHelper #30

Closed Baldhor closed 10 months ago

Baldhor commented 10 months ago

I have an issue with one of my user, I end up with an exception in:

    buildMessage(messageId, bytes) {
        return pb[id_to_type[messageId]].deserializeBinary(bytes);
    }
2023-12-24T09:16:37.803Z [err] [ManagerDrivers] [Driver:esphome-wizard] [PhysicalDevice:vattenfall] [Client] Received an error: TypeError: Cannot read properties of undefined (reading 'deserializeBinary')
    at PlaintextFrameHelper.buildMessage (/app/node_modules/@2colors/esphome-native-api/lib/utils/frameHelper.js:37:42)
    at PlaintextFrameHelper.deserialize (/app/node_modules/@2colors/esphome-native-api/lib/utils/plaintextFrameHelper.js:45:30)
    at PlaintextFrameHelper.onData (/app/node_modules/@2colors/esphome-native-api/lib/utils/plaintextFrameHelper.js:55:36)
    at Socket.<anonymous> (/app/node_modules/@2colors/esphome-native-api/lib/utils/plaintextFrameHelper.js:7:47)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

I suppose the problem come from an unexpected message type. Possible to add a check + throw an exception including the messageId?

I can submit a pull request if needed.

twocolors commented 10 months ago

what message type received?

can show esphome config ?

Baldhor commented 10 months ago

I can ask the user for his ESPhome config. Currently, my main issue is I have no idea about the messageId received, the log is missing this information :)

twocolors commented 10 months ago

we need to think about how to do it correctly and beautifully

twocolors commented 10 months ago

try @2colors/esphome-native-api@1.2.9

Baldhor commented 10 months ago

Looking good, thank you. To be honest, I'm unsure how fast the "user" will respond ... (he didn't to my request of yaml file).

So I close for now.