Skip to content

Redesign monitored variables for hp_ilo sensor#7534

Merged
balloob merged 5 commits into
home-assistant:devfrom
bjw-s:hp_ilo
May 23, 2017
Merged

Redesign monitored variables for hp_ilo sensor#7534
balloob merged 5 commits into
home-assistant:devfrom
bjw-s:hp_ilo

Conversation

@bjw-s
Copy link
Copy Markdown
Contributor

@bjw-s bjw-s commented May 10, 2017

Allow generating specific sensors without the need for template sensors

Description:

Major redesign on the hp_ilo component allowing generating specific sensors without the need for template sensors.

This means a small (but breaking) change for existing users, due to the monitored_variables configuration entry now requiring a sensor name and sensor type instead of being an plain list

I have added an example including a screenshot to the home-assistant.github.io PR.

Related issue (if applicable): n/a

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2608

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: hp_ilo
    host: IP_ADDRESS or HOSTNAME
    username: USERNAME
    password: PASSWORD
    monitored_variables:
      - name: SENSOR NAME
        sensor_type: SENSOR TYPE

Checklist:

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

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @Juggels,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@mention-bot
Copy link
Copy Markdown

@Juggels, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff, @balloob and @robbiet480 to be potential reviewers.

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 don't include a new dependency for extracting data. We use Jinja2 templates for this.

@bjw-s
Copy link
Copy Markdown
Contributor Author

bjw-s commented May 13, 2017

@balloob I've done some changes, no longer requiring the external dependency. Also updated the docs in home-assistant/home-assistant.io#2608

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

We should not do any magic with incoming data.

Fetch data from device -> Run it through template -> Return it from a property.

Interpreting it as JSON is not allowed. Please remove.

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.

We should not use Jinja2 templates to generate JSON that we then will load again. Jinja2 should be used to just generate the value.

Example template could be {{ value.something[0].name }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'homeassistant.helpers.template.Template' imported but unused

bjw-s added 4 commits May 15, 2017 13:45
Allow generating specific sensors without the need for template sensors
Do not interfere with value_template or ilo_data output, this is now the responsibility of the user and should be handled in `configuration.yaml`

Fix UnusedImportStatement

Fix newline after function docstring
@bjw-s
Copy link
Copy Markdown
Contributor Author

bjw-s commented May 16, 2017

Processes requested changes in latest commit

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Looks good. 1 minor change left.

self._state = ilo_data
elif isinstance(ilo_data, (int, float)):
# the sensor state, otherwise store the data in the sensor attributes
if isinstance(ilo_data, (str, bytes, int, float)):
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.

Can you remove this logic and always assign it to the state. I know that it's pre-existing logic but it shouldn't have been merged

@bjw-s
Copy link
Copy Markdown
Contributor Author

bjw-s commented May 17, 2017

Processed requested changes in latest commit

@balloob balloob merged commit e3307fb into home-assistant:dev May 23, 2017
@balloob
Copy link
Copy Markdown
Member

balloob commented May 23, 2017

Thanks! 🐬

@balloob balloob mentioned this pull request Jun 2, 2017
@bjw-s bjw-s deleted the hp_ilo branch June 6, 2017 05:54
@home-assistant home-assistant locked and limited conversation to collaborators Sep 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants