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
NUT sensor enhancements #14570
NUT sensor enhancements #14570
Conversation
…dy when connection to nut unavailable; output human-readable state name by default
… raw value of current status in more info dialog
…t used to display a human-readable form of the status
@@ -209,11 +215,12 @@ def unit_of_measurement(self): | |||
def device_state_attributes(self): | |||
"""Return the sensor attributes.""" | |||
attr = dict() | |||
attr[ATTR_STATE] = self.opp_state() | |||
attr[ATTR_STATE] = self.display_state() + " (" + \ | |||
self._data.status[KEY_STATUS] + ")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use format()
instead of concats (+
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, makes sense.
@@ -209,11 +215,12 @@ def unit_of_measurement(self): | |||
def device_state_attributes(self): | |||
"""Return the sensor attributes.""" | |||
attr = dict() | |||
attr[ATTR_STATE] = self.opp_state() | |||
attr[ATTR_STATE] = "{} ({})".format(self.display_state(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are very accurate this is a breaking change. I would remove the duplicate info here. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. And with the introduction of a separate sensor type for the human-readable status, the additional information in the more info dialogue is probably not necessary anymore.
…man-readable status without the raw value
Is this still a breaking change now that the more info dialogue output remains untouched? |
Oh! You are right. I've removed the tag again. |
Thank you @exxamalte for this fix! 👍 |
…14324) * removed default value from required parameter; raising PlatformNotReady when connection to nut unavailable; output human-readable state name by default * removed superfluous sensor name part; showing human-readable form and raw value of current status in more info dialog * introduced a new virtual sensor type based on the raw status value but used to display a human-readable form of the status * renamed method * format string instead of concatenation * revert the change to the device state attributes - only output the human-readable status without the raw value
Description:
This proposal makes the NUT sensor a bit more user-friendly, and contains the following changes:
ups.status.display
which outputs the UPS status in a human-readable form. For example, outputs "Online Battery Charging" instead of "OL CHRG" on the sensor's state card.Change the more info dialog output by appending the raw status value to the human-readable form. Example output: "state . Online Battery Charging (OL CHRG)".PlatformNotReady
to make HA try again after a few seconds.Related issue (if applicable): fixes #14324
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5411
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed: