hsakoh / switchbot-mqtt

SwitchBot MQTT Home Assistant add-on
MIT License
30 stars 1 forks source link

Blind Tilt, after polling chnages to false position #13

Closed Stofakiller2 closed 4 months ago

Stofakiller2 commented 5 months ago

Just installed this integration a couple of days ago... When fullyopen all my blinds open to normal fully open position (100), but when using polling they are turn back to slideposition 50, that is very annoying, and i can fully open them again, and when i press the polling button they go back to slideposition 50...

hsakoh commented 5 months ago

Thanks for the feedback.

I would like to try to improve but I do not have the actual device.

I would like to check the API input/output and the contents of the webhook. Please change the log level in the add-on settings to Trace, restart the add-on, and reproduce. After that, can you extract the logs that match the blind tilt device ID from the add-on logs and post them here?

Also, please hide the device ID when posting the logs.

I had no such problem with Curtain, which has a similar command system, so I thought Blind would work too...

Stofakiller2 commented 5 months ago

Thanks for your quick reply, I dont use webhook...

I'll try, but maybe, its just as simple as, fullyopen = 100 and when pooling it send then command to /2 = 50??? And the pooling should only retrieve data and not send data (of course it has to send a command to get the data), but not send any ajustment to the tilt of the blinds... I'll be back with some logs later :-)

Hmm, sometimes when polling i see a command in the logs instead of a status... I'll try to let it run by itself instead me pressing the polling all the time :-), Because it happens when it polling bye the PT value, i changed it from PT1H to PT10M and later to PT30M, so i'll try with the 10M again...

Stofakiller2 commented 5 months ago

I found it now, and can repreduse it every time... Eg

  1. from fully close to fully open via the SwitchBotMqttApp's Device configuration
  2. wait until it's fully open and via HA cover control press open again, then the blinds closes about 50% and in HA when its fully open it says it 50% open, and stays there even its closes to about 25%...

So it never gets then status its fully open... I know that blinds can get flullyclosed down and up I found out that i had used garage as device_class, i have now changed it to Blind, and will test again :-)

Stofakiller2 commented 5 months ago

Same result as above... It also happens, when i press blind open in HA, so i must be a bug i HA, or? I press the mqtt fullyopen button in your program twice...

hsakoh commented 5 months ago

I apologize for my incomplete understanding of the situation, but...

Are you using something like a cover.template integration to indirectly operate the MQTT devices? Like this: cover.template <-1-> MQTT Device <-2-> Switch Bot MQTT Add-on

Firstly, for problem isolation, could you please check the following two points?

The Blind Tilt device has the following four commands implemented: "setPosition, fullyOpen, closeUp, closeDown". Additionally, it has a manual polling button and an automatic polling feature.

Just by manually invoking the polling, it does not execute any commands as an MQTT device or add-on (in the part referred to as 2 above).

Could it be possible that the cover template is automatically invoking setPosition, etc., in response to status changes (in the part referred to as 1 above)?

As for how to use the cover.template integration, I think it would be better to solicit opinions in a discussion rather than in an issue.

hsakoh commented 5 months ago

For example, I have tried implementing a Light control panel in the past using the Template Light integration. #1

During the implementation, one issue that arose was that there are two values for things like color, brightness, and color temperature - the command input value and the device state. When a value was received (through polling or webhook) and assigned to the display, the control panel might interpret this as a change in the command input value and autonomously send a command.

This is due to a compatibility issue between the current MQTT device model, which involves a current value and command input, and the control panel integration in the template. This issue is yet to be resolved.

However, with ColorBulb, state changes are completed quickly. So unless operations are rushed, commands are not likely to be resent, making it practical to use.

For devices like curtains or blind tilts, it takes time to complete operations. If polling occurs during this time, I have speculated that problems may be occurring every time.

It would be great if we could create a template mechanism to suppress polling until the state change is completed.

stofakiller commented 4 months ago

I do the change of eg fullyopen/closedown after the blinds and polling are completed... So thats not the issue here... Its when the fullyopen button is pressed... i'll try to find What it sends In the logs...

Stofakiller2 commented 4 months ago

I cant find anywhere, how to send at slidePosition with value, what is the syntax to eg send a json command?

Stofakiller2 commented 4 months ago

@hsakoh When using your own commands/buttons in your program, i dont see anything sent via mqtt, but the response is via MQTT... It makes it difficulte to find out where the problem is... Why dont you use the mqtt to send data?

hsakoh commented 4 months ago

This add-on is for controlling SwitchBot devices via the SwitchBot API. The device is detected by the Home Assistant with MQTT integration.

When a device is operated on the Home Assistant, an MQTT message is sent and the add-on receives the MQTT message and calls the SwitchBot API. When the add-on gets information about the device via webhook or polling, it sends an MQTT message and updates the device status in the MQTT integration.

As shown above, add-ons and MQTT integration exchange information through MQTT topics, and add-ons operate and retrieve information from the actual device through SwitchBotAPI.

What is the MQTT message you are looking for?

When you say "When using your own commands/buttons in your program, i dont see anything sent via mqtt, but the response is via MQTT...", do you mean when the test button is operated on the Ingress (device configuration page)?

The test button on the Ingress (test page) is for testing API calls from the add-on to the SwitchBotAPI server, so it does not issue MQTT messages.

Stofakiller2 commented 4 months ago

Okay, makes sense :-) How do you send a payload with setPosition? I can fine send the btn commands, but since my blinds with your btn command closes them at bit, i wanna try with my own mqtt command to see where the poblem lies... Can you privide me an example?, i've tried different: { "CommandType": "command", "Command": "setPosition", "ParamName": "JoinSemiColon", "ParamValue": "down;0" }

hsakoh commented 4 months ago

I do not have the actual device, so there is some guesswork from the master definition.


The image pasted for reference is of a curtain. In Curtain's setPosition, three sensor types (number,select,text) and a button are detected with one command. image

When each input value is changed, the addon is notified of the value. When the button is pressed, the add-on actually calls the SwitchBotAPI.


For a blind tilt, this should look something like this To mimic device command operations on MQTT integration, we could do so by sending three messages as follows

Stofakiller2 commented 4 months ago

I'll return to my old rest_command/api integration and close this case as not fixed...