Merge pull request #8141 from home-assistant/release-0-47-1

0.47.1
This commit is contained in:
Paulus Schoutsen 2017-06-21 09:24:12 -07:00 committed by GitHub
commit 9252854f99
9 changed files with 55 additions and 16 deletions

View File

@ -75,7 +75,7 @@ class DysonPureCoolLinkDevice(FanEntity):
def async_added_to_hass(self):
"""Callback when entity is added to hass."""
self.hass.async_add_job(
self._device.add_message_listener(self.on_message))
self._device.add_message_listener, self.on_message)
def on_message(self, message):
"""Called when new messages received from the fan."""

View File

@ -58,6 +58,9 @@ CONFIG_SCHEMA = vol.Schema({
}),
}, extra=vol.ALLOW_EXTRA)
RE_DIGIT_TAIL = re.compile(r'^[^\.]*\d+\.?\d+[^\.]*$')
RE_DECIMAL = re.compile(r'[^\d.]+')
def setup(hass, config):
"""Set up the InfluxDB component."""
@ -149,8 +152,6 @@ def setup(hass, config):
}
]
non_digit_tail = re.compile(r'[\d.]+')
non_decimal = re.compile(r'[^\d.]+')
for key, value in state.attributes.items():
if key != 'unit_of_measurement':
# If the key is already in fields
@ -164,10 +165,12 @@ def setup(hass, config):
json_body[0]['fields'][key] = float(value)
except (ValueError, TypeError):
new_key = "{}_str".format(key)
json_body[0]['fields'][new_key] = str(value)
if non_digit_tail.match(json_body[0]['fields'][new_key]):
new_value = str(value)
json_body[0]['fields'][new_key] = new_value
if RE_DIGIT_TAIL.match(new_value):
json_body[0]['fields'][key] = float(
non_decimal.sub('', value))
RE_DECIMAL.sub('', new_value))
json_body[0]['tags'].update(tags)

View File

@ -79,5 +79,8 @@ class VeraLight(VeraDevice, Light):
def update(self):
"""Call to update state."""
self._state = self.vera_device.is_switched_on()
if self.vera_device.is_dimmable:
# If it is dimmable, both functions exist. In case color
# is not supported, it will return None
self._brightness = self.vera_device.get_brightness()
self._color = self.vera_device.get_color()

View File

@ -92,6 +92,7 @@ def execute(hass, filename, source, data=None):
'_print_': StubPrinter,
'_getattr_': protected_getattr,
'_write_': full_write_guard,
'_getiter_': iter,
}
logger = logging.getLogger('{}.{}'.format(__name__, filename))
local = {

View File

@ -62,10 +62,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
name = data.get(CONF_NAME)
modaddr = int(data.get(CONF_MODADDR, 1))
connaddr = int(data.get(CONF_CONNADDR, 1))
cmddata = ""
cmddatas = ""
for cmd in data.get(CONF_COMMANDS):
cmddata += cmd[CONF_NAME] + "\n" + cmd[CONF_DATA] + "\n"
itachip2ir.addDevice(name, modaddr, connaddr, cmddata)
cmdname = cmd[CONF_NAME].strip()
if not cmdname:
cmdname = '""'
cmddata = cmd[CONF_DATA].strip()
if not cmddata:
cmddata = '""'
cmddatas += "{}\n{}\n".format(cmdname, cmddata)
itachip2ir.addDevice(name, modaddr, connaddr, cmddatas)
devices.append(ITachIP2IRRemote(itachip2ir, name))
add_devices(devices, True)
return True

View File

@ -38,7 +38,7 @@ class DysonFilterLifeSensor(Entity):
def async_added_to_hass(self):
"""Callback when entity is added to hass."""
self.hass.async_add_job(
self._device.add_message_listener(self.on_message))
self._device.add_message_listener, self.on_message)
def on_message(self, message):
"""Called when new messages received from the fan."""

View File

@ -2,7 +2,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 0
MINOR_VERSION = 47
PATCH_VERSION = '0'
PATCH_VERSION = '1'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 4, 2)

View File

@ -1,5 +1,6 @@
"""The tests for the InfluxDB component."""
import unittest
import datetime
from unittest import mock
import influxdb as influx_client
@ -123,7 +124,9 @@ class TestInfluxDB(unittest.TestCase):
'latitude': '2.2',
'battery_level': '99%',
'temperature': '20c',
'last_seen': 'Last seen 23 minutes ago'
'last_seen': 'Last seen 23 minutes ago',
'updated_at': datetime.datetime(2017, 1, 1, 0, 0),
'multi_periods': '0.120.240.2023873'
}
state = mock.MagicMock(
state=in_, domain='fake', object_id='entity', attributes=attrs)
@ -144,7 +147,11 @@ class TestInfluxDB(unittest.TestCase):
'battery_level': 99.0,
'temperature_str': '20c',
'temperature': 20.0,
'last_seen_str': 'Last seen 23 minutes ago'
'last_seen_str': 'Last seen 23 minutes ago',
'last_seen': 23.0,
'updated_at_str': '2017-01-01 00:00:00',
'updated_at': 20170101000000,
'multi_periods_str': '0.120.240.2023873'
},
}]
@ -164,7 +171,11 @@ class TestInfluxDB(unittest.TestCase):
'battery_level': 99.0,
'temperature_str': '20c',
'temperature': 20.0,
'last_seen_str': 'Last seen 23 minutes ago'
'last_seen_str': 'Last seen 23 minutes ago',
'last_seen': 23.0,
'updated_at_str': '2017-01-01 00:00:00',
'updated_at': 20170101000000,
'multi_periods_str': '0.120.240.2023873'
},
}]
self.handler_method(event)

View File

@ -149,3 +149,18 @@ hass.stop()
yield from hass.async_block_till_done()
assert "Not allowed to access HomeAssistant.stop" in caplog.text
@asyncio.coroutine
def test_iterating(hass):
"""Test compile error logs error."""
source = """
for i in [1, 2]:
hass.states.set('hello.{}'.format(i), 'world')
"""
hass.async_add_job(execute, hass, 'test.py', source, {})
yield from hass.async_block_till_done()
assert hass.states.is_state('hello.1', 'world')
assert hass.states.is_state('hello.2', 'world')