mirror of
https://github.com/home-assistant/core.git
synced 2025-11-16 14:30:22 +00:00
Update docstrings (#7374)
* Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstrings * Update docstring * Update docstrings * Update docstrings * Fix lint issues * Update docstrings * Revert changes in dict
This commit is contained in:
committed by
Paulus Schoutsen
parent
0e08925259
commit
a4f1f6e724
@@ -14,9 +14,9 @@ from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.util import slugify
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD,
|
||||
CONF_HOST, CONF_PORT,
|
||||
CONF_SENSORS, DEVICE_DEFAULT_NAME)
|
||||
from homeassistant.const import (
|
||||
CONF_USERNAME, CONF_PASSWORD, CONF_HOST, CONF_PORT, CONF_SENSORS,
|
||||
DEVICE_DEFAULT_NAME)
|
||||
from homeassistant.components.sensor import (DOMAIN, PLATFORM_SCHEMA)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -25,23 +25,23 @@ REQUIREMENTS = ['dovado==0.4.1']
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
|
||||
|
||||
SENSOR_UPLOAD = "upload"
|
||||
SENSOR_DOWNLOAD = "download"
|
||||
SENSOR_SIGNAL = "signal"
|
||||
SENSOR_NETWORK = "network"
|
||||
SENSOR_SMS_UNREAD = "sms"
|
||||
SENSOR_UPLOAD = 'upload'
|
||||
SENSOR_DOWNLOAD = 'download'
|
||||
SENSOR_SIGNAL = 'signal'
|
||||
SENSOR_NETWORK = 'network'
|
||||
SENSOR_SMS_UNREAD = 'sms'
|
||||
|
||||
SENSORS = {
|
||||
SENSOR_NETWORK: ("signal strength", "Network", None,
|
||||
"mdi:access-point-network"),
|
||||
SENSOR_SIGNAL: ("signal strength", "Signal Strength", "%",
|
||||
"mdi:signal"),
|
||||
SENSOR_SMS_UNREAD: ("sms unread", "SMS unread", "",
|
||||
"mdi:message-text-outline"),
|
||||
SENSOR_UPLOAD: ("traffic modem tx", "Sent", "GB",
|
||||
"mdi:cloud-upload"),
|
||||
SENSOR_DOWNLOAD: ("traffic modem rx", "Received", "GB",
|
||||
"mdi:cloud-download"),
|
||||
SENSOR_NETWORK: ('signal strength', 'Network', None,
|
||||
'mdi:access-point-network'),
|
||||
SENSOR_SIGNAL: ('signal strength', 'Signal Strength', '%',
|
||||
'mdi:signal'),
|
||||
SENSOR_SMS_UNREAD: ('sms unread', 'SMS unread', '',
|
||||
'mdi:message-text-outline'),
|
||||
SENSOR_UPLOAD: ('traffic modem tx', 'Sent', 'GB',
|
||||
'mdi:cloud-upload'),
|
||||
SENSOR_DOWNLOAD: ('traffic modem rx', 'Received', 'GB',
|
||||
'mdi:cloud-download'),
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
@@ -55,7 +55,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the dovado platform for sensors."""
|
||||
"""Set up the Dovado platform for sensors."""
|
||||
return Dovado().setup(hass, config, add_devices)
|
||||
|
||||
|
||||
@@ -68,28 +68,24 @@ class Dovado:
|
||||
self._dovado = None
|
||||
|
||||
def setup(self, hass, config, add_devices):
|
||||
"""Setup the connection."""
|
||||
"""Set up the connection."""
|
||||
import dovado
|
||||
self._dovado = dovado.Dovado(
|
||||
config.get(CONF_USERNAME),
|
||||
config.get(CONF_PASSWORD),
|
||||
config.get(CONF_HOST),
|
||||
config.get(CONF_PORT))
|
||||
config.get(CONF_USERNAME), config.get(CONF_PASSWORD),
|
||||
config.get(CONF_HOST), config.get(CONF_PORT))
|
||||
|
||||
if not self.update():
|
||||
return False
|
||||
|
||||
def send_sms(service):
|
||||
"""Send SMS through the router."""
|
||||
number = service.data.get("number"),
|
||||
message = service.data.get("message")
|
||||
_LOGGER.debug("message for %s: %s",
|
||||
number, message)
|
||||
number = service.data.get('number'),
|
||||
message = service.data.get('message')
|
||||
_LOGGER.debug("message for %s: %s", number, message)
|
||||
self._dovado.send_sms(number, message)
|
||||
|
||||
if self.state.get("sms") == "enabled":
|
||||
service_name = slugify("{} {}".format(self.name,
|
||||
"send_sms"))
|
||||
if self.state.get('sms') == 'enabled':
|
||||
service_name = slugify("{} {}".format(self.name, 'send_sms'))
|
||||
hass.services.register(DOMAIN, service_name, send_sms)
|
||||
|
||||
for sensor in SENSORS:
|
||||
@@ -153,8 +149,7 @@ class DovadoSensor(Entity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return "{} {}".format(self._dovado.name,
|
||||
SENSORS[self._sensor][1])
|
||||
return "{} {}".format(self._dovado.name, SENSORS[self._sensor][1])
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@@ -175,4 +170,4 @@ class DovadoSensor(Entity):
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return {k: v for k, v in self._dovado.state.items()
|
||||
if k not in ["date", "time"]}
|
||||
if k not in ['date', 'time']}
|
||||
|
||||
Reference in New Issue
Block a user