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