CyberDNS / Lupusec2Mqtt

Lupusec Alarm System to Mqtt
MIT License
11 stars 6 forks source link

Update to version 3.1 | "unable to translate bytes" error #57

Closed christophgasser closed 1 year ago

christophgasser commented 1 year ago

I did the update to 3.1 and now the add-on is crashing with that error message:

Homeassistant config file path is /data/options.json [17:41:52 INF] Lupusec2Mqtt is starting up... [17:41:55 ERR] Error calling POST https://x.x.x.x/action/deviceGet: Request: Method: POST, RequestUri: 'https://10.16.11.11/action/deviceGet', Version: 1.1, Content: , Headers: { Accept: application/json Authorization: Basic X-Token: } System.Text.DecoderFallbackException: Unable to translate bytes [81] at index 835 from specified code page to Unicode. at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index) at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index) at System.Text.Encoding.GetCharsWithFallback(ReadOnlySpan1 bytes, Int32 originalBytesLength, Span1 chars, Int32 originalCharsLength, DecoderNLS decoder) at System.Text.UTF8Encoding.GetCharsWithFallback(ReadOnlySpan1 bytes, Int32 originalBytesLength, Span1 chars, Int32 originalCharsLength, DecoderNLS decoder) at System.Text.Encoding.GetCharsWithFallback(Byte pOriginalBytes, Int32 originalByteCount, Char pOriginalChars, Int32 originalCharCount, Int32 bytesConsumedSoFar, Int32 charsWrittenSoFar, DecoderNLS decoder) at System.Text.Encoding.GetChars(Byte pBytes, Int32 byteCount, Char pChars, Int32 charCount, DecoderNLS decoder) at System.Text.DecoderNLS.GetChars(Byte bytes, Int32 byteCount, Char chars, Int32 charCount, Boolean flush) at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex, Boolean flush) at System.IO.StreamReader.ReadBuffer(Span1 userBuffer, Boolean& readToUserBuffer) at System.IO.StreamReader.ReadSpan(Span1 buffer) at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count) at Newtonsoft.Json.JsonTextReader.ParsePostValue(Boolean ignoreComments) at Newtonsoft.Json.JsonTextReader.Read() at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, Encoding effectiveEncoding, IFormatterLogger formatterLogger) at System.Net.Http.Formatting.JsonMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, Encoding effectiveEncoding, IFormatterLogger formatterLogger) at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger) at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger) --- End of stack trace from previous location --- at System.Net.Http.HttpContentExtensions.ReadAsAsyncCore[T](HttpContent content, Type type, IFormatterLogger formatterLogger, MediaTypeFormatter formatter, CancellationToken cancellationToken) at Lupusec2Mqtt.Lupusec.LupusecService.SendRequest[T](HttpRequestMessage request, LogLevel logLevel) in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/Lupusec/LupusecService.cs:line 148 [17:41:55 FTL] Host terminated unexpectedly System.NullReferenceException: Object reference not set to an instance of an object. at Lupusec2Mqtt.Mqtt.Homeassistant.Devices.CoverFactory.GenerateDevicesAsync() in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/Mqtt/Homeassistant/Devices/CoverFactory.cs:line 18 at Lupusec2Mqtt.MainLoop.GetDevices() in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/MainLoop.cs:line 130 at Lupusec2Mqtt.MainLoop.StartAsync(CancellationToken stoppingToken) in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/MainLoop.cs:line 44 at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) at Lupusec2Mqtt.Program.Main(String[] args) in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/Program.cs:line 34

I also uninstalled the add-on and installed it again. Problem persits. Any idea how to solve that?

BR C

CyberDNS commented 1 year ago

Hi Christoph,

I published a new version that logs the response message. Can you please upgrade to v3.1.1 on Edge and set the Logging Level to Verbose. Then when the addon crashes, you should see the message in the logs, copy and paste it here.

Best regards, David

christophgasser commented 1 year ago

How to install 3.1.1? For "Lupusec2Mqtt Edge" I can only see 3.1.0 which I have installed now.

For that version with "Vervose" I get this:

[21:20:37 FTL] Host terminated unexpectedly System.NullReferenceException: Object reference not set to an instance of an object. at Lupusec2Mqtt.Mqtt.Homeassistant.Devices.CoverFactory.GenerateDevicesAsync() in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/Mqtt/Homeassistant/Devices/CoverFactory.cs:line 18 at Lupusec2Mqtt.MainLoop.GetDevices() in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/MainLoop.cs:line 130 at Lupusec2Mqtt.MainLoop.StartAsync(CancellationToken stoppingToken) in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/MainLoop.cs:line 44 at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) at Lupusec2Mqtt.Program.Main(String[] args) in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/Program.cs:line 34

BR C

christophgasser commented 1 year ago

Update was available this morning.

I have added the content of the log in a textfile. l.txt

BR C

christophgasser commented 1 year ago

If I read the log correct there is an issue with the CoverFactory.cs . I do not have any covers connected with my XT2. because of that maybe one of this properties is empty: _lupusecService.SensorList2.Sensors

BR C

CyberDNS commented 1 year ago

Yes it is in the CoverFactory that the problem happens. CoverFactory is only the component that is responsible to create Cover objects if there are, in you case it is unfortunately in the part where it gathers the information about the devices that are registered on the Lupusec that crashes, this part is also called when no Covers are present (mainly to now that there are no covers present and it has nothing to generate).

I will have a look in the provided log file. What version of the Lupusec you have? XT1 / XT2 (Plus)..?

christophgasser commented 1 year ago

it is a XT2 Plus.

C

CyberDNS commented 1 year ago

I have checked your log file, but it does not contain a log of the response body of /action/deviceGet (the one that crashes).

I think that the log in the HA Addon UI is too short and you have to get it directly from the console. Can you connect to the console of your HA installation and do:

docker ps

Then search for the line that represents the lupusec2mqtt addon container. Copy the container id and do a:

docker logs [containerId]

Then provide me the results of the complete log please.

BR, David

christophgasser commented 1 year ago

Im am running HA on a virtual machine. OS 9.5 / COre 2023.3.1 I have no docker available. Running "docker ps" brings just "command not found".

Any other way to get the logs you need?

BR Christoph

christophgasser commented 1 year ago

Just for completeness: I am connected to HA via SSH using Putty usign user "root". BR C

CyberDNS commented 1 year ago

Ok I think you are SSHing into the running HA container but you have to SSH into your virtual machine (That's where your HA container is running on docker and also the addon containers are running there)

christophgasser commented 1 year ago

OK. Done that. "docker info" is working fine. but "docker ps" is not allowed. available commands available for docker are: info and registries.

CyberDNS commented 1 year ago

Probably you have to sudo the command

sudo docker ps
christophgasser commented 1 year ago

No. Already tried that. "Error while executing rootCmd: unknown command "sudo" for "ha"

CyberDNS commented 1 year ago

Ok I think you are now in the HA CLI. There you have to execute:

login

Then you are in the "real" linux shell. Then you can try docker ps.

christophgasser commented 1 year ago

Thank you. Got the log in a file. Just have to find a way to get it from that machine. I have no WPUT available as it seems. Any idea how to get the file of that machine?

CyberDNS commented 1 year ago

Is scp available? (ssh copy)

christophgasser commented 1 year ago

Yes, it is. I then need an SCP server, right?

christophgasser commented 1 year ago

I am now connected to the server using SCP. But my tmp folder in SCP is empty. But this is the folder I have put my log file into.

christophgasser commented 1 year ago

I guess these are the files of the docker container I can see. do you know how I can get the log file into the container?

CyberDNS commented 1 year ago

You can use docker cp commanf to do this.

christophgasser commented 1 year ago

which container is the correct one? hassio_supervisor?

image

CyberDNS commented 1 year ago

I think it is the one named homeassistant. (image name starts with qemux86...)

CyberDNS commented 1 year ago

Or it could be ssh or cli, I am not sure.

christophgasser commented 1 year ago

It was the SSH container. lupus.log

christophgasser commented 1 year ago

Thank you for your kind support!

CyberDNS commented 1 year ago

No problem, you're welcome. I will analyse the log and come back to you.

CyberDNS commented 1 year ago

I published just now a new version 3.1.2 that you can check out to see if it resolves the problem.

christophgasser commented 1 year ago

Working fine now. That fixed it. Thank you!!!