Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Control ventilation only with presets #172

Merged
merged 2 commits into from
Apr 30, 2023
Merged

Control ventilation only with presets #172

merged 2 commits into from
Apr 30, 2023

Conversation

wlouckx
Copy link
Contributor

@wlouckx wlouckx commented Apr 29, 2023

Goal

  • Use all pre defined ventilation speeds set in the heat pump

Changes

  • Removes "set speed" feature
  • Adds 5 speed modes (Normal + 1..4) as presets

Result

image

Extra info

I was having trouble with setting the different ventilation speed modes with this integration for my F470, and came up with this solution.

Reading #17 (comment) got me thinking it should be possible to set those with the 47260 parameter
It seems that this commit elupus/nibeuplink@1ed805c changed the use of ventilation_boost to 47260 , which probably "broke" the code for the fan entity (SPEED_BOOST would now just select speed 1).

The changes in this pull request use the ventilation boost to select all 5 different speed modes, remove all percentage speed references, but adds the current speed percentage as an extra attribute..


An alternative approach would be to allow both ventilation_boost and 47260 params to be set separately in https://github.com/elupus/nibeuplink . Ventilation boost on my F470 sets speed 4 as shown below:
image
(don't mind the percentage, in my system this is configured as overpressure so exhaust speed is pretty low 😅 )

One could then configure speed 1, 2 and 3 as low, med, high, and Off would be "Normal". It could look then something more like below (but with a boost mode)
image


Note

This works on my F470. I have no idea on how universal this is for other Nibe systems

@elupus
Copy link
Owner

elupus commented Apr 29, 2023

I dont follow. If you sant the speeds, you should make sure the set percentage works.

@wlouckx
Copy link
Contributor Author

wlouckx commented Apr 29, 2023

Nibe in general does not allow to set speed percentage. It basically only allows to set normal or 4 pre defined presets (which go back to normal after the configured return time)

Currently it's configured the fan entity from home assistant with feature SET_SPEED but setting speed throws NotImplementedError("Can't set exact speed") so it actually can't set percentage speed.

Only allowing to read the speed makes the fan card a bit useless.

My change removes the whole unusable set speed, but exposes all the presets returned from Nibe, giving you full control over your ventilation, rather than just having a speed boost mode setting speed 1.

The alternative approach I mentioned is something I didn't include in the code of this pull requests as this requires changes in the other project. Just mentioned a food for thought.

@elupus
Copy link
Owner

elupus commented Apr 29, 2023

There are helpers in home assistant for converting from a percentage to a fixed set of speeds. Fans are expected to use that of they cant set specific speeds.

Look at: https://developers.home-assistant.io/docs/core/entity/fan/ in the converting speeds section.

@wlouckx
Copy link
Contributor Author

wlouckx commented Apr 29, 2023

I have tried that, you can have a go as well with it, but the slider doesn't make a lot of sense. Main problem with Nibe is that you can have following speed steps

  • 0 (default): 50%
  • 1: 30%
  • 2: 60%
  • 3: 100%
  • 4: 80%

The converting speed method home assistant provides is basically just dividing 100% into length of the list
https://github.com/home-assistant/core/blob/dev/homeassistant/util/percentage.py

During __init__ of the fan these speeds are not available yet (get_value returns None) so you can't make a sorted dictionary or lists at that point.

I think, as Nibe systems return to default speed after a certain time, they basically just have 1 fixed speed, and 4 "boost" modes. Hence it's more logical to return it the same way to the end user as well.

In my opinion the fan support from Home Assistant focussed too much on percentages, which doesn't suit the way Nibe implemented their ventilation speed control.

fan.py Outdated
if (value := self.get_value(self._ventilation.fan_speed)) is not None:
return int(value)
return None

Copy link
Owner

@elupus elupus Apr 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to remove the current speed? Can't that still remain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to remove that part but we would then need to re-enable the SET_SPEED feature in supported_features , otherwise Home Assistant never calls the property percentage

https://github.com/elupus/hass_nibe/pull/172/files#diff-f81efb969b5fcdd4d2e256c1698433e68971e9a3f47d0c7243e23b00467fdceaL140-R130

This is why I added data["fan_speed"] = self.get_raw(self._ventilation.fan_speed) in extra_state_attributes to give the user an entity to read the fan speed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Please leave the percentage anyway. I might see of i can get that changed in core so that percentage is available even if we cant set the speed.

Copy link
Contributor Author

@wlouckx wlouckx Apr 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with f5a2c8a

edit:
Or let me know if you also want back the SET_SPEED option and async_set_percentage back :) .

@elupus
Copy link
Owner

elupus commented Apr 30, 2023

I wonder of the fan entity have gotten support for state attribute translation in frontend yet. If so we should probably make use of that. If so the presets need to be named differently. But we can do that later.

@elupus elupus merged commit f930d77 into elupus:master Apr 30, 2023
@wlouckx
Copy link
Contributor Author

wlouckx commented Apr 30, 2023

Climate does have state translations it seems, maybe it's another way to implement the ventilation with the fan modes of the climate control:
https://developers.home-assistant.io/docs/core/entity/climate
https://developers.home-assistant.io/docs/internationalization/core#entity-attribute-name-and-state-of-entity-components

I'll fiddle around with it in the next few days/weeks and let you know if I come up with something.

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

Successfully merging this pull request may close these issues.

2 participants