Skip to content

Commit

Permalink
Update formatting and version.
Browse files Browse the repository at this point in the history
  • Loading branch information
eseglem committed Sep 2, 2022
1 parent a7743f1 commit e1ea730
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 56 deletions.
23 changes: 14 additions & 9 deletions custom_components/wattbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""
Component to integrate with WattBox.
Component to integrate with wattbox.
For more details about this component, please refer to
https://github.com/eseglem/hass-wattbox/
"""
from datetime import timedelta
from functools import partial
import logging
import os
from datetime import timedelta
from functools import partial

import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
Expand All @@ -17,14 +19,10 @@
CONF_RESOURCES,
CONF_SCAN_INTERVAL,
CONF_USERNAME,
PERCENTAGE,

)
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_track_time_interval
import voluptuous as vol

from .const import (
BINARY_SENSOR_TYPES,
Expand All @@ -42,7 +40,7 @@
TOPIC_UPDATE,
)

REQUIREMENTS = ["pywattbox>=0.3.0"]
REQUIREMENTS = ["pywattbox>=0.4.0"]

_LOGGER = logging.getLogger(__name__)

Expand All @@ -65,7 +63,10 @@
)

CONFIG_SCHEMA = vol.Schema(
{DOMAIN: vol.All(cv.ensure_list, [WATTBOX_HOST_SCHEMA]),}, extra=vol.ALLOW_EXTRA,
{
DOMAIN: vol.All(cv.ensure_list, [WATTBOX_HOST_SCHEMA]),
},
extra=vol.ALLOW_EXTRA,
)


Expand Down Expand Up @@ -122,6 +123,8 @@ async def async_setup(hass, config):

# Setup scheduled updates
async def scan_update_data(_, hass, name):
"""Scan update data wrapper."""

_LOGGER.debug(
"Scan Update Data: %s - %s",
hass.data[DOMAIN_DATA][name],
Expand All @@ -132,6 +135,7 @@ async def scan_update_data(_, hass, name):

async def update_data(hass, name):
"""Update data."""

# This is where the main logic to update platform data goes.
try:
await hass.async_add_executor_job(hass.data[DOMAIN_DATA][name].update)
Expand All @@ -148,6 +152,7 @@ async def update_data(hass, name):

async def check_files(hass):
"""Return bool that indicates if all files are present."""

# Verify that the user downloaded all files.
base = f"{hass.config.path()}/custom_components/{DOMAIN}"
missing = []
Expand Down
1 change: 1 addition & 0 deletions custom_components/wattbox/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Binary sensor platform for wattbox."""

import logging

from homeassistant.components.binary_sensor import BinarySensorEntity
Expand Down
10 changes: 8 additions & 2 deletions custom_components/wattbox/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants for wattbox."""

from datetime import timedelta

from homeassistant.components.binary_sensor import (
Expand All @@ -7,12 +8,17 @@
DEVICE_CLASS_PROBLEM,
DEVICE_CLASS_SAFETY,
)
from homeassistant.const import POWER_WATT, TIME_MINUTES, PERCENTAGE, ELECTRIC_POTENTIAL_VOLT
from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE,
POWER_WATT,
TIME_MINUTES,
)

# Base component constants
DOMAIN = "wattbox"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.7.1"
VERSION = "0.8.0"
PLATFORMS = ["binary_sensor", "sensor", "switch"]
REQUIRED_FILES = ["binary_sensor.py", "const.py", "sensor.py", "switch.py"]
ISSUE_URL = "https://github.com/eseglem/hass-wattbox/issues"
Expand Down
6 changes: 5 additions & 1 deletion custom_components/wattbox/entity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Base Entity component for wattbox."""

from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
Expand All @@ -6,6 +8,8 @@


class WattBoxEntity(Entity):
"""WattBox Entity class."""

def __init__(self, hass, name, *args):
self.hass = hass
self.attr = dict()
Expand All @@ -27,7 +31,7 @@ def update() -> None:

async def async_will_remove_from_hass(self) -> None:
"""Disconnect dispatcher listener when removed."""
if self._async_unsub_dispatcher_connect:
if hasattr(self, "_async_unsub_dispatcher_connect"):
self._async_unsub_dispatcher_connect()

@property
Expand Down
1 change: 1 addition & 0 deletions custom_components/wattbox/sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sensor platform for wattbox."""

import logging

from homeassistant.const import CONF_NAME, CONF_RESOURCES
Expand Down
5 changes: 4 additions & 1 deletion custom_components/wattbox/switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Switch platform for blueprint."""
"""Switch platform for wattbox."""

import logging

from homeassistant.components.switch import DEVICE_CLASS_OUTLET, SwitchEntity
Expand Down Expand Up @@ -105,6 +106,8 @@ def device_class(self):


class WattBoxMasterSwitch(WattBoxBinarySwitch):
"""WattBox master switch class."""

def __init__(self, hass, name):
super().__init__(hass, name, 0)
self._name = name + " Master Switch"
20 changes: 0 additions & 20 deletions package.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions resources.json

This file was deleted.

17 changes: 1 addition & 16 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,4 @@ ignore =
W504

[isort]
# https://github.com/timothycrosley/isort
# https://github.com/timothycrosley/isort/wiki/isort-Settings
# splits long import on multiple lines indented by 4 spaces
multi_line_output = 3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
indent = " "
# by default isort don't check module indexes
not_skip = __init__.py
# will group `import x` and `from x import` of the same module.
force_sort_within_sections = true
sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section = THIRDPARTY
combine_as_imports = true
profile = black

0 comments on commit e1ea730

Please sign in to comment.