Skip to content

Commit

Permalink
Manual linting
Browse files Browse the repository at this point in the history
Fixed min_version error, by undefined variable.
  • Loading branch information
P-Storm committed Mar 25, 2024
1 parent b4fef2c commit 5b74a94
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 48 deletions.
5 changes: 2 additions & 3 deletions custom_components/button_plus/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.device_registry import DeviceInfo

from custom_components.button_plus.button_plus_api.model import Connector, ConnectorEnum
from .button_plus_api.model import Connector, ConnectorEnum
from .const import DOMAIN
from . import ButtonPlusHub

from .const import DOMAIN, MANUFACTURER

_LOGGER = logging.getLogger(__name__)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import Enum

class ConnectorEnum(Enum):
NOT_CONNECTED = 0
BAR = 1
DISPLAY = 2
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import logging

import aiohttp

_LOGGER: logging.Logger = logging.getLogger(__package__)


Expand All @@ -14,7 +12,7 @@ def __init__(self, ip_address, session) -> None:
self._base = f"http://{ip_address}"
self._session = session

_LOGGER.debug(f"Initialize Button+ local API client")
_LOGGER.debug("Initialize Button+ local API client")

async def fetch_config(self):
url = f"{self._base}/config"
Expand Down
10 changes: 2 additions & 8 deletions custom_components/button_plus/button_plus_api/model.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import json
from typing import List, Dict, Any
from enum import Enum

class ConnectorEnum(Enum):
NOT_CONNECTED = 0
BAR = 1
DISPLAY = 2

from custom_components.button_plus.button_plus_api.event_type import EventType

from .connector_type import ConnectorEnum
from .event_type import EventType

class Connector:
def __init__(self, connector_id: int, connector_type: int):
Expand Down
7 changes: 4 additions & 3 deletions custom_components/button_plus/buttonplushub.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

import logging

from config.custom_components.button_plus.button_plus_api.local_api_client import LocalApiClient
from config.custom_components.button_plus.button_plus_api.model import ConnectorEnum, DeviceConfiguration
from config.custom_components.button_plus.const import DOMAIN, MANUFACTURER
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers import device_registry as dr
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client

from .button_plus_api.local_api_client import LocalApiClient
from .button_plus_api.model import ConnectorEnum, DeviceConfiguration
from .const import DOMAIN, MANUFACTURER


_LOGGER: logging.Logger = logging.getLogger(__package__)

Expand Down
15 changes: 7 additions & 8 deletions custom_components/button_plus/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
from json import JSONDecodeError

import voluptuous as vol
from custom_components.button_plus.button_plus_api.model import ConnectorEnum
from homeassistant import config_entries, exceptions
from homeassistant.const import CONF_IP_ADDRESS, CONF_EMAIL, CONF_PASSWORD, CONF_HOST
from homeassistant import config_entries
from homeassistant.const import CONF_IP_ADDRESS, CONF_EMAIL, CONF_PASSWORD
from homeassistant.helpers import aiohttp_client
from .button_plus_api.api_client import ApiClient
from .button_plus_api.local_api_client import LocalApiClient
from .button_plus_api.model import DeviceConfiguration, MqttBroker
from .button_plus_api.event_type import EventType
from homeassistant.helpers.network import get_url
from packaging import version

from .const import DOMAIN # pylint:disable=unused-import
from .button_plus_api.api_client import ApiClient
from .button_plus_api.local_api_client import LocalApiClient
from .button_plus_api.model import ConnectorEnum, DeviceConfiguration, MqttBroker
from .button_plus_api.event_type import EventType
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions custom_components/button_plus/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.components.mqtt import client as mqtt, ReceiveMessage

from custom_components.button_plus.buttonplushub import ButtonPlusHub
from custom_components.button_plus.const import DOMAIN
from .buttonplushub import ButtonPlusHub
from .const import DOMAIN


_LOGGER = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/button_plus/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import DeviceInfo
from custom_components.button_plus.buttonplushub import ButtonPlusHub

from .buttonplushub import ButtonPlusHub

from .const import DOMAIN, MANUFACTURER

Expand Down
20 changes: 7 additions & 13 deletions custom_components/button_plus/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,38 @@
from __future__ import annotations

import logging
from typing import Any

from homeassistant.components.number import NumberEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.components.mqtt import client as mqtt
from packaging import version
from .button_plus_api.event_type import EventType
from . import ButtonPlusHub
from packaging import version

from .const import DOMAIN, MANUFACTURER
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)



async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add switches for passed config_entry in HA."""

brightness = []

"""Add switches for passed config_entry in HA."""

hub: ButtonPlusHub = hass.data[DOMAIN][config_entry.entry_id]

if version.parse(hub.config.info.firmware) < version.parse('1.11'):
min_version = '1.11'
if version.parse(hub.config.info.firmware) < version.parse(min_version):
_LOGGER.info(f"Current version {hub.config.info.firmware} doesn't support the brightness, it must be at least firmware version {min_version}")
return

_LOGGER.debug(f"Creating number with parameters: {hub.hub_id}")
# _LOGGER.debug(f"Creating Lights with parameters: {button.button_id} {button.label} {hub.hub_id}")
mini = ButtonPlusMiniBrightness(hub)
brightness.append(mini)
hub.add_brightness("mini", mini)
Expand Down Expand Up @@ -106,7 +101,6 @@ def device_info(self) -> DeviceInfo:

async def async_set_value(self, value: float) -> None:
"""Set the text value and publish to mqtt."""
# TODO: Add support for mini
label_topic = f"buttonplus/{self._hub_id}/brightness/{self._brightness_type}"
_LOGGER.debug(f"ButtonPlus brightness update for {self.entity_id}")
_LOGGER.debug(f"ButtonPlus brightness update to {label_topic} with new value: {value}")
Expand All @@ -124,7 +118,7 @@ def __init__(self, hub: ButtonPlusHub):
@property
def name(self) -> str:
"""Return the display name of this light."""
return f'Brightness mini display'
return 'Brightness mini display'


class ButtonPlusLargeBrightness(ButtonPlusBrightness):
Expand All @@ -136,4 +130,4 @@ def __init__(self, hub: ButtonPlusHub):
@property
def name(self) -> str:
"""Return the display name of this light."""
return f'Brightness large display'
return 'Brightness large display'
3 changes: 2 additions & 1 deletion custom_components/button_plus/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from homeassistant.components.switch import (SwitchEntity, SwitchDeviceClass)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from custom_components.button_plus.button_plus_api.model import ConnectorEnum
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .button_plus_api.model import ConnectorEnum
from . import ButtonPlusHub

from .const import DOMAIN, MANUFACTURER
Expand Down
7 changes: 2 additions & 5 deletions custom_components/button_plus/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import logging

from custom_components.button_plus.button_plus_api.model import ConnectorEnum
from homeassistant.components.text import TextEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
Expand All @@ -12,11 +11,9 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.device_registry import DeviceInfo

from custom_components.button_plus.button_plus_api.model import Connector

from . import ButtonPlusHub

from .const import DOMAIN, MANUFACTURER
from .button_plus_api.model import ConnectorEnum
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

Expand Down

0 comments on commit 5b74a94

Please sign in to comment.