Skip to content

NUT sensor enhancements#14570

Merged
syssi merged 6 commits intohome-assistant:devfrom
exxamalte:nut-enhancements
May 22, 2018
Merged

NUT sensor enhancements#14570
syssi merged 6 commits intohome-assistant:devfrom
exxamalte:nut-enhancements

Conversation

@exxamalte
Copy link
Copy Markdown
Contributor

@exxamalte exxamalte commented May 21, 2018

Description:

This proposal makes the NUT sensor a bit more user-friendly, and contains the following changes:

  • Fix NUT sensor shows raw status instead of human-readable status #14324 by introducing a new virtual sensor type 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)".
  • In two cases where during the setup of the sensor the NUT status is unavailable or the initial sensor update fails, raise a 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):

sensor:
  - platform: nut
    resources:
      - ups.status.display

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

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

exxamalte added 4 commits May 20, 2018 22:41
…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
Comment thread homeassistant/components/sensor/nut.py Outdated
attr = dict()
attr[ATTR_STATE] = self.opp_state()
attr[ATTR_STATE] = self.display_state() + " (" + \
self._data.status[KEY_STATUS] + ")"
Copy link
Copy Markdown
Member

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 (+)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, makes sense.

Comment thread homeassistant/components/sensor/nut.py Outdated
"""Return the sensor attributes."""
attr = dict()
attr[ATTR_STATE] = self.opp_state()
attr[ATTR_STATE] = "{} ({})".format(self.display_state(),
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

@exxamalte
Copy link
Copy Markdown
Contributor Author

Is this still a breaking change now that the more info dialogue output remains untouched?

@syssi
Copy link
Copy Markdown
Member

syssi commented May 22, 2018

Oh! You are right. I've removed the tag again.

@syssi syssi merged commit a2decda into home-assistant:dev May 22, 2018
@fanaticDavid
Copy link
Copy Markdown
Contributor

Thank you @exxamalte for this fix! 👍

@exxamalte exxamalte deleted the nut-enhancements branch May 22, 2018 23:25
@home-assistant home-assistant locked and limited conversation to collaborators Sep 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed integration: nut small-pr PRs with less than 30 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NUT sensor shows raw status instead of human-readable status

4 participants