Blind Tilt, after polling chnages to false position
Stofakiller2 opened this issue · 13 comments
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...
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...
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...
I found it now, and can repreduse it every time...
Eg
- from fully close to fully open via the SwitchBotMqttApp's Device configuration
- 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 :-)
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...
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?
- Whether the issue is reproduced when you execute test commands from the add-on's WEB UI.
- Whether the issue is reproduced with the direct operation of the MQTT device.
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.
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.
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...
I cant find anywhere, how to send at slidePosition with value, what is the syntax to eg send a json command?
@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?
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.
-
When a device is discovered by the add-on, the following topics are used to send and receive device configuration information (MQTT discovery data)
- Example Topic
homeassistant/button/btn_2_cmd_{deviceid}/config
- Example Payload
{ "payload_press": "action", "command_topic": "switchbot/{deviceid}/cmd", "command_template": "{\n \"CommandType\": \"command\",\n \"Command\": \"turnOff\",\n \"ParamName\": \"btn\",\n \"ParamValue\": \"{{value}}\"\n}", "name": "turnOff", "unique_id": "btn_2_cmd_{deviceid}", "object_id": "btn_2_cmd_{deviceid}", "device": { "identifiers": [ "{deviceid}" ], "name": "Curtain", "manufacturer": "SwitchBot", "model": "Curtain" }, "icon": "mdi:curtains-closed", "platform": "mqtt" }
- Example Topic
-
Notifications of status changes from the add-on to MQTT integration are sent and received with the following topics (Subscribed topics)
- Example Topic
switchbot/{deviceid}/status/both
switchbot/{deviceid}/attribute
- Example Payload
{ "deviceId": "{deviceid}", "deviceType": "Curtain", "calibrate": true, "group": false, "slidePosition": 99, "battery": 59 }
- Example Topic
-
Device command input from the MQTT integration to the add-on is sent and received in the following topics (Transmitted messages)
- Example Topic
switchbot/{deviceid}/cmd
- Example Payload
{ "CommandType": "command", "Command": "pause", "ParamName": "btn", "ParamValue": "action" }
- Example Topic
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.
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" }
I do not have the actual device, so there is some guesswork from the master definition.
- The actual MQTT payload can be verified by
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.
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
- Enter Direction (up or down)
{
"CommandType": "command",
"Command": "setPosition",
"ParamName": "direction",
"ParamValue": "up"
}
- Enter Position (0-100)
{
"CommandType": "command",
"Command": "setPosition",
"ParamName": "position",
"ParamValue": "50"
}
- Press the button
{
"CommandType": "command",
"Command": "setPosition",
"ParamName": "btn",
"ParamValue": "action"
}
I'll return to my old rest_command/api integration and close this case as not fixed...