frontend icon indicating copy to clipboard operation
frontend copied to clipboard

humidifier card: display the value of current humidity sensor

Open Shulyaka opened this issue 2 years ago • 1 comments

Proposed change

Add the possibility to configure the humidifier card to display the current humidity (along with the target humidity). I might need your advise on design considerations. The thing is that the position of current and target humidity is inversed when compared to current and target temperature on a thermostat card, which might lead to a confusion. At the same time if we swap the values, then it would appear inversed when the current_humidity_sensor is provided compared to when it is not provided. I am not sure which is worse.

изображение

Type of change

  • [ ] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [x] New feature (thank you!)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Example configuration

    cards:
      - type: humidifier
        entity: humidifier.demo_humidifier
        current_humidity_sensor: sensor.bedroom_humidity

Additional information

  • This PR fixes or closes issue:
  • This PR is related to issue or discussion:
  • Link to documentation pull request: home-assistant/home-assistant.io#25202

Checklist

  • [x] The code change is tested and works locally.
  • [x] There is no commented out code in this PR.
  • [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

Shulyaka avatar Dec 08 '22 14:12 Shulyaka

Very pleased to see this PR as it addresses the exact problem I've been having right now. Ideally, I would also like to see generic humidifier receive the option to report the current state of its own sensor too so perhaps we could pre-emptively ensure this card also checks for the existence of a current_humidity state fall back. So it first checks for the optional current_humidity_sensor entity, then falls back to a current_humidity state on the humidifier entity itself and finally to showing nothing as originally done so? :) This would match the current behaviour and naming conventions of climate entities, which report a current_temperature state when one is available :)

apbarratt avatar Dec 12 '22 14:12 apbarratt

Hi @matthiasdebaat

I might need your advice on this design.

  1. Should swap the current and target humidity to match the thermostat card?
  2. Should I leave it as it is now to match the humidifier card with no current humidity?
  3. Should I make an additional configuration option to allow user to chose? If yes, what should be the default?

Shulyaka avatar Dec 22 '22 15:12 Shulyaka

  1. Should swap the current and target humidity to match the thermostat card?
  2. Should I leave it as it is now to match the humidifier card with no current humidity?

My assumption is that if we ask our users it will be 50/50, mainly because people have to adapt to this change. So I would suggest follow the principle of making things consistent, in this case our thermostat card. When we can display the current value the big number is current and small number is target. When there isn't a current value we can keep it as is, since there is only a single value.

  1. Should I make an additional configuration option to allow user to chose? If yes, what should be the default?

No, adding this option makes it unnecessary difficult in my opinion.

matthiasdebaat avatar Dec 22 '22 16:12 matthiasdebaat

@matthiasdebaat

I've done the change. In the process I found some disadvantages I would like to note:

  1. The current humidity now has to be rounded, otherwise the value doesn't fit.
  2. I originally had an idea to open a more-info-dialog for the current_humidity_sensor, which is now not possible because now clicking on the current humidity now switches the humidifier on and off and there is no place to click for launching the more-info-dialog for the current_humidity_sensor.

Shulyaka avatar Dec 23 '22 16:12 Shulyaka

изображение

Shulyaka avatar Dec 23 '22 16:12 Shulyaka

Sorry for lack of feedback despite being on watch list. I like the work so far and think you're right to have the figured reversed to show target small and current large to match the thermostat cards. I've never had a need for the precision given from decimal points with humidity so I doubt it's something that would upset me in being missing (though doesn't the temperature card allow decimals on both values?). In your screenshot, I note the percentage symbol is missing on the smaller indicator, I'm not a fan of losing that to be honest. Looking forward to this being approved soon :) The more info option is a pain with the thermostat cards too, with it being hidden in the 3 dot menu. This would go back to my point that the humidifier device should provide this data too, but I understand your point that this sort of behaviour is being distanced from now :(

apbarratt avatar Jan 05 '23 12:01 apbarratt

The percentage sign is missing to mimic the thermostat card: image About the more-info-dialog: I originally had an idea to open the more-info dialog of the current humidity sensor (not the humidifier itself) on click to the current humidity value. But that only works if the target humidity is big and the current humidity is small. Yes, you are right, the thermostat card can handle decimals. But now we have the on/off button on the humidifier card so the decimals don't fit well. But I will try to play around. Also most consumer humidity sensors have accuracy +-3% anyway...

Shulyaka avatar Jan 08 '23 12:01 Shulyaka

Looks great! I've just found out after a few (too many) hours that the reason my MQTT humidifier isn't working, is because I was sending a numeric humidity state to it, when it wanted on/off - and realized the humidifiers have no record of the current humidity.

If possible, could this functionality also be added to MQTT humidifiers too please?

A few others have mentioned the same issue: https://community.home-assistant.io/t/make-humidifiers-show-up-the-same-as-thermostat-in-lovelace/427935/5

mewejo avatar Feb 02 '23 00:02 mewejo

It will work with every humidifier as long as the current humidity is a separate sensor and the card is configured to that sensor. In future I am going to try to fetch the sensors automatically if they are connected via device registry (not sure if that's possible yet) The reason the humidifier card looks different to the thermostat card is that the climate integration is not great to begin with, and repeating old mistakes is not the way forward. Even in this very PR you can see that I have to reduce functionality to make it look similar to the thermostat card.

Shulyaka avatar Feb 02 '23 07:02 Shulyaka

Please excuse my ignorance - thank you for explaining. :-)

mewejo avatar Feb 02 '23 09:02 mewejo

@apbarratt I've added the precision back: image

Shulyaka avatar Feb 24 '23 13:02 Shulyaka

Oh that's looking good, I like it :) And anyone who would prefer less precision could of course template an entity as required :)

apbarratt avatar Feb 24 '23 20:02 apbarratt

Does anyone know what is required to get this in front of the powers that be for review? It seems rude to tag someone directly but I'm going to go with the biggest contributer: @balloob in the hope that they can trigger whatever process is required. @Shulyaka I think has done the work required, but it seems to have gone quiet now. Is there a step we're missing in moving this forwards?

apbarratt avatar Mar 13 '23 11:03 apbarratt

@apbarratt I think humidifiers are just not that interesting

To draw some attention, let me announce that I have further plans for this card:

  1. Indication of whether the device is active or not. This is another useful feature that a thermostat card has. Already developed and tested locally, needs rebase, depends on this PR.
  2. Look up the device registry to pick up the current humidity sensor automatically. Did not research that yet, whether it is possible or not, but that also depends on this PR.

Shulyaka avatar Mar 31 '23 22:03 Shulyaka

I like the design, we should have consistent design with thermostat card 👍 I have a mixed felling about adding a current humidity sensor in the card config. We have multiple options :

  • add current_humidity attributes to humidifier (but it's required back-end update). There is discussion for this https://github.com/home-assistant/architecture/discussions/856
  • look up the device registry to current de humidity sensor automatically as you suggest.

piitaya avatar Apr 05 '23 09:04 piitaya

  1. I like the concept of sensors being separate entities rather than attributes.
  2. I am going to do it as a next step after this PR is merged. However the device registry is not available for entities that are not configured via config entries, such as generic_hygrostat, so I would prefer keeping the configuration option.

Shulyaka avatar Apr 05 '23 13:04 Shulyaka

@matthiasdebaat sorry to bother you, but could you take a look at this PR again please?

Shulyaka avatar Apr 23 '23 07:04 Shulyaka

Design looks good to me. Can't help you with the sensor vs. attribute topic though. If this blocks this PR, I would advise to bump this architecture discussion https://github.com/home-assistant/architecture/discussions/856 or open a Core PR.

matthiasdebaat avatar Apr 25 '23 09:04 matthiasdebaat

No, it is not blocking, the logic is clear, I am just looking for a way to finalize this PR to get it merged:)

Shulyaka avatar Apr 25 '23 13:04 Shulyaka

The design is accepted but not the implementation. If we merged this one, the climate card will received PRs to add custom sensor for temperature, humidifier and the card editor will become cluttered...

The current_humidity should be an humidifier attribute to be consistent with the climate entity with current_temperature. There is a architecture discussion for this. So it's blocking by a core architecture decision for now.

piitaya avatar Apr 25 '23 14:04 piitaya

There must be a misunderstanding because the climate and humidifier platforms are very different in the core, with humidifier being significantly more modern. Let me try to clarify that in the architecture discussion first.

Shulyaka avatar Apr 25 '23 15:04 Shulyaka

I will make the changes after https://github.com/home-assistant/core/pull/94874 However I will not be able to test it locally until the end of next week. Until that, I'll keep this PR a draft.

Shulyaka avatar Jun 21 '23 07:06 Shulyaka

I've made the changes. Now if the current humidity sensor is not explicitly configured, the current_humidity attribute is used to show the current humidity. However I am will not be able to test it until the end of next week.

Shulyaka avatar Jun 21 '23 09:06 Shulyaka

This PR is still in draft, are we waiting for something?

bramkragten avatar Jun 21 '23 14:06 bramkragten

Even though everything looks good, I am unable to test it right now, because I am not home. I made the changes blindly. This is the only reason it is draft.

Shulyaka avatar Jun 21 '23 14:06 Shulyaka

I think we might have to reconsider the order of the values, and always keep the setpoint the main value. This will prevent confusion, as this was always the case already, and aligns with the new more info design https://github.com/home-assistant/frontend/pull/17011

We should at least not swap the values based on if they are available I think.

bramkragten avatar Jun 26 '23 11:06 bramkragten

Swapped back.

Shulyaka avatar Jun 26 '23 13:06 Shulyaka

We postponed the humidifier more info dialog to next release because of UX/UI issues. Also, in the future, we could add an option to let the user choose the current or target as a main info : https://github.com/home-assistant/frontend/pull/17050

I will merge this PR and then create another to align this card with the thermostat card :

  • add 2 buttons at the button to turn on/turn off the humidifier
  • swap (again) the value. Target at the middle, current at the bottom.

So humidifier will have the same behavior as climate. Changing the thermostat card would have been too impactful for this release.

piitaya avatar Jun 27 '23 15:06 piitaya