elupus / hass_nibe

Home Assistant Nibe Uplink Integration
184 stars 54 forks source link

Control ventilation only with presets #172

Closed wlouckx closed 1 year ago

wlouckx commented 1 year ago

Goal

Changes

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 https://github.com/elupus/hass_nibe/issues/17#issuecomment-515751011 got me thinking it should be possible to set those with the 47260 parameter It seems that this commit https://github.com/elupus/nibeuplink/commit/1ed805c6d4dd9706452fbae93ce639002d404250 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 commented 1 year ago

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

wlouckx commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

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.

elupus commented 1 year ago

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.

wlouckx commented 1 year ago

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.