frontend
frontend copied to clipboard
humidifier card: display the value of current humidity sensor
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:
- [x] Documentation added/updated for www.home-assistant.io
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 :)
Hi @matthiasdebaat
I might need your advice on this design.
- Should swap the current and target humidity to match the thermostat card?
- Should I leave it as it is now to match the humidifier card with no current humidity?
- Should I make an additional configuration option to allow user to chose? If yes, what should be the default?
- Should swap the current and target humidity to match the thermostat card?
- 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.
- 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
I've done the change. In the process I found some disadvantages I would like to note:
- The current humidity now has to be rounded, otherwise the value doesn't fit.
- 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.
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 :(
The percentage sign is missing to mimic the thermostat card:
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...
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
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.
Please excuse my ignorance - thank you for explaining. :-)
@apbarratt I've added the precision back:
Oh that's looking good, I like it :) And anyone who would prefer less precision could of course template an entity as required :)
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 I think humidifiers are just not that interesting
To draw some attention, let me announce that I have further plans for this card:
- 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.
- 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.
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.
- I like the concept of sensors being separate entities rather than attributes.
- 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.
@matthiasdebaat sorry to bother you, but could you take a look at this PR again please?
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.
No, it is not blocking, the logic is clear, I am just looking for a way to finalize this PR to get it merged:)
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.
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.
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.
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.
This PR is still in draft, are we waiting for something?
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.
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.
Swapped back.
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.