diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml index 43100eb..04d5979 100644 --- a/.devcontainer/configuration.yaml +++ b/.devcontainer/configuration.yaml @@ -1,9 +1,7 @@ -default_config: - -automation: !include automations.yaml - -logger: - default: error - logs: - custom_components.blueprint: debug - +default_config: + +logger: + default: error + logs: + custom_components.nicehash: debug + diff --git a/.gitignore b/.gitignore index ed8ebf5..bb033a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,138 @@ -__pycache__ \ No newline at end of file +.DS_STORE +*.bak + +# VS Code +.vscode/settings.json + +# Dev Container +.devcontainer/configuration.yaml + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/LICENSE b/LICENSE index 8a418c6..a987474 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Joakim Sørensen @ludeeus +Copyright (c) 2020 Brian Berg @brianberg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index c0d548e..b5e0f1d 100644 --- a/README.md +++ b/README.md @@ -1,72 +1,4 @@ -# Notice - -The component and platforms in this repository are not meant to be used by a -user, but as a "blueprint" that custom component developers can build -upon, to make more awesome stuff. - -This blueprint uses ['sampleclient'](https://github.com/ludeeus/sampleclient) to simulate what you actually might use in your integration. - -HAVE FUN! 😎 - -## Why? - -This is simple, by having custom_components look (README + structure) the same -it is easier for developers to help each other and for users to start using them. - -If you are a developer and you want to add things to this "blueprint" that you think more -developers will have use for, please open a PR to add it :) - -## What? - -This repository contains multiple files, here is a overview: - -File | Purpose --- | -- -`.devcontainer/*` | Used for development/testing with VSCODE, more info in the readme file in that dir. -`.github/ISSUE_TEMPLATE/feature_request.md` | Template for Feature Requests -`.github/ISSUE_TEMPLATE/issue.md` | Template for issues -`.github/settings.yml` | Probot settings to control the repository settings. -`.vscode/tasks.json` | Tasks for the devcontainer. -`custom_components/blueprint/.translations/*` | [Translation files.](https://developers.home-assistant.io/docs/en/next/internationalization_custom_component_localization.html#translation-strings) -`custom_components/blueprint/__init__.py` | The component file for the integration. -`custom_components/blueprint/binary_sensor.py` | Binary sensor platform for the integration. -`custom_components/blueprint/config_flow.py` | Config flow file, this adds the UI configuration possibilities. -`custom_components/blueprint/const.py` | A file to hold shared variables/constants for the entire integration. -`custom_components/blueprint/manifest.json` | A [manifest file](https://developers.home-assistant.io/docs/en/creating_integration_manifest.html) for Home Assistant. -`custom_components/blueprint/sensor.py` | Sensor platform for the integration. -`custom_components/blueprint/switch.py` | Switch sensor platform for the integration. -`CONTRIBUTING.md` | Guidelines on how to contribute. -`example.png` | Screenshot that demonstrate how it might look in the UI. -`info.md` | An example on a info file (used by [hacs][hacs]). -`LICENSE` | The license file for the project. -`README.md` | The file you are reading now, should contain info about the integration, installation and configuration instructions. -`requirements.txt` | Python packages used by this integration. - -## How? - -If you want to use all the potential and features of this blueprint tempalte you -should use Visual Studio Code to develop in a container. In this container you -will have all the tools to ease your python development and a dedicated Home -Assistant core instance to run your integration. See `.devcontainer/README.md` for more information. - -If you need to work on the python library in parallel of this integration -(`sampleclient` in this example) there are different options. The following one seems -easy to implement: - -- Create a dedicated branch for your python library on a public git repository (example: branch -`dev` on `https://github.com/ludeeus/sampleclient`) -- Update in the `manifest.json` file the `requirements` key to point on your development branch -( example: `"requirements": ["git+https://github.com/ludeeus/sampleclient.git@dev#devp==0.0.1beta1"]`) -- Each time you need to make a modification to your python library, push it to your -development branch and increase the number of the python library version in `manifest.json` file -to ensure Home Assistant update the code of the python library. (example `"requirements": ["git+https://...==0.0.1beta2"]`). - - -*** -README content if this was a published component: -*** - -# blueprint +# NiceHash Home Assistant Integration [![GitHub Release][releases-shield]][releases] [![GitHub Activity][commits-shield]][commits] @@ -79,41 +11,39 @@ README content if this was a published component: [![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum] -_Component to integrate with [blueprint][blueprint]._ +_Component to integrate with [NiceHash][nicehash]_ **This component will set up the following platforms.** Platform | Description -- | -- `binary_sensor` | Show something `True` or `False`. -`sensor` | Show info from blueprint API. +`sensor` | Show info from NiceHash API. `switch` | Switch something `True` or `False`. -![example][exampleimg] - ## Installation 1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`). 2. If you do not have a `custom_components` directory (folder) there, you need to create it. -3. In the `custom_components` directory (folder) create a new folder called `blueprint`. -4. Download _all_ the files from the `custom_components/blueprint/` directory (folder) in this repository. +3. In the `custom_components` directory (folder) create a new folder called `nicehash`. +4. Download _all_ the files from the `custom_components/nicehash/` directory (folder) in this repository. 5. Place the files you downloaded in the new directory (folder) you created. 6. Restart Home Assistant -7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Blueprint" +7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "NiceHash" Using your HA configuration directory (folder) as a starting point you should now also have this: ```text -custom_components/blueprint/.translations/en.json -custom_components/blueprint/.translations/nb.json -custom_components/blueprint/.translations/sensor.nb.json -custom_components/blueprint/__init__.py -custom_components/blueprint/binary_sensor.py -custom_components/blueprint/config_flow.py -custom_components/blueprint/const.py -custom_components/blueprint/manifest.json -custom_components/blueprint/sensor.py -custom_components/blueprint/switch.py +custom_components/nicehash/.translations/en.json +custom_components/nicehash/.translations/nb.json +custom_components/nicehash/.translations/sensor.nb.json +custom_components/nicehash/__init__.py +custom_components/nicehash/binary_sensor.py +custom_components/nicehash/config_flow.py +custom_components/nicehash/const.py +custom_components/nicehash/manifest.json +custom_components/nicehash/sensor.py +custom_components/nicehash/switch.py ``` ## Configuration is done in the UI @@ -124,13 +54,12 @@ custom_components/blueprint/switch.py If you want to contribute to this please read the [Contribution guidelines](CONTRIBUTING.md) -*** -[blueprint]: https://github.com/custom-components/blueprint -[buymecoffee]: https://www.buymeacoffee.com/ludeeus +[nicehash]: https://nicehash.com +[buymecoffee]: https://www.buymeacoffee.com/brianberg [buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge -[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge -[commits]: https://github.com/custom-components/blueprint/commits/master +[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/nicehash.svg?style=for-the-badge +[commits]: https://github.com/custom-components/nicehash/commits/master [hacs]: https://github.com/custom-components/hacs [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge [discord]: https://discord.gg/Qa5fW2R @@ -138,7 +67,8 @@ If you want to contribute to this please read the [Contribution guidelines](CONT [exampleimg]: example.png [forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge [forum]: https://community.home-assistant.io/ -[license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge -[maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge -[releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge -[releases]: https://github.com/custom-components/blueprint/releases +[license-shield]: https://img.shields.io/github/license/custom-components/nicehash.svg?style=for-the-badge +[maintenance-shield]: https://img.shields.io/badge/maintainer-Brian%20Berg%20%40brianberg-blue.svg?style=for-the-badge +[releases-shield]: https://img.shields.io/github/release/custom-components/nicehash.svg?style=for-the-badge +[releases]: https://github.com/custom-components/nicehash/releases + diff --git a/custom_components/blueprint/.translations/en.json b/custom_components/blueprint/.translations/en.json deleted file mode 100644 index 300e60c..0000000 --- a/custom_components/blueprint/.translations/en.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "config": { - "title": "Blueprint", - "step": { - "user": { - "title": "Blueprint", - "description": "If you need help with the configuration have a look here: https://github.com/custom-components/blueprint", - "data": { - "username": "Username", - "password": "Password" - } - } - }, - "error": { - "auth": "Username/Password is wrong." - }, - "abort": { - "single_instance_allowed": "Only a single configuration of Blueprint is allowed." - } - }, - "options": { - "step": { - "user": { - "data": { - "binary_sensor": "Binary sensor enabled", - "sensor": "Sensor enabled", - "switch": "Switch enabled" - } - } - } - } -} \ No newline at end of file diff --git a/custom_components/blueprint/.translations/nb.json b/custom_components/blueprint/.translations/nb.json deleted file mode 100644 index c53e807..0000000 --- a/custom_components/blueprint/.translations/nb.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "config": { - "title": "Blueprint", - "step": { - "user": { - "title": "Blueprint", - "description": "Hvis du trenger hjep til konfigurasjon ta en titt her: https://github.com/custom-components/blueprint", - "data": { - "username": "Brukernavn", - "password": "Passord" - } - } - }, - "error": { - "auth": "Brukernavn/Passord er feil." - }, - "abort": { - "single_instance_allowed": "Du kan konfigurere Blueprint kun en gang." - } - }, - "options": { - "step": { - "user": { - "data": { - "binary_sensor": "Binær sensor aktivert", - "sensor": "Sensor aktivert", - "switch": "Bryter aktivert" - } - } - } - } -} \ No newline at end of file diff --git a/custom_components/blueprint/.translations/sensor.nb.json b/custom_components/blueprint/.translations/sensor.nb.json deleted file mode 100644 index ed34ceb..0000000 --- a/custom_components/blueprint/.translations/sensor.nb.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "state": { - "Some sample static text.": "Eksempel tekst." - } -} \ No newline at end of file diff --git a/custom_components/blueprint/__init__.py b/custom_components/blueprint/__init__.py deleted file mode 100644 index ae22b7f..0000000 --- a/custom_components/blueprint/__init__.py +++ /dev/null @@ -1,105 +0,0 @@ -""" -Custom integration to integrate blueprint with Home Assistant. - -For more details about this integration, please refer to -https://github.com/custom-components/blueprint -""" -import asyncio -from datetime import timedelta -import logging - -from homeassistant.config_entries import ConfigEntry -from homeassistant.core import Config, HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady -from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed -from sampleclient.client import Client - -from custom_components.blueprint.const import ( - CONF_PASSWORD, - CONF_USERNAME, - DOMAIN, - PLATFORMS, - STARTUP_MESSAGE, -) - -SCAN_INTERVAL = timedelta(seconds=30) - -_LOGGER = logging.getLogger(__name__) - - -async def async_setup(hass: HomeAssistant, config: Config): - """Set up this integration using YAML is not supported.""" - return True - - -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): - """Set up this integration using UI.""" - if hass.data.get(DOMAIN) is None: - hass.data.setdefault(DOMAIN, {}) - _LOGGER.info(STARTUP_MESSAGE) - - username = entry.data.get(CONF_USERNAME) - password = entry.data.get(CONF_PASSWORD) - - coordinator = BlueprintDataUpdateCoordinator( - hass, username=username, password=password - ) - await coordinator.async_refresh() - - if not coordinator.last_update_success: - raise ConfigEntryNotReady - - hass.data[DOMAIN][entry.entry_id] = coordinator - - for platform in PLATFORMS: - if entry.options.get(platform, True): - coordinator.platforms.append(platform) - hass.async_add_job( - hass.config_entries.async_forward_entry_setup(entry, platform) - ) - - entry.add_update_listener(async_reload_entry) - return True - - -class BlueprintDataUpdateCoordinator(DataUpdateCoordinator): - """Class to manage fetching data from the API.""" - - def __init__(self, hass, username, password): - """Initialize.""" - self.api = Client(username, password) - self.platforms = [] - - super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL) - - async def _async_update_data(self): - """Update data via library.""" - try: - data = await self.api.async_get_data() - return data.get("data", {}) - except Exception as exception: - raise UpdateFailed(exception) - - -async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): - """Handle removal of an entry.""" - coordinator = hass.data[DOMAIN][entry.entry_id] - unloaded = all( - await asyncio.gather( - *[ - hass.config_entries.async_forward_entry_unload(entry, platform) - for platform in PLATFORMS - if platform in coordinator.platforms - ] - ) - ) - if unloaded: - hass.data[DOMAIN].pop(entry.entry_id) - - return unloaded - - -async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry): - """Reload config entry.""" - await async_unload_entry(hass, entry) - await async_setup_entry(hass, entry) diff --git a/custom_components/blueprint/binary_sensor.py b/custom_components/blueprint/binary_sensor.py deleted file mode 100644 index ebb8411..0000000 --- a/custom_components/blueprint/binary_sensor.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Binary sensor platform for blueprint.""" -from homeassistant.components.binary_sensor import BinarySensorDevice - -from custom_components.blueprint.const import ( - BINARY_SENSOR, - BINARY_SENSOR_DEVICE_CLASS, - DEFAULT_NAME, - DOMAIN, -) -from custom_components.blueprint.entity import BlueprintEntity - - -async def async_setup_entry(hass, entry, async_add_devices): - """Setup binary_sensor platform.""" - coordinator = hass.data[DOMAIN][entry.entry_id] - async_add_devices([BlueprintBinarySensor(coordinator, entry)]) - - -class BlueprintBinarySensor(BlueprintEntity, BinarySensorDevice): - """blueprint binary_sensor class.""" - - @property - def name(self): - """Return the name of the binary_sensor.""" - return f"{DEFAULT_NAME}_{BINARY_SENSOR}" - - @property - def device_class(self): - """Return the class of this binary_sensor.""" - return BINARY_SENSOR_DEVICE_CLASS - - @property - def is_on(self): - """Return true if the binary_sensor is on.""" - return self.coordinator.data.get("bool_on", False) diff --git a/custom_components/blueprint/config_flow.py b/custom_components/blueprint/config_flow.py deleted file mode 100644 index 731d17c..0000000 --- a/custom_components/blueprint/config_flow.py +++ /dev/null @@ -1,108 +0,0 @@ -"""Adds config flow for Blueprint.""" -from homeassistant import config_entries -from homeassistant.core import callback -from sampleclient.client import Client -import voluptuous as vol - -from custom_components.blueprint.const import ( # pylint: disable=unused-import - CONF_PASSWORD, - CONF_USERNAME, - DOMAIN, - PLATFORMS, -) - - -class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): - """Config flow for Blueprint.""" - - VERSION = 1 - CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL - - def __init__(self): - """Initialize.""" - self._errors = {} - - async def async_step_user( - self, user_input=None # pylint: disable=bad-continuation - ): - """Handle a flow initialized by the user.""" - self._errors = {} - - # Uncomment the next 2 lines if only a single instance of the integration is allowed: - # if self._async_current_entries(): - # return self.async_abort(reason="single_instance_allowed") - - if user_input is not None: - valid = await self._test_credentials( - user_input[CONF_USERNAME], user_input[CONF_PASSWORD] - ) - if valid: - return self.async_create_entry( - title=user_input[CONF_USERNAME], data=user_input - ) - else: - self._errors["base"] = "auth" - - return await self._show_config_form(user_input) - - return await self._show_config_form(user_input) - - @staticmethod - @callback - def async_get_options_flow(config_entry): - return BlueprintOptionsFlowHandler(config_entry) - - async def _show_config_form(self, user_input): # pylint: disable=unused-argument - """Show the configuration form to edit location data.""" - return self.async_show_form( - step_id="user", - data_schema=vol.Schema( - {vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str} - ), - errors=self._errors, - ) - - async def _test_credentials(self, username, password): - """Return true if credentials is valid.""" - try: - client = Client(username, password) - await client.async_get_data() - return True - except Exception: # pylint: disable=broad-except - pass - return False - - -class BlueprintOptionsFlowHandler(config_entries.OptionsFlow): - """Blueprint config flow options handler.""" - - def __init__(self, config_entry): - """Initialize HACS options flow.""" - self.config_entry = config_entry - self.options = dict(config_entry.options) - - async def async_step_init(self, user_input=None): # pylint: disable=unused-argument - """Manage the options.""" - return await self.async_step_user() - - async def async_step_user(self, user_input=None): - """Handle a flow initialized by the user.""" - if user_input is not None: - self.options.update(user_input) - return await self._update_options() - - return self.async_show_form( - step_id="user", - data_schema=vol.Schema( - { - vol.Required(x, default=self.options.get(x, True)): bool - for x in sorted(PLATFORMS) - } - ), - ) - - async def _update_options(self): - """Update config entry options.""" - return self.async_create_entry( - title=self.config_entry.data.get(CONF_USERNAME), data=self.options - ) diff --git a/custom_components/blueprint/const.py b/custom_components/blueprint/const.py deleted file mode 100644 index 86530cb..0000000 --- a/custom_components/blueprint/const.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Constants for blueprint.""" -# Base component constants -NAME = "Blueprint" -DOMAIN = "blueprint" -DOMAIN_DATA = f"{DOMAIN}_data" -VERSION = "0.0.1" - -ISSUE_URL = "https://github.com/custom-components/blueprint/issues" - -# Icons -ICON = "mdi:format-quote-close" - -# Device classes -BINARY_SENSOR_DEVICE_CLASS = "connectivity" - -# Platforms -BINARY_SENSOR = "binary_sensor" -SENSOR = "sensor" -SWITCH = "switch" -PLATFORMS = [BINARY_SENSOR, SENSOR, SWITCH] - - -# Configuration and options -CONF_ENABLED = "enabled" -CONF_USERNAME = "username" -CONF_PASSWORD = "password" - -# Defaults -DEFAULT_NAME = DOMAIN - - -STARTUP_MESSAGE = f""" -------------------------------------------------------------------- -{NAME} -Version: {VERSION} -This is a custom integration! -If you have any issues with this you need to open an issue here: -{ISSUE_URL} -------------------------------------------------------------------- -""" diff --git a/custom_components/blueprint/entity.py b/custom_components/blueprint/entity.py deleted file mode 100644 index 7972e37..0000000 --- a/custom_components/blueprint/entity.py +++ /dev/null @@ -1,52 +0,0 @@ -"""BlueprintEntity class""" -from homeassistant.helpers import entity - -from custom_components.blueprint.const import DOMAIN, NAME, VERSION - - -class BlueprintEntity(entity.Entity): - def __init__(self, coordinator, config_entry): - self.coordinator = coordinator - self.config_entry = config_entry - - @property - def should_poll(self): - """No need to poll. Coordinator notifies entity of updates.""" - return False - - @property - def available(self): - """Return if entity is available.""" - return self.coordinator.last_update_success - - @property - def unique_id(self): - """Return a unique ID to use for this entity.""" - return self.config_entry.entry_id - - @property - def device_info(self): - return { - "identifiers": {(DOMAIN, self.unique_id)}, - "name": NAME, - "model": VERSION, - "manufacturer": NAME, - } - - @property - def device_state_attributes(self): - """Return the state attributes.""" - return { - "time": str(self.coordinator.data.get("time")), - "static": self.coordinator.data.get("static"), - } - - async def async_added_to_hass(self): - """Connect to dispatcher listening for entity data notifications.""" - self.async_on_remove( - self.coordinator.async_add_listener(self.async_write_ha_state) - ) - - async def async_update(self): - """Update Brother entity.""" - await self.coordinator.async_request_refresh() diff --git a/custom_components/blueprint/manifest.json b/custom_components/blueprint/manifest.json deleted file mode 100644 index 5f5af27..0000000 --- a/custom_components/blueprint/manifest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "domain": "blueprint", - "name": "Blueprint", - "documentation": "https://github.com/custom-components/blueprint", - "dependencies": [], - "config_flow": true, - "codeowners": [ - "@ludeeus" - ], - "requirements": [ - "sampleclient" - ] -} diff --git a/custom_components/blueprint/sensor.py b/custom_components/blueprint/sensor.py deleted file mode 100644 index db1891c..0000000 --- a/custom_components/blueprint/sensor.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Sensor platform for blueprint.""" -from custom_components.blueprint.const import DEFAULT_NAME, DOMAIN, ICON, SENSOR -from custom_components.blueprint.entity import BlueprintEntity - - -async def async_setup_entry(hass, entry, async_add_devices): - """Setup sensor platform.""" - coordinator = hass.data[DOMAIN][entry.entry_id] - async_add_devices([BlueprintSensor(coordinator, entry)]) - - -class BlueprintSensor(BlueprintEntity): - """blueprint Sensor class.""" - - @property - def name(self): - """Return the name of the sensor.""" - return f"{DEFAULT_NAME}_{SENSOR}" - - @property - def state(self): - """Return the state of the sensor.""" - return self.coordinator.data.get("static") - - @property - def icon(self): - """Return the icon of the sensor.""" - return ICON diff --git a/custom_components/blueprint/switch.py b/custom_components/blueprint/switch.py deleted file mode 100644 index 8cd1bcc..0000000 --- a/custom_components/blueprint/switch.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Switch platform for blueprint.""" -from homeassistant.components.switch import SwitchDevice - -from custom_components.blueprint.const import DEFAULT_NAME, DOMAIN, ICON, SWITCH -from custom_components.blueprint.entity import BlueprintEntity - - -async def async_setup_entry(hass, entry, async_add_devices): - """Setup sensor platform.""" - coordinator = hass.data[DOMAIN][entry.entry_id] - async_add_devices([BlueprintBinarySwitch(coordinator, entry)]) - - -class BlueprintBinarySwitch(BlueprintEntity, SwitchDevice): - """blueprint switch class.""" - - async def async_turn_on(self, **kwargs): # pylint: disable=unused-argument - """Turn on the switch.""" - await self.coordinator.api.async_change_something(True) - await self.coordinator.async_request_refresh() - - async def async_turn_off(self, **kwargs): # pylint: disable=unused-argument - """Turn off the switch.""" - await self.coordinator.api.async_change_something(False) - await self.coordinator.async_request_refresh() - - @property - def name(self): - """Return the name of the switch.""" - return f"{DEFAULT_NAME}_{SWITCH}" - - @property - def icon(self): - """Return the icon of this switch.""" - return ICON - - @property - def is_on(self): - """Return true if the switch is on.""" - return self.coordinator.api.something diff --git a/example.png b/example.png deleted file mode 100644 index c2d4244..0000000 Binary files a/example.png and /dev/null differ diff --git a/hacs.json b/hacs.json index 04c51e2..f47862b 100644 --- a/hacs.json +++ b/hacs.json @@ -1,11 +1,8 @@ { - "name": "Blueprint", - "hacs": "0.24.0", - "domains": [ - "binary_sensor", - "sensor", - "switch" - ], - "iot_class": "Cloud Polling", - "homeassistant": "0.108.0" + "name": "NiceHash", + "domains": [ + "sensor" + ], + "iot_class": "Cloud Polling", + "homeassistant": "0.108.0" } \ No newline at end of file diff --git a/info.md b/info.md index 4a097f5..aa6ceed 100644 --- a/info.md +++ b/info.md @@ -9,23 +9,19 @@ [![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum] -_Component to integrate with [blueprint][blueprint]._ +_Component to integrate with [NiceHash][nicehash]_ -**This component will set up the following platforms.** +**This component will set up the following platforms** Platform | Description -- | -- -`binary_sensor` | Show something `True` or `False`. -`sensor` | Show info from blueprint API. -`switch` | Switch something `True` or `False`. - -![example][exampleimg] +`sensor` | Show info from NiceHash API {% if not installed %} ## Installation -1. Click install. -1. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Blueprint". +1. Click install +1. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "NiceHash" {% endif %} @@ -34,13 +30,11 @@ Platform | Description -*** - -[blueprint]: https://github.com/custom-components/blueprint -[buymecoffee]: https://www.buymeacoffee.com/ludeeus +[nicehash]: https://nicehash.com +[buymecoffee]: https://www.buymeacoffee.com/brianberg [buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge -[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge -[commits]: https://github.com/custom-components/blueprint/commits/master +[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/nicehash.svg?style=for-the-badge +[commits]: https://github.com/custom-components/nicehash/commits/master [hacs]: https://github.com/custom-components/hacs [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge [discord]: https://discord.gg/Qa5fW2R @@ -48,7 +42,7 @@ Platform | Description [exampleimg]: example.png [forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge [forum]: https://community.home-assistant.io/ -[license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge -[maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge -[releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge -[releases]: https://github.com/custom-components/blueprint/releases +[license-shield]: https://img.shields.io/github/license/custom-components/nicehash.svg?style=for-the-badge +[maintenance-shield]: https://img.shields.io/badge/maintainer-Brian%20Berg%20%40brianberg-blue.svg?style=for-the-badge +[releases-shield]: https://img.shields.io/github/release/custom-components/nicehash.svg?style=for-the-badge +[releases]: https://github.com/custom-components/nicehash/releases diff --git a/setup.cfg b/setup.cfg index 4b57c35..49db7c7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build doctests = True # To work with Black -max-line-length = 88 +max-line-length = 80 # E501: line too long # W503: Line break occurred before a binary operator # E203: Whitespace before ':' @@ -23,7 +23,7 @@ multi_line_output = 3 include_trailing_comma=True force_grid_wrap=0 use_parentheses=True -line_length=88 +line_length=80 indent = " " # by default isort don't check module indexes not_skip = __init__.py @@ -31,5 +31,5 @@ not_skip = __init__.py force_sort_within_sections = true sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER default_section = THIRDPARTY -known_first_party = custom_components.blueprint +known_first_party = custom_components.nicehash combine_as_imports = true