CyberDNS / Lupusec2Mqtt

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

Write a state in XT2+ fails #83

Closed ocfu closed 1 month ago

ocfu commented 1 month ago

Hi,

I am trying to write a state (e.g. switch on/off of a switch), using the 'set' Mqtt topic of the device, e.g. publish the value "ON" to the topic "homeassistant/switch/lupusec/ZS_2b4001/set" using Mqtt Explorer.

It fails with the errors find below. It indicates an authorization issue: 401 (Unauthorized). However, reading the states works well (3s polling) and the XT2+ user is the "Expert" user, which has write access (I am using the same user in an ioBroker Lupusec adapter and read+write works) and in the Lupus App. Note: I have xxxx the Tokens here.

lupusec2mqtt runs in a docker container on a raspberry pi (cyberdns/lupusec2mqtt_hassaddon_armv7:3.1.4)

[12:02:38 ERR] Error calling GET https://192.168.178.41/: Request: Method: GET, RequestUri: 'https://192.168.178.41/', Version: 1.1, Content: , Headers: { Accept: application/json X-Token: xxxxxxxx } Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. at Newtonsoft.Json.JsonTextReader.ParseValue() at Newtonsoft.Json.JsonTextReader.Read() at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) at Lupusec2Mqtt.Lupusec.LupusecService.SendRequest[T](HttpRequestMessage request, LogLevel logLevel) in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/Lupusec/LupusecService.cs:line 166 [12:02:38 INF] Command homeassistant/switch/lupusec/ZS_2b4001/set of device ZS:2b4001 - Licht Carport executed with input ON [12:02:39 ERR] Error calling POST https://192.168.178.41/action/recordListGet: Request: Method: POST, RequestUri: 'https://192.168.178.41/action/recordListGet', Version: 1.1, Content: , Headers: { Accept: application/json Authorization: Basic xxxxxx X-Token: xxxxx } System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at Lupusec2Mqtt.Lupusec.LupusecService.SendRequest[T](HttpRequestMessage request, LogLevel logLevel) in /src/Lupusec2Mqtt/src/Lupusec2Mqtt/Lupusec/LupusecService.cs:line 166 [12:02:39 INF] Value for topic homeassistant/switch/lupusec/ZS_2b4001/state on device ZS:2b4001 - Licht Carport changed from OFF to ON [12:02:40 INF] Value for topic homeassistant/switch/lupusec/ZS_2b4001/state on device ZS:2b4001 - Licht Carport changed from ON to OFF

CyberDNS commented 1 month ago

Hi @ocfu,

This was an issue that was resolved in one of the last versions. Can you try upgrading to the version 3.3.5, please?

The it should work.

Best regards, David

ocfu commented 1 month ago

Hi David,

great, many thanks! Now it works. I somehow didn't saw not using the latest version, just copied the docker line from the readme.

BR Olaf

CyberDNS commented 1 month ago

Hi Olaf,

Glad to hear that it is working now. So I think I have to updat the readme to the last version 😉.

Br, David