mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 21:55:10 +02:00
no pydocstyle errors
This commit is contained in:
@@ -121,6 +121,7 @@ class AdsHub:
|
|||||||
"""Representation of a PyADS connection."""
|
"""Representation of a PyADS connection."""
|
||||||
|
|
||||||
def __init__(self, ads_client, poll_interval, use_notify):
|
def __init__(self, ads_client, poll_interval, use_notify):
|
||||||
|
"""Initialize the ADS Hub."""
|
||||||
self.poll_interval = poll_interval
|
self.poll_interval = poll_interval
|
||||||
self.use_notify = use_notify
|
self.use_notify = use_notify
|
||||||
|
|
||||||
@@ -180,7 +181,7 @@ class AdsHub:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _device_notification_callback(self, addr, notification, huser):
|
def _device_notification_callback(self, addr, notification, huser):
|
||||||
"""Callback for device notifications."""
|
"""Handle device notifications."""
|
||||||
from pyads import PLCTYPE_BOOL, PLCTYPE_INT, PLCTYPE_BYTE, PLCTYPE_UINT
|
from pyads import PLCTYPE_BOOL, PLCTYPE_INT, PLCTYPE_BYTE, PLCTYPE_UINT
|
||||||
contents = notification.contents
|
contents = notification.contents
|
||||||
|
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
"""
|
"""Support for ADS binary sensors."""
|
||||||
Support for ADS binary sensors.
|
|
||||||
|
|
||||||
"""
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
@@ -32,7 +30,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Set up the Binary Sensor platform for ADS. """
|
"""Set up the Binary Sensor platform for ADS."""
|
||||||
ads_hub = hass.data.get(DATA_ADS)
|
ads_hub = hass.data.get(DATA_ADS)
|
||||||
if not ads_hub:
|
if not ads_hub:
|
||||||
return False
|
return False
|
||||||
@@ -60,6 +58,7 @@ class AdsBinarySensor(BinarySensorDevice):
|
|||||||
|
|
||||||
def __init__(self, ads_hub, name, adsvar, device_class, use_notify,
|
def __init__(self, ads_hub, name, adsvar, device_class, use_notify,
|
||||||
poll_interval):
|
poll_interval):
|
||||||
|
"""Initialize AdsBinarySensor entity."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = False
|
self._state = False
|
||||||
self._device_class = device_class or 'moving'
|
self._device_class = device_class or 'moving'
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
"""
|
"""Support for ADS light sources."""
|
||||||
Support for ADS light sources.
|
|
||||||
"""
|
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
|
|
||||||
@@ -42,6 +41,7 @@ class AdsLight(Light):
|
|||||||
"""Representation of ADS light."""
|
"""Representation of ADS light."""
|
||||||
|
|
||||||
def __init__(self, ads_hub, varname_enable, varname_brightness, devname):
|
def __init__(self, ads_hub, varname_enable, varname_brightness, devname):
|
||||||
|
"""Initialize AdsLight entity."""
|
||||||
self._ads_hub = ads_hub
|
self._ads_hub = ads_hub
|
||||||
self._on_state = False
|
self._on_state = False
|
||||||
self._brightness = 50
|
self._brightness = 50
|
||||||
@@ -52,7 +52,7 @@ class AdsLight(Light):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Return the name of the device if any. """
|
"""Return the name of the device if any."""
|
||||||
return self._devname
|
return self._devname
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -68,7 +68,7 @@ class AdsLight(Light):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
""" If light is on. """
|
"""If light is on."""
|
||||||
return self._on_state
|
return self._on_state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
"""
|
"""Support for ADS sensors."""
|
||||||
Support for ADS sensors.__init__.py
|
|
||||||
|
|
||||||
"""
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@@ -64,6 +62,7 @@ class AdsSensor(Entity):
|
|||||||
|
|
||||||
def __init__(self, ads_hub, adsvar, adstype, devname, unit_of_measurement,
|
def __init__(self, ads_hub, adsvar, adstype, devname, unit_of_measurement,
|
||||||
use_notify, poll_interval, factor):
|
use_notify, poll_interval, factor):
|
||||||
|
"""Initialize AdsSensor entity."""
|
||||||
self._ads_hub = ads_hub
|
self._ads_hub = ads_hub
|
||||||
self._name = devname
|
self._name = devname
|
||||||
self._value = 0
|
self._value = 0
|
||||||
@@ -80,15 +79,17 @@ class AdsSensor(Entity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
"""Return the name of the entity."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Return the state of the device. """
|
"""Return the state of the device."""
|
||||||
return self._value
|
return self._value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
"""Return the unit of measurement."""
|
||||||
return self._unit_of_measurement
|
return self._unit_of_measurement
|
||||||
|
|
||||||
def callback(self, name, value):
|
def callback(self, name, value):
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
"""
|
"""Support for ADS switch platform."""
|
||||||
Support for ADS switch platform.
|
|
||||||
|
|
||||||
"""
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@@ -35,9 +33,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
|
|
||||||
class AdsSwitch(ToggleEntity):
|
class AdsSwitch(ToggleEntity):
|
||||||
""" Representation of an Ads switch device. """
|
"""Representation of an Ads switch device."""
|
||||||
|
|
||||||
def __init__(self, ads_hub, dev_name, ads_var):
|
def __init__(self, ads_hub, dev_name, ads_var):
|
||||||
|
"""Initialize the AdsSwitch entity."""
|
||||||
self._ads_hub = ads_hub
|
self._ads_hub = ads_hub
|
||||||
self._on_state = False
|
self._on_state = False
|
||||||
self.dev_name = dev_name
|
self.dev_name = dev_name
|
||||||
@@ -45,24 +44,28 @@ class AdsSwitch(ToggleEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
"""Return if the switch is turned on."""
|
||||||
return self._on_state
|
return self._on_state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
"""Return the name of the entity."""
|
||||||
return self.dev_name
|
return self.dev_name
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
|
"""Turn the switch on."""
|
||||||
self._ads_hub.write_by_name(self.ads_var, True,
|
self._ads_hub.write_by_name(self.ads_var, True,
|
||||||
self._ads_hub.PLCTYPE_BOOL)
|
self._ads_hub.PLCTYPE_BOOL)
|
||||||
self._on_state = True
|
self._on_state = True
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
|
"""Turn the switch off."""
|
||||||
self._ads_hub.write_by_name(self.ads_var, False,
|
self._ads_hub.write_by_name(self.ads_var, False,
|
||||||
self._ads_hub.PLCTYPE_BOOL)
|
self._ads_hub.PLCTYPE_BOOL)
|
||||||
self._on_state = False
|
self._on_state = False
|
||||||
|
|
||||||
def value_changed(self, val):
|
def value_changed(self, val):
|
||||||
"""Handle changed state change."""
|
"""Handle changed state."""
|
||||||
self._on_state = val
|
self._on_state = val
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user