KiraPC / ha-switchbot-remote

A Custom HomeAssistant Integration to control Switchbot Hub
MIT License
54 stars 3 forks source link

Control Functions as Entites in Home Assistant #33

Closed LIrahara closed 8 months ago

LIrahara commented 9 months ago

Hi Kira,

This isn't much of an issue but more of a question. I'm having trouble getting the control functions for my AC to show up as usable entities in home assistant. Can this only be done through custom buttons, or is there a way to get the pre populated buttons to work?

I followed the naming conventions in the guide and they did show up in home assistant, but don't seem to be doing what they say. On and off just cause a beep like a command has been sent through but it doesn't switch off or anything.

Is there a guide for this anywhere?

Cheers

KiraPC commented 9 months ago

Hi @LIrahara I did not get you.

Could you please explain better, maybe attaching some screenshots of what you have on switchbot and what you would have in HomeAssistant, or what you already have.

Thanks

LIrahara commented 9 months ago

Yeah sure,

So in the first screen shot, it shows the buttons for control that have been automatically populated by switch bot on positive identification of the AC unit. I noted that these buttons have varying names and assumed that it would need to be added exactly in supported functions, which is what I did. The following 2 screen shots show where I am adding the buttons into home assistant. Once added into HA, and assigned to a button, they don't perform as expected. The unit does not turn off and turn on from HA. The AC unit does respond like it has accepted a command but it's like its a command for increasing the temp for example. It just double beeps and carries on running. When sending the off command I would expect a long beep and for it to stop running. It seems something is being lost in translation here. I might be doing something wrong.

Your guide indicates support for custom buttons. Is that the only way to achieve what I'm talking about or should I be able to do it with the pre populated ones as described above.

Hope that makes a bit more sense. Screenshot_20240220_174500_SwitchBot

Screenshot_20240220_174723_Home Assistant

Screenshot_20240220_174801_Home Assistant

Screenshot_20240220_174835_Home Assistant

Screenshot_20240220_174906_Home Assistant

KiraPC commented 9 months ago

Hi @LIrahara

Now it's clearest.

You should see your switchbot devices under the integration page under the configured hub.

LIrahara commented 9 months ago

So I'm doing everything right?

The functions are not working if I do it this way.

Do I need to make custom buttons repeating the functions? Like do I need to make my own ON button for this to work?

KiraPC commented 9 months ago

I don't know.

Do you see your configured device in the HA devices list?

Can you publish your HA screens?

Also logs would be helpful

LIrahara commented 8 months ago

Apologies Kira,

Have been out of the country. Ill be home in a few days and will tackle this. Its difficult if im not testing locally.

LIrahara commented 8 months ago

Hi Kira,

Okay so I did a bit of work today. I have a bunch of new hubs, so I just started from scratch. By the way, is there a way to clear hubs that are no longer used in the integration? I tried to delete and Reinstall but couldn't.

Anyways, So I added a hub, and set up the ac control. It works from the switchbot app interface as well as the prepopulated control interface on home assistant. So that's all happy days.

The issue comes in when trying to add the individual button as an entity in he assistant. Following what I put up previously, 1) Go to the switchbot app and note the name of the button which is case sensitive. Screenshot_20240308_153346_SwitchBot

2) Go to Home Assistant and go into the configuration of the AC control and add it into the button names Screenshot_20240308_153432_Home Assistant

3) Go into the new entity in Home Assistant and trigger it. Note the timestamp here. The ac does respond to a received command but it's not the off command and the unit keeps running. Screenshot_20240308_153524_Home Assistant

4) On checking the logs in the Switchbot app, it is confirmed that the Off command was not sent but rather a temp change and fan change and a few other ones. You can see this timestamp lines up with the one in Home Assistant. Screenshot_20240308_153608_SwitchBot

5) Knowing I can get a successful Off response from the ac unit using the control in the switch bot app, I went back and hit that button. AC turned off with no issue. Screenshot_20240308_153655_SwitchBot

6) The logs in the Switchbot app reflect the turn off command. This is obviously different from what was sent in the steps above, but just done as a confirmation. Screenshot_20240308_153727_SwitchBot

7) So looking at the logs, they hold case sensitive commands, which lines up with what your guide says and the newly noted "Turn off" in the log led me to believe that what's on the button may be incorrect so I went back and added another button in the Home Assistant config reflecting this. Screenshot_20240308_153759_Home Assistant

8) Tried hitting this new entity and again the correct command was not received by the ac unit. Screenshot_20240308_153834_Home Assistant

9) You can see this reflected in the Switchbot logs. Screenshot_20240308_153914_SwitchBot

Unsure what I'm doing wrong here. I feel like it might be something simple though.

KiraPC commented 8 months ago

Can you attach logs?

You can't remove hub from the integration you had to unlink them from your switchbot account.

LIrahara commented 8 months ago

Sorry, new to the home assistant scene.

I've enabled logging and debugging for the integration and filtered for the created "off" button shown in the screenshot below.

Is that what you need or are you chasing something else? I just found a log file in my phone also. That might be what you're chasing. Logging was not enabled for the tests I outlined in the previous post.

Screenshot_20240308_213907_Home Assistant error_log-2.txt

KiraPC commented 8 months ago

I analyzed the logs and it seems there is no issue when request is sending to the switchbot systems.

2024-03-08 21:34:00.951 DEBUG (SyncWorker_2) [custom_components.switchbotremote.client.remote] Sending command setAll
2024-03-08 21:34:00.952 DEBUG (SyncWorker_2) [custom_components.switchbotremote.client.remote] Command payload {'commandType': 'command', 'command': 'setAll', 'parameter': '28,2,1,on'}
2024-03-08 21:34:00.952 DEBUG (SyncWorker_2) [custom_components.switchbotremote.client.client] Calling service https://api.switch-bot.com/v1.1/devices/01-202403081452-14540302/commands
2024-03-08 21:34:02.190 DEBUG (SyncWorker_2) [custom_components.switchbotremote.client.client] Call service https://api.switch-bot.com/v1.1/devices/01-202403081452-14540302/commands OK
2024-03-08 21:34:06.531 DEBUG (SyncWorker_62) [custom_components.switchbotremote.client.remote] Sending command setAll
2024-03-08 21:34:06.531 DEBUG (SyncWorker_62) [custom_components.switchbotremote.client.remote] Command payload {'commandType': 'command', 'command': 'setAll', 'parameter': '19.0,2,1,on'}
2024-03-08 21:34:06.532 DEBUG (SyncWorker_62) [custom_components.switchbotremote.client.client] Calling service https://api.switch-bot.com/v1.1/devices/01-202403081452-14540302/commands
2024-03-08 21:34:07.713 DEBUG (SyncWorker_62) [custom_components.switchbotremote.client.client] Call service https://api.switch-bot.com/v1.1/devices/01-202403081452-14540302/commands OK
2024-03-08 21:35:02.526 DEBUG (SyncWorker_29) [custom_components.switchbotremote.client.remote] Sending command OFF
2024-03-08 21:35:02.527 DEBUG (SyncWorker_29) [custom_components.switchbotremote.client.remote] Command payload {'commandType': 'customize', 'command': 'OFF', 'parameter': 'default'}
2024-03-08 21:35:02.527 DEBUG (SyncWorker_29) [custom_components.switchbotremote.client.client] Calling service https://api.switch-bot.com/v1.1/devices/01-202403081452-14540302/commands
2024-03-08 21:35:03.925 DEBUG (SyncWorker_29) [custom_components.switchbotremote.client.client] Call service https://api.switch-bot.com/v1.1/devices/01-202403081452-14540302/commands OK

Also you confirm that from the switchbot app you can see the request sent by the integration. So I cannot help you more than this.

I'm sorry