Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add preset mode: normal #70

Open
Silther opened this issue Sep 25, 2023 · 27 comments
Open

add preset mode: normal #70

Silther opened this issue Sep 25, 2023 · 27 comments

Comments

@Silther
Copy link
Contributor

Silther commented Sep 25, 2023

Option 1:
How can you deactivate the auto-Preset mode if you only have one preset?
(I don't want to adjust the speed but switch off the auto mode at the current speed)

Option 2: (preferred)
Add an normal or none preset mode to the Dyson Pure Cool Link or all fans.

The preset mode should also stay the same after you switch the device off and on again.

@Silther Silther mentioned this issue Sep 27, 2023
@dotvezz
Copy link
Member

dotvezz commented Sep 28, 2023

Hey, thanks for the post (And the PR!) and sorry for the slow followup! I'm not entirely sure I understand the ask here. Could you go into a bit more detail?

I'll go over and take a look at the PR too, but I'll try to keep discussion here to avoid confusion.

@dotvezz
Copy link
Member

dotvezz commented Sep 28, 2023

Aha, okay looking at the PR (and at Home Assistant) I see what you're getting at now. The code looks pretty good! There are a few details to address but overall I think this is pretty great.

I'll do some testing and make a PR onto your PR (It's turtles PRs all the way down). When we're happy with the result, we'll merge it in probably tomorrow!

For those details to address, I want to preface it with this: None of these are anything you should feel discouraged by. It's just details - your code itself is 👍 👍 .

  1. The /vendor/libdyson directory is actually a 1:1 copy of libdyson. Any changes in the Vendor directory should be paired with an identical PR on that other repository
    • This is a practice called "dependency vendoring" and it definitely has pros and cons. It helps here for us because (before I started vendoring libdyson) users of this integration frequently had issues with dependency version mismatches..
    • Normally this would mean your first PR is a twofer, but actually I don't think we'll need the changes in that libdyson.
  2. This block here makes perfect sense, but unfortunately it runs into limitations with Dyson's messaging.
    • The values on self.fan_mode here are actually coupled directly to the MQTT messaging.
    • Every message to/from Dyson devices limits you to four characters for things like sensor readings or mode settings.
      • This limitation is an arbitrary (and stupid confusing) decision made by Dyson.
    • Fortunately, we don't actually need to worry about this. I'm pretty sure we can use device.auto_mode == false to check for "normal" mode.

@Silther
Copy link
Contributor Author

Silther commented Sep 28, 2023

Are the devices then automatically updated to the latest version or do you have to do something manually in Home assistant?

@Silther
Copy link
Contributor Author

Silther commented Sep 28, 2023

how does the fan actually remember which mode he had before switching off?

@dotvezz
Copy link
Member

dotvezz commented Sep 28, 2023

Are the devices then automatically updated to the latest version or do you have to do something manually in Home assistant?

If you're asking "How do I update this integration?" then you'll need to update it with HACS. After I publish a new release in just a bit here, it can take up to two hour for HACS to detect the new version and give you an "update" button. But you can force it to re-check by restarting your Home Assistant instance.

Short version: You don't need to update the (Dyson) devices but you will need to manually press the "update" button for the Home Assistant Integration.

how does the fan actually remember which mode he had before switching off?

The fan itself has its own internal compute hardware and memory/storage. When you turn it on, it's more like a computer fast-rebooting than a fan simply turning on. I'm not sure what hardware it's running, but seems substantial enough as it has Wi-Fi, Bluetooth, an MQTT Broker, and processing for several sensors. I'd guess it's running something around the level of an ESP32.

Now I'm curious, maybe @Paul-McNeice might be able to enlighten us (if he's allowed to - this might be one of those industrial secret things).

@dotvezz
Copy link
Member

dotvezz commented Sep 28, 2023

Released v1.2.0, thanks for your contribution! This is one of those detailed quality-of-life things that really make the experience so much better.

Closing this issue, but feel free to keep discussing here in the thread if you want.

@dotvezz dotvezz closed this as completed Sep 28, 2023
@Silther
Copy link
Contributor Author

Silther commented Sep 28, 2023

I just received the update, looks like all is working.

@Silther
Copy link
Contributor Author

Silther commented Sep 28, 2023

how does the fan actually remember which mode he had before switching off?

It looks like this part is not working yet.
The mode is set to normal when the device is switched off and it seems to forget in which mode it was.

via Dyson Remote

Via.Dyson.Remote.mp4

via Home Assistant

via.Home.Assistant.mp4

@dotvezz
Copy link
Member

dotvezz commented Sep 28, 2023

@Silther interesting! Looks like when we send a power-on command, we're also overriding the device's internal state. This'll probably be a small fix but might take some funky debugging to find the problem.

If you want to take a stab at it, here's some guidance I can provide: This will probably need to be implemented in the libdyson repo. But I'll try to get to debugging it later tonight to get a clearer picture of what's happening.

Reopening this issue to track it.

@dotvezz dotvezz reopened this Sep 28, 2023
@Silther
Copy link
Contributor Author

Silther commented Sep 28, 2023

If you want to take a stab at it

I would like to, but since I am currently between exams, I do not have enough time.

@dotvezz
Copy link
Member

dotvezz commented Sep 28, 2023

Lol no worries. Exams come first.

@Silther Silther changed the title Deactivate preset mode or add preset mode normal add preset mode: normal Nov 8, 2023
@tetra-fox
Copy link

When using the HomeKit Bridge integration, the Auto and Normal toggles are added to Apple Home as switches, grouped together. Previously, the auto/manual toggle was exposed to Apple Home as an accessory property, enabling easier control with Siri and reducing clutter in the Home app.
While I recognize that preferences may vary, I prefer the previous behavior primarily because Apple Home is my home control app of choice, not Home Assistant. I'm curious whether it might be possible to introduce a setting that allows users to customize this behavior on a per-device basis.

Current Pre 1.2.0

@Silther
Copy link
Contributor Author

Silther commented Nov 16, 2023

Could you add a screenshot also showing the current settings page?

And why is there a small icon switch inside of the right switch? It looks pretty strang to me.

@Silther
Copy link
Contributor Author

Silther commented Nov 16, 2023

Have you searched for similar bugs reports in the himekit bridge github?

I looks pretty strange to me, that homekit showed you an additional manuel fanmode toggle even if there hasn't been one implemented.
You have a dyson pure cool link right?

EDITt: I just saw that you have an humidify, this device shoud not even be affected be the changes I made.

@tetra-fox
Copy link

I have an older model, a Pure Humidify+Cool Cryptomic (PH02).

homekit showed you an additional manuel fanmode toggle even if there hasn't been one implemented

Not sure how exactly your implementation works, but the auto/manual toggle pre-1.2.0 does actually work and the changes introduced in 1.2.0 caused that toggle to disappear from the accessory settings page. In its place exists two extra switches called "Auto" and "Normal" which do the same thing, just less elegantly, see below:

These switches are automatically grouped together into one page, that's what the first screenshot is in my original post

And this is what the settings page for the fan accessory looks like running ha-dyson 1.3.2 (notice the missing auto/manual toggle)

Have you searched for similar bugs reports in the himekit bridge github?

I did, but unfortunately it seems that I might be the first to experience this. (or maybe I'm not good at searching github issues lol)
I don't really think this is a bug per se, rather a variation in how Home Assistant handles certain device properties when exporting to HomeKit.

@Silther
Copy link
Contributor Author

Silther commented Nov 17, 2023

In its place exists two extra switches called "Auto" and "Normal" which do the same thing, just less elegantly, see below:

What happens if you switch both of them off?

@tetra-fox
Copy link

tetra-fox commented Dec 22, 2023

Nothing happens to my Dyson fan, it just eventually turns whichever switch was on last back on. Turning one on turns off the other, and an invalid state (both off) just reverts the virtual HomeKit switches. This is how Home Assistant exports presets to HomeKit it seems, similar to how input_selects are exported to HomeKit.

@klaptafel
Copy link

klaptafel commented Jan 4, 2024

When using the HomeKit Bridge integration, the Auto and Normal toggles are added to Apple Home as switches, grouped together. Previously, the auto/manual toggle was exposed to Apple Home as an accessory property, enabling easier control with Siri and reducing clutter in the Home app. While I recognize that preferences may vary, I prefer the previous behavior primarily because Apple Home is my home control app of choice, not Home Assistant. I'm curious whether it might be possible to introduce a setting that allows users to customize this behavior on a per-device basis.

Current Pre 1.2.0

Just migrated from shenxn/ha-dyson to libdyson-wg/ha-dyson and this is the first thing I noticed as well. I also prefer the 'old' way.

@Silther
Copy link
Contributor Author

Silther commented Jan 4, 2024

Thats seems to be a limitation of homekit, as they do not support fan modes. Documentation

Could you upload a video how the old switches worked?

@Silther
Copy link
Contributor Author

Silther commented Jan 4, 2024

Just migrated from shenxn/ha-dyson to libdyson-wg/ha-dyson and this is the first thing I noticed as well. I also prefer the 'old' way.

What dyson fan do you use?

@RefineryX
Copy link

RefineryX commented Jan 18, 2024

I came here to report the HomeKit behaviour and saw @tetra-fox post... thought I would post here instead of creating a new issue.

On the old Dyson Integration it shows like the below (which is my preference)

Screenshot 2024-01-18 at 20 30 59 Screenshot 2024-01-18 at 20 31 03




On the new integration, it appears like the below in three different tiles grouped together.

Screenshot 2024-01-18 at 20 32 32 Screenshot 2024-01-18 at 20 32 47 Screenshot 2024-01-18 at 20 32 57




On state
Screenshot 2024-01-18 at 20 44 39
Off state (though it appears to be shown as powered on because one of the switches are on - highlighted red - not sure what that switch does... nothing happens)
Screenshot 2024-01-18 at 20 43 41

Screenshot 2024-01-18 at 20 47 36

@Silther
Copy link
Contributor Author

Silther commented Jan 18, 2024

the thing is, that the home assistant users never had the switch between normal and auto, that is what I added. It seems that homkit just doesn't support preset modes

@Silther
Copy link
Contributor Author

Silther commented Jan 18, 2024

Screenshot 2024-01-18 at 20 32 47

what gets shown if you open the accessories tab?

@RefineryX
Copy link

what gets shown if you open the accessories tab?

image

@tetra-fox
Copy link

tetra-fox commented Jan 26, 2024

I did a quick bit of research and it looks like this behavior stems from the HomeKit integration, specifically these lines of code. When there is only one preset mode added to a fan entity, the HomeKit integration assumes it is the auto mode and adds it as a property, and when there are >1 preset modes they all just get added as switches.

However, it seems that this integration's implementation of preset modes is possibly incorrect, per the Fan Entity documentation.

Preset modes should not include named (manual) speed settings as these should be represented as percentages

and

If it is possible to set a percentage speed manually without disabling the preset mode, create a switch or service to represent the mode.

stick out to me specifically.

To elaborate, the first excerpt indicates to me that manual should not be a preset mode at all, as the manual preset essentially sets the fan speed percentage. The second excerpt suggests that because setting a percentage speed technically would not disable the manual preset, a switch or service should be created instead.

I'd be more than happy to assist with modifying the implementation to better align with the Home Assistant documentation.

@Silther
Copy link
Contributor Author

Silther commented Jan 26, 2024

However, it seems that this integration's implementation of preset modes is possibly incorrect, per the Fan Entity documentation.

I'm not sure if I read it correctly, but after the documantation it should show none instead of normal if automode is disabled?

@tetra-fox
Copy link

The documentation suggests that when no preset is selected (e.g., when auto mode is off), the preset_mode property of the fan should return None, not display "none". How the None is handled is up to whatever is getting the property, be it the Home Assistant frontend or the HomeKit integration.

The previous implementation seems more in line with the documentation:

@property
def preset_mode(self) -> Optional[str]:
"""Return the current selected preset mode."""
if self._device.auto_mode:
return PRESET_MODE_AUTO
return None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants