Skip to content

Commit

Permalink
Solved lint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanU committed Dec 26, 2023
1 parent 95fdb28 commit c10b7b8
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 102 deletions.
6 changes: 5 additions & 1 deletion custom_components/mygekko/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


async def async_setup_entry(hass, entry, async_add_devices):
"""Setup button platform."""
"""Set up button platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
lights = coordinator.api.get_lights()
if lights is not None:
Expand All @@ -30,23 +30,27 @@ class MyGekkoLightGroupOnButton(MyGekkoEntity, ButtonEntity):
"""mygekko Light class."""

def __init__(self, coordinator, light: Light):
"""Initialize the Light Group On button."""
super().__init__(coordinator, light, "lights", "On")
self._light = light
self._attr_icon = "mdi:lightbulb-on"
self._attr_translation_key = "mygekko_light_group_on"

async def async_press(self) -> None:
"""Press the button."""
await self._light.set_state(LightState.ON)


class MyGekkoLightGroupOffButton(MyGekkoEntity, ButtonEntity):
"""mygekko Light class."""

def __init__(self, coordinator, light: Light):
"""Initialize the Light Group Off button."""
super().__init__(coordinator, light, "lights", "Off")
self._light = light
self._attr_icon = "mdi:lightbulb-off"
self._attr_translation_key = "mygekko_light_group_off"

async def async_press(self) -> None:
"""Press the button."""
await self._light.set_state(LightState.OFF)
3 changes: 2 additions & 1 deletion custom_components/mygekko/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


async def async_setup_entry(hass, entry, async_add_devices):
"""Setup cover platform."""
"""Set up cover platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]

async_add_devices(
Expand All @@ -35,6 +35,7 @@ class MyGekkoRoomTempClimate(MyGekkoEntity, ClimateEntity):
_attr_temperature_unit = UnitOfTemperature.CELSIUS

def __init__(self, coordinator, room_temp: RoomTemp):
"""Initialize the MyGekko climate entity."""
super().__init__(coordinator, room_temp, "room_temps")
self._room_temp = room_temp
self._attr_translation_key = "mygekko_roomtemp"
Expand Down
1 change: 1 addition & 0 deletions custom_components/mygekko/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Data Update Coordinator for the MyGekko integration."""
import logging
from datetime import timedelta

Expand Down
7 changes: 6 additions & 1 deletion custom_components/mygekko/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


async def async_setup_entry(hass, entry, async_add_devices):
"""Setup cover platform."""
"""Set up cover platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
blinds = coordinator.api.get_blinds()
if blinds is not None:
Expand All @@ -31,6 +31,7 @@ class MyGekkoCover(MyGekkoEntity, CoverEntity):
_attr_device_class = CoverDeviceClass.SHUTTER

def __init__(self, coordinator, blind: Blind):
"""Initialize the MyGekko cover."""
super().__init__(coordinator, blind, "blinds")
self._blind = blind
supported_features = self._blind.supported_features
Expand Down Expand Up @@ -66,6 +67,7 @@ def _handle_coordinator_update(self) -> None:

@property
def is_closed(self) -> bool | None:
"""Check whether the cover is closed."""
# myGekko blinds are closed on 100 and open on 0
return (
ceil(self._blind.position) == 100
Expand Down Expand Up @@ -95,13 +97,15 @@ def current_cover_tilt_position(self) -> int | None:

@property
def is_closing(self) -> bool:
"""Check whether the cover is closing."""
return (
self._blind.state == BlindState.DOWN
or self._blind.state == BlindState.HOLD_DOWN
)

@property
def is_opening(self) -> bool:
"""Check whether the cover is opening."""
return (
self._blind.state == BlindState.UP
or self._blind.state == BlindState.HOLD_UP
Expand All @@ -120,6 +124,7 @@ async def async_stop_cover(self, **kwargs: Any):
await self._blind.set_state(BlindState.STOP)

async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Set the cover position."""
# myGekko blinds are closed on 100 and open on 0
await self._blind.set_position(100.0 - float(kwargs[ATTR_POSITION]))

Expand Down
8 changes: 5 additions & 3 deletions custom_components/mygekko/entity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""MyGekkoEntity class"""
"""MyGekkoEntity class."""
import logging

from homeassistant.helpers.entity import DeviceInfo
Expand All @@ -13,13 +13,14 @@


class MyGekkoEntity(CoordinatorEntity):
"""Base Class for MyGekko entities"""
"""Base Class for MyGekko entities."""

_attr_has_entity_name = True

def __init__(
self, coordinator, entity: Entity, entity_prefix: str, entity_suffix: str = ""
):
"""Initialize a MyGekko entity."""
super().__init__(coordinator)

device_id = f"{entity_prefix}{entity.entity_id}"
Expand All @@ -37,13 +38,14 @@ def __init__(


class MyGekkoControllerEntity(CoordinatorEntity):
"""Base Class for MyGekko controller entities"""
"""Base Class for MyGekko controller entities."""

_attr_has_entity_name = True

def __init__(
self, coordinator, entity: Entity, globals_network, entity_prefix: str
):
"""Initialize a MyGekko controller entity."""
super().__init__(coordinator)

device_id = f"mygekko_controller_{globals_network['gekkoname']}"
Expand Down
6 changes: 5 additions & 1 deletion custom_components/mygekko/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


async def async_setup_entry(hass, entry, async_add_devices):
"""Setup light platform."""
"""Set up light platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
lights: list[Light] = coordinator.api.get_lights()
if lights is not None:
Expand All @@ -36,6 +36,7 @@ class MyGekkoLight(MyGekkoEntity, LightEntity):
_attr_name = None

def __init__(self, coordinator, light: Light):
"""Initialize a MyGekko light."""
super().__init__(coordinator, light, "lights")
self._light = light

Expand All @@ -59,16 +60,19 @@ def _handle_coordinator_update(self) -> None:

@property
def is_on(self) -> bool | None:
"""Check whether the light is on."""
_LOGGER.debug(
"The light state of %s is %d", self._light.name, self._light.state
)
return self._light.state == LightState.ON

async def async_turn_off(self, **kwargs):
"""Turn off the light."""
_LOGGER.debug("Switch off light %s", self._light.name)
await self._light.set_state(LightState.OFF)

async def async_turn_on(self, **kwargs):
"""Turn on the light."""
_LOGGER.debug("Switch on light %s", self._light.name)
if ATTR_RGB_COLOR in kwargs and kwargs[ATTR_RGB_COLOR]:
await self._light.set_rgb_color(kwargs[ATTR_RGB_COLOR])
Expand Down
4 changes: 3 additions & 1 deletion custom_components/mygekko/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


async def async_setup_entry(hass, entry, async_add_devices):
"""Setup scene platform."""
"""Set up scene platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
actions = coordinator.api.get_actions()
globals_network = coordinator.api.get_globals_network()
Expand All @@ -25,6 +25,7 @@ class MyGekkoScene(MyGekkoControllerEntity, Scene):
"""mygekko Scene class."""

def __init__(self, coordinator, action: Action, globals_network):
"""Initialize a MyGekko scene."""
super().__init__(coordinator, action, globals_network, "actions")
self._action = action

Expand All @@ -34,4 +35,5 @@ def _handle_coordinator_update(self) -> None:
self.async_write_ha_state()

async def async_activate(self, **kwargs: Any) -> None:
"""Activate the scene."""
await self._action.set_state(ActionState.ON)
5 changes: 4 additions & 1 deletion custom_components/mygekko/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


async def async_setup_entry(hass, entry, async_add_devices):
"""Setup select platform."""
"""Set up select platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]

async_add_devices(
Expand All @@ -32,6 +32,7 @@ class MyGekkoVentBypassSelect(MyGekkoEntity, SelectEntity):
"""mygekko vent bypass select class."""

def __init__(self, coordinator, vent: Vent):
"""Initialize a MyGekko vent bypass selection."""
super().__init__(coordinator, vent, "vents", "Bypass")
self._vent = vent
self.entity_description = SelectEntityDescription(
Expand Down Expand Up @@ -62,6 +63,7 @@ class MyGekkoVentWorkingModeSelect(MyGekkoEntity, SelectEntity):
"""mygekko vent working mode select class."""

def __init__(self, coordinator, vent: Vent):
"""Initialize a MyGekko vent working mode selection."""
super().__init__(coordinator, vent, "vents", "Working Mode")
self._vent = vent
self.entity_description = SelectEntityDescription(
Expand Down Expand Up @@ -93,6 +95,7 @@ class MyGekkoVentWorkingLevelSelect(MyGekkoEntity, SelectEntity):
"""mygekko vent level select class."""

def __init__(self, coordinator, vent: Vent):
"""Initialize a MyGekko vent working level selection."""
super().__init__(coordinator, vent, "vents", "Level")
self._vent = vent
self.entity_description = SelectEntityDescription(
Expand Down
Loading

0 comments on commit c10b7b8

Please sign in to comment.