Maintenance (#4101)

* UPdate ordering, fix typos, and align logger messages

* Update import style, fix PEP257 issue, and align logger messages

* Updaate import style and align logger messages

* Update import style and align logger messages

* Update ordering

* Update import style and ordering

* Update quotes

* Make logger messages more clear

* Fix indentation
pull/4038/merge
Fabian Affolter 2016-10-29 18:12:43 +02:00 committed by Paulus Schoutsen
parent 5a2b4a5376
commit d4b3f56d53
9 changed files with 150 additions and 175 deletions

View File

@ -4,23 +4,19 @@ Support for Concord232 alarm control panels.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/alarm_control_panel.concord232/
"""
import datetime
import logging
import requests
import voluptuous as vol
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_HOST, CONF_NAME, CONF_PORT,
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME,
STATE_ALARM_DISARMED, STATE_UNKNOWN)
CONF_HOST, CONF_NAME, CONF_PORT, STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_UNKNOWN)
import homeassistant.helpers.config_validation as cv
import requests
import voluptuous as vol
REQUIREMENTS = ['concord232==0.14']
_LOGGER = logging.getLogger(__name__)
@ -29,17 +25,17 @@ DEFAULT_HOST = 'localhost'
DEFAULT_NAME = 'CONCORD232'
DEFAULT_PORT = 5007
SCAN_INTERVAL = 1
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
})
SCAN_INTERVAL = 1
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup concord232 platform."""
"""Set up the Concord232 alarm control panel platform."""
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
@ -49,7 +45,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
try:
add_devices([Concord232Alarm(hass, url, name)])
except requests.exceptions.ConnectionError as ex:
_LOGGER.error('Unable to connect to Concord232: %s', str(ex))
_LOGGER.error("Unable to connect to Concord232: %s", str(ex))
return False
@ -57,7 +53,7 @@ class Concord232Alarm(alarm.AlarmControlPanel):
"""Represents the Concord232-based alarm panel."""
def __init__(self, hass, url, name):
"""Initalize the concord232 alarm panel."""
"""Initialize the Concord232 alarm panel."""
from concord232 import client as concord232_client
self._state = STATE_UNKNOWN
@ -68,7 +64,7 @@ class Concord232Alarm(alarm.AlarmControlPanel):
try:
client = concord232_client.Client(self._url)
except requests.exceptions.ConnectionError as ex:
_LOGGER.error('Unable to connect to Concord232: %s', str(ex))
_LOGGER.error("Unable to connect to Concord232: %s", str(ex))
self._alarm = client
self._alarm.partitions = self._alarm.list_partitions()
@ -100,16 +96,16 @@ class Concord232Alarm(alarm.AlarmControlPanel):
try:
part = self._alarm.list_partitions()[0]
except requests.exceptions.ConnectionError as ex:
_LOGGER.error('Unable to connect to %(host)s: %(reason)s',
_LOGGER.error("Unable to connect to %(host)s: %(reason)s",
dict(host=self._url, reason=ex))
newstate = STATE_UNKNOWN
except IndexError:
_LOGGER.error('concord232 reports no partitions')
_LOGGER.error("Concord232 reports no partitions")
newstate = STATE_UNKNOWN
if part['arming_level'] == "Off":
if part['arming_level'] == 'Off':
newstate = STATE_ALARM_DISARMED
elif "Home" in part['arming_level']:
elif 'Home' in part['arming_level']:
newstate = STATE_ALARM_ARMED_HOME
else:
newstate = STATE_ALARM_ARMED_AWAY

View File

@ -5,25 +5,22 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/alarm_control_panel.envisalink/
"""
import logging
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.envisalink import (EVL_CONTROLLER,
EnvisalinkDevice,
PARTITION_SCHEMA,
CONF_CODE,
CONF_PANIC,
CONF_PARTITIONNAME,
SIGNAL_PARTITION_UPDATE,
SIGNAL_KEYPAD_UPDATE)
from homeassistant.components.envisalink import (
EVL_CONTROLLER, EnvisalinkDevice, PARTITION_SCHEMA, CONF_CODE, CONF_PANIC,
CONF_PARTITIONNAME, SIGNAL_PARTITION_UPDATE, SIGNAL_KEYPAD_UPDATE)
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED,
STATE_UNKNOWN, STATE_ALARM_TRIGGERED)
DEPENDENCIES = ['envisalink']
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['envisalink']
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Perform the setup for Envisalink alarm panels."""
_configured_partitions = discovery_info['partitions']
_code = discovery_info[CONF_CODE]
@ -38,30 +35,30 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
_panic_type,
EVL_CONTROLLER.alarm_state['partition'][part_num],
EVL_CONTROLLER)
add_devices_callback([_device])
add_devices([_device])
return True
class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel):
"""Represents the Envisalink-based alarm panel."""
"""Representation of an Envisalink-based alarm panel."""
# pylint: disable=too-many-arguments
def __init__(self, partition_number, alarm_name,
code, panic_type, info, controller):
def __init__(self, partition_number, alarm_name, code, panic_type, info,
controller):
"""Initialize the alarm panel."""
from pydispatch import dispatcher
self._partition_number = partition_number
self._code = code
self._panic_type = panic_type
_LOGGER.debug('Setting up alarm: ' + alarm_name)
_LOGGER.debug("Setting up alarm: %s", alarm_name)
EnvisalinkDevice.__init__(self, alarm_name, info, controller)
dispatcher.connect(self._update_callback,
signal=SIGNAL_PARTITION_UPDATE,
sender=dispatcher.Any)
dispatcher.connect(self._update_callback,
signal=SIGNAL_KEYPAD_UPDATE,
sender=dispatcher.Any)
dispatcher.connect(
self._update_callback, signal=SIGNAL_PARTITION_UPDATE,
sender=dispatcher.Any)
dispatcher.connect(
self._update_callback, signal=SIGNAL_KEYPAD_UPDATE,
sender=dispatcher.Any)
def _update_callback(self, partition):
"""Update HA state, if needed."""
@ -90,20 +87,20 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel):
def alarm_disarm(self, code=None):
"""Send disarm command."""
if self._code:
EVL_CONTROLLER.disarm_partition(str(code),
self._partition_number)
EVL_CONTROLLER.disarm_partition(
str(code), self._partition_number)
def alarm_arm_home(self, code=None):
"""Send arm home command."""
if self._code:
EVL_CONTROLLER.arm_stay_partition(str(code),
self._partition_number)
EVL_CONTROLLER.arm_stay_partition(
str(code), self._partition_number)
def alarm_arm_away(self, code=None):
"""Send arm away command."""
if self._code:
EVL_CONTROLLER.arm_away_partition(str(code),
self._partition_number)
EVL_CONTROLLER.arm_away_partition(
str(code), self._partition_number)
def alarm_trigger(self, code=None):
"""Alarm trigger command. Will be used to trigger a panic alarm."""

View File

@ -5,20 +5,16 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.concord232/
"""
import datetime
import logging
import requests
import voluptuous as vol
from homeassistant.components.binary_sensor import (
BinarySensorDevice, PLATFORM_SCHEMA, SENSOR_CLASSES)
from homeassistant.const import (CONF_HOST, CONF_PORT)
import homeassistant.helpers.config_validation as cv
import requests
import voluptuous as vol
REQUIREMENTS = ['concord232==0.14']
_LOGGER = logging.getLogger(__name__)
@ -27,9 +23,12 @@ CONF_EXCLUDE_ZONES = 'exclude_zones'
CONF_ZONE_TYPES = 'zone_types'
DEFAULT_HOST = 'localhost'
DEFAULT_NAME = 'Alarm'
DEFAULT_PORT = '5007'
DEFAULT_SSL = False
SCAN_INTERVAL = 1
ZONE_TYPES_SCHEMA = vol.Schema({
cv.positive_int: vol.In(SENSOR_CLASSES),
})
@ -42,14 +41,10 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_ZONE_TYPES, default={}): ZONE_TYPES_SCHEMA,
})
SCAN_INTERVAL = 1
DEFAULT_NAME = "Alarm"
# pylint: disable=too-many-locals
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Concord232 binary sensor platform."""
"""Set up the Concord232 binary sensor platform."""
from concord232 import client as concord232_client
host = config.get(CONF_HOST)
@ -59,24 +54,23 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
sensors = []
try:
_LOGGER.debug('Initializing Client.')
client = concord232_client.Client('http://{}:{}'
.format(host, port))
_LOGGER.debug("Initializing Client")
client = concord232_client.Client('http://{}:{}'.format(host, port))
client.zones = client.list_zones()
client.last_zone_update = datetime.datetime.now()
except requests.exceptions.ConnectionError as ex:
_LOGGER.error('Unable to connect to Concord232: %s', str(ex))
_LOGGER.error("Unable to connect to Concord232: %s", str(ex))
return False
for zone in client.zones:
_LOGGER.info('Loading Zone found: %s', zone['name'])
_LOGGER.info("Loading Zone found: %s", zone['name'])
if zone['number'] not in exclude:
sensors.append(Concord232ZoneSensor(
hass,
client,
zone,
zone_types.get(zone['number'], get_opening_type(zone))))
sensors.append(
Concord232ZoneSensor(
hass, client, zone, zone_types.get(zone['number'],
get_opening_type(zone)))
)
add_devices(sensors)
@ -84,16 +78,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
def get_opening_type(zone):
"""Helper function to try to guess sensor type frm name."""
if "MOTION" in zone["name"]:
return "motion"
if "KEY" in zone["name"]:
return "safety"
if "SMOKE" in zone["name"]:
return "smoke"
if "WATER" in zone["name"]:
return "water"
return "opening"
"""Helper function to try to guess sensor type from name."""
if 'MOTION' in zone['name']:
return 'motion'
if 'KEY' in zone['name']:
return 'safety'
if 'SMOKE' in zone['name']:
return 'smoke'
if 'WATER' in zone['name']:
return 'water'
return 'opening'
class Concord232ZoneSensor(BinarySensorDevice):

View File

@ -13,9 +13,9 @@ from homeassistant.components.notify import (
ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService)
from homeassistant.const import CONF_API_KEY, CONF_SENDER
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['messagebird==1.2.0']
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,

View File

@ -6,14 +6,14 @@ https://home-assistant.io/components/notify.nfandroidtv/
"""
import os
import logging
import requests
import voluptuous as vol
from homeassistant.components.notify import (ATTR_TITLE,
ATTR_TITLE_DEFAULT,
ATTR_DATA,
BaseNotificationService,
PLATFORM_SCHEMA)
from homeassistant.components.notify import (
ATTR_TITLE, ATTR_TITLE_DEFAULT, ATTR_DATA, BaseNotificationService,
PLATFORM_SCHEMA)
from homeassistant.const import CONF_TIMEOUT
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
@ -24,7 +24,6 @@ CONF_POSITION = 'position'
CONF_TRANSPARENCY = 'transparency'
CONF_COLOR = 'color'
CONF_INTERRUPT = 'interrupt'
CONF_TIMEOUT = 'timeout'
DEFAULT_DURATION = 5
DEFAULT_POSITION = 'bottom-right'
@ -41,32 +40,32 @@ ATTR_BKGCOLOR = 'bkgcolor'
ATTR_INTERRUPT = 'interrupt'
POSITIONS = {
"bottom-right": 0,
"bottom-left": 1,
"top-right": 2,
"top-left": 3,
"center": 4,
'bottom-right': 0,
'bottom-left': 1,
'top-right': 2,
'top-left': 3,
'center': 4,
}
TRANSPARENCIES = {
"default": 0,
"0%": 1,
"25%": 2,
"50%": 3,
"75%": 4,
"100%": 5,
'default': 0,
'0%': 1,
'25%': 2,
'50%': 3,
'75%': 4,
'100%': 5,
}
COLORS = {
"grey": "#607d8b",
"black": "#000000",
"indigo": "#303F9F",
"green": "#4CAF50",
"red": "#F44336",
"cyan": "#00BCD4",
"teal": "#009688",
"amber": "#FFC107",
"pink": "#E91E63",
'grey': '#607d8b',
'black': '#000000',
'indigo': '#303F9F',
'green': '#4CAF50',
'red': '#F44336',
'cyan': '#00BCD4',
'teal': '#009688',
'amber': '#FFC107',
'pink': '#E91E63',
}
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@ -95,13 +94,8 @@ def get_service(hass, config):
interrupt = config.get(CONF_INTERRUPT)
timeout = config.get(CONF_TIMEOUT)
return NFAndroidTVNotificationService(remoteip,
duration,
position,
transparency,
color,
interrupt,
timeout)
return NFAndroidTVNotificationService(
remoteip, duration, position, transparency, color, interrupt, timeout)
# pylint: disable=too-many-instance-attributes
@ -109,20 +103,19 @@ class NFAndroidTVNotificationService(BaseNotificationService):
"""Notification service for Notifications for Android TV."""
# pylint: disable=too-many-arguments,too-few-public-methods
def __init__(self, remoteip, duration, position, transparency,
color, interrupt, timeout):
def __init__(self, remoteip, duration, position, transparency, color,
interrupt, timeout):
"""Initialize the service."""
self._target = "http://%s:7676" % remoteip
self._target = 'http://{}:7676'.format(remoteip)
self._default_duration = duration
self._default_position = position
self._default_transparency = transparency
self._default_color = color
self._default_interrupt = interrupt
self._timeout = timeout
self._icon_file = os.path.join(os.path.dirname(__file__), "..",
"frontend",
"www_static", "icons",
"favicon-192x192.png")
self._icon_file = os.path.join(
os.path.dirname(__file__), '..', 'frontend', 'www_static', 'icons',
'favicon-192x192.png')
# pylint: disable=too-many-branches
def send_message(self, message="", **kwargs):
@ -132,36 +125,36 @@ class NFAndroidTVNotificationService(BaseNotificationService):
payload = dict(filename=('icon.png',
open(self._icon_file, 'rb'),
'application/octet-stream',
{'Expires': '0'}), type="0",
{'Expires': '0'}), type='0',
title=kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
msg=message, duration="%i" % self._default_duration,
position="%i" % POSITIONS.get(self._default_position),
bkgcolor="%s" % COLORS.get(self._default_color),
transparency="%i" % TRANSPARENCIES.get(
position='%i' % POSITIONS.get(self._default_position),
bkgcolor='%s' % COLORS.get(self._default_color),
transparency='%i' % TRANSPARENCIES.get(
self._default_transparency),
offset="0", app=ATTR_TITLE_DEFAULT, force="true",
interrupt="%i" % self._default_interrupt)
offset='0', app=ATTR_TITLE_DEFAULT, force='true',
interrupt='%i' % self._default_interrupt)
data = kwargs.get(ATTR_DATA)
if data:
if ATTR_DURATION in data:
duration = data.get(ATTR_DURATION)
try:
payload[ATTR_DURATION] = "%i" % int(duration)
payload[ATTR_DURATION] = '%i' % int(duration)
except ValueError:
_LOGGER.warning("Invalid duration-value: %s",
str(duration))
if ATTR_POSITION in data:
position = data.get(ATTR_POSITION)
if position in POSITIONS:
payload[ATTR_POSITION] = "%i" % POSITIONS.get(position)
payload[ATTR_POSITION] = '%i' % POSITIONS.get(position)
else:
_LOGGER.warning("Invalid position-value: %s",
str(position))
if ATTR_TRANSPARENCY in data:
transparency = data.get(ATTR_TRANSPARENCY)
if transparency in TRANSPARENCIES:
payload[ATTR_TRANSPARENCY] = "%i" % TRANSPARENCIES.get(
payload[ATTR_TRANSPARENCY] = '%i' % TRANSPARENCIES.get(
transparency)
else:
_LOGGER.warning("Invalid transparency-value: %s",
@ -169,22 +162,21 @@ class NFAndroidTVNotificationService(BaseNotificationService):
if ATTR_COLOR in data:
color = data.get(ATTR_COLOR)
if color in COLORS:
payload[ATTR_BKGCOLOR] = "%s" % COLORS.get(color)
payload[ATTR_BKGCOLOR] = '%s' % COLORS.get(color)
else:
_LOGGER.warning("Invalid color-value: %s", str(color))
if ATTR_INTERRUPT in data:
interrupt = data.get(ATTR_INTERRUPT)
try:
payload[ATTR_INTERRUPT] = "%i" % cv.boolean(interrupt)
payload[ATTR_INTERRUPT] = '%i' % cv.boolean(interrupt)
except vol.Invalid:
_LOGGER.warning("Invalid interrupt-value: %s",
str(interrupt))
try:
_LOGGER.debug("Payload: %s", str(payload))
response = requests.post(self._target,
files=payload,
timeout=self._timeout)
response = requests.post(
self._target, files=payload, timeout=self._timeout)
if response.status_code != 200:
_LOGGER.error("Error sending message: %s", str(response))
except requests.exceptions.ConnectionError as err:

View File

@ -9,12 +9,13 @@ import logging
import requests
import voluptuous as vol
from homeassistant.components.notify import (BaseNotificationService,
ATTR_TITLE,
PLATFORM_SCHEMA)
from homeassistant.components.notify import (
BaseNotificationService, ATTR_TITLE, PLATFORM_SCHEMA)
from homeassistant.const import CONTENT_TYPE_JSON
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
CONF_CONSUMER_KEY = 'consumer_key'
CONF_CONSUMER_SECRET = 'consumer_secret'
CONF_PHONE_NUMBER = 'phone_number'
@ -25,8 +26,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_PHONE_NUMBER): cv.string,
})
_LOGGER = logging.getLogger(__name__)
def get_service(hass, config):
"""Get the Telstra SMS API notification service."""
@ -34,14 +33,12 @@ def get_service(hass, config):
consumer_secret = config.get(CONF_CONSUMER_SECRET)
phone_number = config.get(CONF_PHONE_NUMBER)
# Attempt an initial authentication to confirm credentials
if _authenticate(consumer_key, consumer_secret) is False:
_LOGGER.exception('Error obtaining authorization from Telstra API')
return None
return TelstraNotificationService(consumer_key,
consumer_secret,
phone_number)
return TelstraNotificationService(
consumer_key, consumer_secret, phone_number)
# pylint: disable=too-few-public-methods, too-many-arguments
@ -59,10 +56,10 @@ class TelstraNotificationService(BaseNotificationService):
title = kwargs.get(ATTR_TITLE)
# Retrieve authorization first
token_response = _authenticate(self._consumer_key,
self._consumer_secret)
token_response = _authenticate(
self._consumer_key, self._consumer_secret)
if token_response is False:
_LOGGER.exception('Error obtaining authorization from Telstra API')
_LOGGER.exception("Error obtaining authorization from Telstra API")
return
# Send the SMS
@ -73,17 +70,16 @@ class TelstraNotificationService(BaseNotificationService):
message_data = {
'to': self._phone_number,
'body': text
'body': text,
}
message_resource = 'https://api.telstra.com/v1/sms/messages'
message_headers = {
'Content-Type': CONTENT_TYPE_JSON,
'Authorization': 'Bearer ' + token_response['access_token']
'Authorization': 'Bearer ' + token_response['access_token'],
}
message_response = requests.post(message_resource,
headers=message_headers,
json=message_data,
timeout=10)
message_response = requests.post(
message_resource, headers=message_headers, json=message_data,
timeout=10)
if message_response.status_code != 202:
_LOGGER.exception("Failed to send SMS. Status code: %d",
@ -99,9 +95,8 @@ def _authenticate(consumer_key, consumer_secret):
'scope': 'SMS'
}
token_resource = 'https://api.telstra.com/v1/oauth/token'
token_response = requests.get(token_resource,
params=token_data,
timeout=10).json()
token_response = requests.get(
token_resource, params=token_data, timeout=10).json()
if 'error' in token_response:
return False

View File

@ -9,16 +9,17 @@ import logging
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.notify import (PLATFORM_SCHEMA,
BaseNotificationService)
from homeassistant.components.notify import (
PLATFORM_SCHEMA, BaseNotificationService)
from homeassistant.const import CONF_ACCESS_TOKEN
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['TwitterAPI==2.4.2']
CONF_CONSUMER_KEY = "consumer_key"
CONF_CONSUMER_SECRET = "consumer_secret"
CONF_ACCESS_TOKEN_SECRET = "access_token_secret"
_LOGGER = logging.getLogger(__name__)
CONF_CONSUMER_KEY = 'consumer_key'
CONF_CONSUMER_SECRET = 'consumer_secret'
CONF_ACCESS_TOKEN_SECRET = 'access_token_secret'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_CONSUMER_KEY): cv.string,
@ -30,15 +31,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def get_service(hass, config):
"""Get the Twitter notification service."""
return TwitterNotificationService(config[CONF_CONSUMER_KEY],
config[CONF_CONSUMER_SECRET],
config[CONF_ACCESS_TOKEN],
config[CONF_ACCESS_TOKEN_SECRET])
return TwitterNotificationService(
config[CONF_CONSUMER_KEY], config[CONF_CONSUMER_SECRET],
config[CONF_ACCESS_TOKEN], config[CONF_ACCESS_TOKEN_SECRET]
)
# pylint: disable=too-few-public-methods
class TwitterNotificationService(BaseNotificationService):
"""Implement notification service for the Twitter service."""
"""Implementation of a notification service for the Twitter service."""
def __init__(self, consumer_key, consumer_secret, access_token_key,
access_token_secret):

View File

@ -9,15 +9,15 @@ import logging
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.notify import (BaseNotificationService,
PLATFORM_SCHEMA)
from homeassistant.components.notify import (
BaseNotificationService, PLATFORM_SCHEMA)
from homeassistant.const import CONF_HOST
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['https://github.com/TheRealLink/pylgtv'
'/archive/v0.1.2.zip'
REQUIREMENTS = ['https://github.com/TheRealLink/pylgtv/archive/v0.1.2.zip'
'#pylgtv==0.1.2']
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
@ -34,10 +34,10 @@ def get_service(hass, config):
try:
client.register()
except PyLGTVPairException:
_LOGGER.error('Pairing failed.')
_LOGGER.error("Pairing with TV failed")
return None
except OSError:
_LOGGER.error('Host unreachable.')
_LOGGER.error("TV unreachable")
return None
return LgWebOSNotificationService(client)
@ -58,6 +58,6 @@ class LgWebOSNotificationService(BaseNotificationService):
try:
self._client.send_message(message)
except PyLGTVPairException:
_LOGGER.error('Pairing failed.')
_LOGGER.error("Pairing with TV failed")
except OSError:
_LOGGER.error('Host unreachable.')
_LOGGER.error("TV unreachable")

View File

@ -53,7 +53,7 @@ class XmppNotificationService(BaseNotificationService):
def send_message(self, message="", **kwargs):
"""Send a message to a user."""
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
data = "{}: {}".format(title, message) if title else message
data = '{}: {}'.format(title, message) if title else message
send_message(self._sender + '/home-assistant', self._password,
self._recipient, self._tls, data)