Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switch platform for hp ilo integration #32209

Closed
wants to merge 1 commit into from
Closed

Add switch platform for hp ilo integration #32209

wants to merge 1 commit into from

Conversation

nickneos
Copy link
Contributor

Proposed change

Adds switch platform to the HP ILO integration

Type of change

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

Example entry for configuration.yaml:

# Example configuration.yaml
switch:
  platform: hp_ilo
  host: 192.168.1.100
  username: administrator
  password: password
  port: 443

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

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

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

@codecov
Copy link

codecov bot commented Feb 26, 2020

Codecov Report

Merging #32209 into dev will decrease coverage by 0.07%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev   #32209      +/-   ##
==========================================
- Coverage   94.75%   94.68%   -0.08%     
==========================================
  Files         775      773       -2     
  Lines       56154    55926     -228     
==========================================
- Hits        53209    52951     -258     
- Misses       2945     2975      +30
Impacted Files Coverage 螖
homeassistant/components/hp_ilo/switch.py 0% <0%> (酶)
homeassistant/helpers/system_info.py 84.21% <0%> (-4.03%) 猬囷笍
homeassistant/components/lovelace/dashboard.py 93.75% <0%> (-2.52%) 猬囷笍
homeassistant/helpers/collection.py 95.81% <0%> (-0.92%) 猬囷笍
homeassistant/components/lovelace/websocket.py 93.47% <0%> (-0.53%) 猬囷笍
...istant/components/homekit_controller/connection.py 92.73% <0%> (-0.35%) 猬囷笍
homeassistant/helpers/entity.py 97.3% <0%> (-0.34%) 猬囷笍
homeassistant/components/ring/sensor.py 86.86% <0%> (-0.14%) 猬囷笍
homeassistant/components/gdacs/sensor.py 98.75% <0%> (-0.06%) 猬囷笍
homeassistant/components/http/auth.py 96.77% <0%> (-0.06%) 猬囷笍
... and 46 more

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update e9a7b66...e9f337e. Read the comment docs.

@springstan springstan changed the title create switch for hp ilo integration Add switch platform for hp ilo integration Feb 26, 2020

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the HP iLO switch."""
hostname = config.get(CONF_HOST)
Copy link
Member

Choose a reason for hiding this comment

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

Please use dict[key] for required config keys as well.

"""Support for powering on/off server with HP iLO."""
import logging

import hpilo
Copy link
Member

Choose a reason for hiding this comment

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

Only import the login function and maybe rename it to something more self-explanatory.


def __init__(self, hass, name, hp_ilo):
"""Initialize the HP iLO switch."""
self._hass = hass
Copy link
Member

Choose a reason for hiding this comment

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

Self.hass is not used

"""Initialize the HP iLO switch."""
self._hass = hass
self._name = name
self.hp_ilo = hp_ilo
Copy link
Member

Choose a reason for hiding this comment

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

Please rename this to client or server since it resembles the name of the library too much IMHO.

@frenck
Copy link
Member

frenck commented Mar 6, 2020

So why add a separate platform to the integration?

I rather would recommend converting it to an actual integration, having a single configuration entry to create both in one go.

@nickneos
Copy link
Contributor Author

nickneos commented Mar 6, 2020

yes i agree, but not sure how to do this as I am quite new to developing on home assistant

@frenck
Copy link
Member

frenck commented Mar 7, 2020

Most of the integrations we have, can serve as an example for this.

What you basically need to do, on a high level overview, is process the configuration in __init__.py (so the setup moves into there). And forward the setup to the different available platforms.

https://developers.home-assistant.io/docs/creating_component_generic_discovery/

@stale
Copy link

stale bot commented Apr 6, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Apr 6, 2020
@stale stale bot closed this Apr 13, 2020
Dev automation moved this from Needs review to Cancelled Apr 13, 2020
@lock lock bot locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Cancelled
Development

Successfully merging this pull request may close these issues.

None yet

4 participants