Skip to content

Commit

Permalink
Merge pull request #612 from XKNX/dependabot/pip/pylint-2.7.0
Browse files Browse the repository at this point in the history
Bump pylint from 2.6.2 to 2.7.0
  • Loading branch information
farmio committed Feb 23, 2021
2 parents 2247fb0 + 8f96782 commit e0c956c
Show file tree
Hide file tree
Showing 19 changed files with 105 additions and 117 deletions.
18 changes: 9 additions & 9 deletions home-assistant-plugin/custom_components/xknx/__init__.py
Expand Up @@ -106,31 +106,31 @@
vol.Optional(CONF_XKNX_EXPOSE): vol.All(
cv.ensure_list, [ExposeSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.cover.value): vol.All(
vol.Optional(SupportedPlatforms.COVER.value): vol.All(
cv.ensure_list, [CoverSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.binary_sensor.value): vol.All(
vol.Optional(SupportedPlatforms.BINARY_sensor.value): vol.All(
cv.ensure_list, [BinarySensorSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.light.value): vol.All(
vol.Optional(SupportedPlatforms.LIGHT.value): vol.All(
cv.ensure_list, [LightSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.climate.value): vol.All(
vol.Optional(SupportedPlatforms.CLIMATE.value): vol.All(
cv.ensure_list, [ClimateSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.notify.value): vol.All(
vol.Optional(SupportedPlatforms.NOTIFY.value): vol.All(
cv.ensure_list, [NotifySchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.switch.value): vol.All(
vol.Optional(SupportedPlatforms.SWITCH.value): vol.All(
cv.ensure_list, [SwitchSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.sensor.value): vol.All(
vol.Optional(SupportedPlatforms.SENSOR.value): vol.All(
cv.ensure_list, [SensorSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.scene.value): vol.All(
vol.Optional(SupportedPlatforms.SCENE.value): vol.All(
cv.ensure_list, [SceneSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.weather.value): vol.All(
vol.Optional(SupportedPlatforms.WEATHER.value): vol.All(
cv.ensure_list, [WeatherSchema.SCHEMA]
),
vol.Optional(SupportedPlatforms.fan.value): vol.All(
Expand Down
24 changes: 12 additions & 12 deletions home-assistant-plugin/custom_components/xknx/const.py
Expand Up @@ -26,23 +26,23 @@
class ColorTempModes(Enum):
"""Color temperature modes for config validation."""

absolute = "DPT-7.600"
relative = "DPT-5.001"
ABSOLUTE = "DPT-7.600"
RELATIVE = "DPT-5.001"


class SupportedPlatforms(Enum):
"""Supported platforms."""

binary_sensor = "binary_sensor"
climate = "climate"
cover = "cover"
fan = "fan"
light = "light"
notify = "notify"
scene = "scene"
sensor = "sensor"
switch = "switch"
weather = "weather"
BINARY_SENSOR = "binary_sensor"
CLIMATE = "climate"
COVER = "cover"
FAN = "fan"
LIGHT = "light"
NOTIFY = "notify"
SCENE = "scene"
SENSOR = "sensor"
SWITCH = "switch"
WEATHER = "weather"


# Map KNX controller modes to HA modes. This list might not be complete.
Expand Down
24 changes: 12 additions & 12 deletions home-assistant-plugin/custom_components/xknx/factory.py
Expand Up @@ -40,34 +40,34 @@ def create_knx_device(
config: ConfigType,
) -> XknxDevice:
"""Return the requested XKNX device."""
if platform is SupportedPlatforms.light:
if platform is SupportedPlatforms.LIGHT:
return _create_light(knx_module, config)

if platform is SupportedPlatforms.cover:
if platform is SupportedPlatforms.COVER:
return _create_cover(knx_module, config)

if platform is SupportedPlatforms.climate:
if platform is SupportedPlatforms.CLIMATE:
return _create_climate(knx_module, config)

if platform is SupportedPlatforms.switch:
if platform is SupportedPlatforms.SWITCH:
return _create_switch(knx_module, config)

if platform is SupportedPlatforms.sensor:
if platform is SupportedPlatforms.SENSOR:
return _create_sensor(knx_module, config)

if platform is SupportedPlatforms.notify:
if platform is SupportedPlatforms.NOTIFY:
return _create_notify(knx_module, config)

if platform is SupportedPlatforms.scene:
if platform is SupportedPlatforms.SCENE:
return _create_scene(knx_module, config)

if platform is SupportedPlatforms.binary_sensor:
if platform is SupportedPlatforms.BINARY_sensor:
return _create_binary_sensor(knx_module, config)

if platform is SupportedPlatforms.weather:
if platform is SupportedPlatforms.WEATHER:
return _create_weather(knx_module, config)

if platform is SupportedPlatforms.fan:
if platform is SupportedPlatforms.FAN:
return _create_fan(knx_module, config)


Expand Down Expand Up @@ -121,12 +121,12 @@ def _create_light(knx_module: XKNX, config: ConfigType) -> XknxLight:
group_address_tunable_white_state = None
group_address_color_temp = None
group_address_color_temp_state = None
if config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.absolute:
if config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.ABSOLUTE:
group_address_color_temp = config.get(LightSchema.CONF_COLOR_TEMP_ADDRESS)
group_address_color_temp_state = config.get(
LightSchema.CONF_COLOR_TEMP_STATE_ADDRESS
)
elif config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.relative:
elif config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.RELATIVE:
group_address_tunable_white = config.get(LightSchema.CONF_COLOR_TEMP_ADDRESS)
group_address_tunable_white_state = config.get(
LightSchema.CONF_COLOR_TEMP_STATE_ADDRESS
Expand Down
6 changes: 3 additions & 3 deletions home-assistant-plugin/custom_components/xknx/fan.py
Expand Up @@ -34,14 +34,14 @@ def __init__(self, device: XknxFan):
"""Initialize of KNX fan."""
super().__init__(device)

if self._device.mode == FanSpeedMode.Step:
if self._device.mode == FanSpeedMode.STEP:
self._step_range = (1, device.max_step)
else:
self._step_range = None

async def async_set_percentage(self, percentage: int) -> None:
"""Set the speed of the fan, as a percentage."""
if self._device.mode == FanSpeedMode.Step:
if self._device.mode == FanSpeedMode.STEP:
step = math.ceil(percentage_to_ranged_value(self._step_range, percentage))
await self._device.set_speed(step)
else:
Expand All @@ -63,7 +63,7 @@ def percentage(self) -> Optional[int]:
if self._device.current_speed is None:
return None

if self._device.mode == FanSpeedMode.Step:
if self._device.mode == FanSpeedMode.STEP:
return ranged_value_to_percentage(
self._step_range, self._device.current_speed
)
Expand Down
2 changes: 1 addition & 1 deletion requirements/testing.txt
Expand Up @@ -5,7 +5,7 @@ coveralls==3.0.0
flake8==3.8.4
flake8-isort==4.0.0
pydocstyle==5.1.1
pylint==2.6.2
pylint==2.7.0
pylint-strict-informational==0.1
pytest==6.2.2
pytest-cov==2.11.1
Expand Down
2 changes: 1 addition & 1 deletion test/config_tests/resources/light/valid_1.yaml
Expand Up @@ -17,6 +17,6 @@ color_temperature:
address: "2/5/7"
state_address: "2/5/8"
state_update: "expire 60"
mode: absolute
mode: ABSOLUTE
min_kelvin: 2550
max_kelvin: 6200
2 changes: 1 addition & 1 deletion test/config_tests/resources/light/valid_4.yaml
Expand Up @@ -7,4 +7,4 @@ color_temperature:
address: "2/5/7"
state_address: "2/5/8"
state_update: "expire 60"
mode: relative
mode: RELATIVE
2 changes: 1 addition & 1 deletion test/config_tests/resources/xknx/valid_1.yaml
Expand Up @@ -50,7 +50,7 @@ light:
address: "2/5/7"
state_address: "2/5/8"
state_update: "expire 60"
mode: absolute
mode: ABSOLUTE
min_kelvin: 2550
max_kelvin: 6200
fan:
Expand Down
2 changes: 1 addition & 1 deletion test/config_tests/resources/xknx/valid_2.yaml
Expand Up @@ -47,7 +47,7 @@ light:
address: "2/5/7"
state_address: "2/5/8"
state_update: "expire 60"
mode: absolute
mode: ABSOLUTE
min_kelvin: 2550
max_kelvin: 6200
fan:
Expand Down
2 changes: 1 addition & 1 deletion test/config_tests/resources/xknx/valid_3.yaml
Expand Up @@ -52,7 +52,7 @@ light:
address: "2/5/7"
state_address: "2/5/8"
state_update: "expire 60"
mode: absolute
mode: ABSOLUTE
min_kelvin: 2550
max_kelvin: 6200
fan:
Expand Down
20 changes: 10 additions & 10 deletions test/devices_tests/weather_test.py
Expand Up @@ -144,7 +144,7 @@ def test_state_lightning(self):
weather._rain_alarm.payload = DPTBinary(1)
weather._wind_alarm.payload = DPTBinary(1)

self.assertEqual(weather.ha_current_state(), WeatherCondition.lightning_rainy)
self.assertEqual(weather.ha_current_state(), WeatherCondition.LIGHTNING_RAINY)

def test_state_snowy_rainy(self):
"""Test snow rain if frost alarm and rain alarm are true."""
Expand All @@ -159,7 +159,7 @@ def test_state_snowy_rainy(self):
weather._rain_alarm.payload = DPTBinary(1)
weather._frost_alarm.payload = DPTBinary(1)

self.assertEqual(weather.ha_current_state(), WeatherCondition.snowy_rainy)
self.assertEqual(weather.ha_current_state(), WeatherCondition.SNOWY_RAINY)

def test_wind_alarm(self):
"""Test basic state mapping."""
Expand All @@ -174,7 +174,7 @@ def test_wind_alarm(self):

weather._wind_alarm.payload = DPTBinary(1)

self.assertEqual(weather.ha_current_state(), WeatherCondition.windy)
self.assertEqual(weather.ha_current_state(), WeatherCondition.WINDY)

def test_rain_alarm(self):
"""Test basic state mapping."""
Expand All @@ -189,7 +189,7 @@ def test_rain_alarm(self):

weather._rain_alarm.payload = DPTBinary(1)

self.assertEqual(weather.ha_current_state(), WeatherCondition.rainy)
self.assertEqual(weather.ha_current_state(), WeatherCondition.RAINY)

def test_cloudy_summer(self):
"""Test cloudy summer if illuminance matches defined interval."""
Expand All @@ -211,7 +211,7 @@ def test_cloudy_summer(self):
summer_date = datetime.datetime(2020, 10, 5, 18, 00)

self.assertEqual(
weather.ha_current_state(current_date=summer_date), WeatherCondition.cloudy
weather.ha_current_state(current_date=summer_date), WeatherCondition.CLOUDY
)

def test_sunny_summer(self):
Expand All @@ -235,7 +235,7 @@ def test_sunny_summer(self):
summer_date = datetime.datetime(2020, 10, 5, 18, 00)

self.assertEqual(
weather.ha_current_state(current_date=summer_date), WeatherCondition.sunny
weather.ha_current_state(current_date=summer_date), WeatherCondition.SUNNY
)

def test_sunny_winter(self):
Expand All @@ -258,7 +258,7 @@ def test_sunny_winter(self):
winter_date = datetime.datetime(2020, 12, 5, 18, 00)

self.assertEqual(
weather.ha_current_state(current_date=winter_date), WeatherCondition.sunny
weather.ha_current_state(current_date=winter_date), WeatherCondition.SUNNY
)

def test_cloudy_winter(self):
Expand All @@ -282,7 +282,7 @@ def test_cloudy_winter(self):
winter_date = datetime.datetime(2020, 12, 31, 18, 00)

self.assertEqual(
weather.ha_current_state(current_date=winter_date), WeatherCondition.cloudy
weather.ha_current_state(current_date=winter_date), WeatherCondition.CLOUDY
)

def test_day_night(self):
Expand All @@ -294,14 +294,14 @@ def test_day_night(self):

weather._day_night.payload = DPTBinary(0)

self.assertEqual(weather.ha_current_state(), WeatherCondition.clear_night)
self.assertEqual(weather.ha_current_state(), WeatherCondition.CLEAR_NIGHT)

def test_weather_default(self):
"""Test default state mapping."""
xknx = XKNX()
weather: Weather = Weather(name="weather", xknx=xknx)

self.assertEqual(weather.ha_current_state(), WeatherCondition.exceptional)
self.assertEqual(weather.ha_current_state(), WeatherCondition.EXCEPTIONAL)

#
# Create sensor tests
Expand Down
2 changes: 1 addition & 1 deletion test/knxip_tests/tunnelling_request_test.py
Expand Up @@ -66,7 +66,7 @@ def test_connect_request(self):
),
)

cemi = CEMIFrame(xknx, code=CEMIMessageCode.L_Data_REQ)
cemi = CEMIFrame(xknx, code=CEMIMessageCode.L_DATA_REQ)
cemi.telegram = Telegram(
destination_address=GroupAddress("9/0/8"),
payload=GroupValueWrite(DPTBinary(1)),
Expand Down
8 changes: 4 additions & 4 deletions xknx/devices/fan.py
Expand Up @@ -30,8 +30,8 @@
class FanSpeedMode(Enum):
"""Enum for setting the fan speed mode."""

Percent = 1
Step = 2
PERCENT = 1
STEP = 2


class Fan(Device):
Expand All @@ -56,10 +56,10 @@ def __init__(
super().__init__(xknx, name, device_updated_cb)

self.speed: Union[RemoteValueDptValue1Ucount, RemoteValueScaling]
self.mode = FanSpeedMode.Step if max_step is not None else FanSpeedMode.Percent
self.mode = FanSpeedMode.STEP if max_step is not None else FanSpeedMode.PERCENT
self.max_step = max_step

if self.mode == FanSpeedMode.Step:
if self.mode == FanSpeedMode.STEP:
self.speed = RemoteValueDptValue1Ucount(
xknx,
group_address_speed,
Expand Down

0 comments on commit e0c956c

Please sign in to comment.