mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
commit
d4e2332ce0
@ -14,6 +14,7 @@ import requests
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.event import track_point_in_utc_time
|
from homeassistant.helpers.event import track_point_in_utc_time
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
from homeassistant.util import slugify
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
@ -87,7 +88,7 @@ def setup_scanner(hass, config, see):
|
|||||||
vehicle_url = rel["vehicle"] + '/'
|
vehicle_url = rel["vehicle"] + '/'
|
||||||
attributes = query("attributes", vehicle_url)
|
attributes = query("attributes", vehicle_url)
|
||||||
|
|
||||||
dev_id = "volvo_" + attributes["registrationNumber"]
|
dev_id = "volvo_" + slugify(attributes["registrationNumber"])
|
||||||
host_name = "%s %s/%s" % (attributes["registrationNumber"],
|
host_name = "%s %s/%s" % (attributes["registrationNumber"],
|
||||||
attributes["vehicleType"],
|
attributes["vehicleType"],
|
||||||
attributes["modelYear"])
|
attributes["modelYear"])
|
||||||
|
@ -353,7 +353,8 @@ def _get_devices(device_type, keys):
|
|||||||
name = _create_ha_name(
|
name = _create_ha_name(
|
||||||
name=device.NAME,
|
name=device.NAME,
|
||||||
channel=channel,
|
channel=channel,
|
||||||
param=param
|
param=param,
|
||||||
|
count=len(channels)
|
||||||
)
|
)
|
||||||
device_dict = {
|
device_dict = {
|
||||||
CONF_PLATFORM: "homematic",
|
CONF_PLATFORM: "homematic",
|
||||||
@ -377,22 +378,22 @@ def _get_devices(device_type, keys):
|
|||||||
return device_arr
|
return device_arr
|
||||||
|
|
||||||
|
|
||||||
def _create_ha_name(name, channel, param):
|
def _create_ha_name(name, channel, param, count):
|
||||||
"""Generate a unique object name."""
|
"""Generate a unique object name."""
|
||||||
# HMDevice is a simple device
|
# HMDevice is a simple device
|
||||||
if channel == 1 and param is None:
|
if count == 1 and param is None:
|
||||||
return name
|
return name
|
||||||
|
|
||||||
# Has multiple elements/channels
|
# Has multiple elements/channels
|
||||||
if channel > 1 and param is None:
|
if count > 1 and param is None:
|
||||||
return "{} {}".format(name, channel)
|
return "{} {}".format(name, channel)
|
||||||
|
|
||||||
# With multiple param first elements
|
# With multiple param first elements
|
||||||
if channel == 1 and param is not None:
|
if count == 1 and param is not None:
|
||||||
return "{} {}".format(name, param)
|
return "{} {}".format(name, param)
|
||||||
|
|
||||||
# Multiple param on object with multiple elements
|
# Multiple param on object with multiple elements
|
||||||
if channel > 1 and param is not None:
|
if count > 1 and param is not None:
|
||||||
return "{} {} {}".format(name, channel, param)
|
return "{} {} {}".format(name, channel, param)
|
||||||
|
|
||||||
|
|
||||||
@ -600,12 +601,6 @@ class HMDevice(Entity):
|
|||||||
if self._state:
|
if self._state:
|
||||||
self._state = self._state.upper()
|
self._state = self._state.upper()
|
||||||
|
|
||||||
# Generate name
|
|
||||||
if not self._name:
|
|
||||||
self._name = _create_ha_name(name=self._address,
|
|
||||||
channel=self._channel,
|
|
||||||
param=self._state)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
"""Return false. Homematic states are pushed by the XML RPC Server."""
|
"""Return false. Homematic states are pushed by the XML RPC Server."""
|
||||||
|
@ -100,8 +100,8 @@ def setup(hass, config):
|
|||||||
kwargs[ATTR_TITLE] = title.render()
|
kwargs[ATTR_TITLE] = title.render()
|
||||||
|
|
||||||
if targets.get(call.service) is not None:
|
if targets.get(call.service) is not None:
|
||||||
kwargs[ATTR_TARGET] = targets[call.service]
|
kwargs[ATTR_TARGET] = [targets[call.service]]
|
||||||
else:
|
elif call.data.get(ATTR_TARGET) is not None:
|
||||||
kwargs[ATTR_TARGET] = call.data.get(ATTR_TARGET)
|
kwargs[ATTR_TARGET] = call.data.get(ATTR_TARGET)
|
||||||
|
|
||||||
message.hass = hass
|
message.hass = hass
|
||||||
|
@ -344,12 +344,15 @@ class HTML5NotificationService(BaseNotificationService):
|
|||||||
# Pick out fields that should go into the notification directly vs
|
# Pick out fields that should go into the notification directly vs
|
||||||
# into the notification data dictionary.
|
# into the notification data dictionary.
|
||||||
|
|
||||||
for key, val in data.copy().items():
|
data_tmp = {}
|
||||||
|
|
||||||
|
for key, val in data.items():
|
||||||
if key in HTML5_SHOWNOTIFICATION_PARAMETERS:
|
if key in HTML5_SHOWNOTIFICATION_PARAMETERS:
|
||||||
payload[key] = val
|
payload[key] = val
|
||||||
del data[key]
|
else:
|
||||||
|
data_tmp[key] = val
|
||||||
|
|
||||||
payload[ATTR_DATA] = data
|
payload[ATTR_DATA] = data_tmp
|
||||||
|
|
||||||
if (payload[ATTR_DATA].get(ATTR_URL) is None and
|
if (payload[ATTR_DATA].get(ATTR_URL) is None and
|
||||||
payload.get(ATTR_ACTIONS) is None):
|
payload.get(ATTR_ACTIONS) is None):
|
||||||
|
@ -63,6 +63,9 @@ class PushoverNotificationService(BaseNotificationService):
|
|||||||
|
|
||||||
targets = kwargs.get(ATTR_TARGET)
|
targets = kwargs.get(ATTR_TARGET)
|
||||||
|
|
||||||
|
if not isinstance(targets, list):
|
||||||
|
targets = [targets]
|
||||||
|
|
||||||
for target in targets:
|
for target in targets:
|
||||||
if target is not None:
|
if target is not None:
|
||||||
data['device'] = target
|
data['device'] = target
|
||||||
|
@ -68,7 +68,10 @@ class SlackNotificationService(BaseNotificationService):
|
|||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
import slacker
|
import slacker
|
||||||
|
|
||||||
targets = kwargs.get(ATTR_TARGET, [self._default_channel])
|
if kwargs.get(ATTR_TARGET) is None:
|
||||||
|
targets = [self._default_channel]
|
||||||
|
else:
|
||||||
|
targets = kwargs.get(ATTR_TARGET)
|
||||||
|
|
||||||
data = kwargs.get('data')
|
data = kwargs.get('data')
|
||||||
attachments = data.get('attachments') if data else None
|
attachments = data.get('attachments') if data else None
|
||||||
|
@ -55,7 +55,7 @@ CONFIG_SCHEMA = vol.Schema({
|
|||||||
|
|
||||||
PLATFORM_SCHEMA = vol.Schema({
|
PLATFORM_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_NAME): cv.string,
|
vol.Required(CONF_NAME): cv.string,
|
||||||
vol.Required(CONF_PIN): cv.positive_int,
|
vol.Optional(CONF_PIN): cv.positive_int,
|
||||||
vol.Optional(CONF_ADDRESS): cv.string,
|
vol.Optional(CONF_ADDRESS): cv.string,
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"""Constants used by Home Assistant components."""
|
"""Constants used by Home Assistant components."""
|
||||||
MAJOR_VERSION = 0
|
MAJOR_VERSION = 0
|
||||||
MINOR_VERSION = 30
|
MINOR_VERSION = 30
|
||||||
PATCH_VERSION = '1'
|
PATCH_VERSION = '2'
|
||||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||||
REQUIRED_PYTHON_VER = (3, 4, 2)
|
REQUIRED_PYTHON_VER = (3, 4, 2)
|
||||||
|
@ -64,7 +64,6 @@ class TestNotifyDemo(unittest.TestCase):
|
|||||||
data = self.events[0].data
|
data = self.events[0].data
|
||||||
assert {
|
assert {
|
||||||
'message': 'my message',
|
'message': 'my message',
|
||||||
'target': None,
|
|
||||||
'title': 'my title',
|
'title': 'my title',
|
||||||
'data': {'hello': 'world'}
|
'data': {'hello': 'world'}
|
||||||
} == data
|
} == data
|
||||||
@ -92,7 +91,6 @@ data_template:
|
|||||||
self.assertTrue(len(self.events) == 1)
|
self.assertTrue(len(self.events) == 1)
|
||||||
assert {
|
assert {
|
||||||
'message': 'Test 123 4',
|
'message': 'Test 123 4',
|
||||||
'target': None,
|
|
||||||
'data': {
|
'data': {
|
||||||
'push': {
|
'push': {
|
||||||
'sound':
|
'sound':
|
||||||
@ -124,7 +122,6 @@ data_template:
|
|||||||
assert {
|
assert {
|
||||||
'message': 'Test 123 4',
|
'message': 'Test 123 4',
|
||||||
'title': 'Test',
|
'title': 'Test',
|
||||||
'target': None,
|
|
||||||
'data': {
|
'data': {
|
||||||
'push': {
|
'push': {
|
||||||
'sound':
|
'sound':
|
||||||
@ -152,7 +149,7 @@ data_template:
|
|||||||
|
|
||||||
assert {
|
assert {
|
||||||
'message': 'my message',
|
'message': 'my message',
|
||||||
'target': 'test target id',
|
'target': ['test target id'],
|
||||||
'title': 'my title',
|
'title': 'my title',
|
||||||
'data': {'hello': 'world'}
|
'data': {'hello': 'world'}
|
||||||
} == data
|
} == data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user