KiraPC / ha-switchbot-remote

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

Fan is turning on when opening info panel in HA #49

Closed voydz closed 4 months ago

voydz commented 4 months ago

Hi,

I really appreciate your work on this, thanks!

Bildschirmfoto 2024-07-16 um 09 22 19

I noticed that the fan is turning on, when I open the detail panel of my fan entity. I have a Dyson AM-07 fan, it turns on when I am pressing the oscillation key on the remote.

I suppose somehow HA is sending/checking for the oscillation status and sending the command for it? Can this be fixed, so that no commands are sent a default state is assumed after a fresh setup/after HA is restarted. I know that with IR devices get out of sync, I have no issues with that. The current behavior is just not contributing to the situation. :)

Thank you very much. best regards

KiraPC commented 4 months ago

Hi @voydz

Sorry, but I don't get the point.

voydz commented 4 months ago

Hey @KiraPC

let me explain how to reproduce:

  1. Setup a fan using your HA component
  2. Click on the fan entity to open the dialog shown in my first post (the entity detail panel)

Expected result

Actual result

KiraPC commented 4 months ago

But this is not regarding the custom component but how HA works.

I did not manage the behavior of the HA button.

voydz commented 4 months ago

@KiraPC I assume HA is checking for the status of power and oscillation.

Could it be, that this is implemented in a way, so that the component is handling that as an input?

I see, that this might seem as a "HA problem" and nothing with your component. But its a usability thing, isn't it? I do not have this issue with other integrations and components. So it might seem to be a good idea to sort this out, so that your component handles it in a way, so that devices behave as expected don't you think?

UPDATE: Just had a look at the code, HA indeed seems to call a function which in turn calls send_command. That seems very weird. But I totally get you, there is no good way to detect and intercept that. Should this behavior at least be documented somewhere so that others do not stumble upon that?

KiraPC commented 4 months ago

@voydz I'm using this integration since an year ago and I never had a similar issue.

I have a lot component configured, including an A/C, and when I open the detail I never had this issue.

The core component is common for every device.

voydz commented 4 months ago

Yeah, sorry to bother. I do not know why it behaves like that. I can now definetly say that a swing/oscillate command is send after opening the detail. (Tested it with the fan being on. Starts/Stops to swing after opening the detail.)

I will resort to using every key with a custom button now, I guess.

KiraPC commented 4 months ago

I had a very quickly view into the code but as I remember there isn't any relationship between the "view detail action" and the "sending command"

I don't know if you know a little of coding concept, but events are what you generate when you click something.

There is no event fired to the custom component code when you click on the detail button.

So, I can assume this is not a custom component issue.

voydz commented 4 months ago

I had a very quickly view into the code but as I remember there isn't any relationship between the "view detail action" and the "sending command"

I don't know if you know a little of coding concept, but events are what you generate when you click something.

There is no event fired to the custom component code when you click on the detail button.

So, I can assume this is not a custom component issue.

Thanks for your time and looking into it. :)