mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
commit
e620479cc8
@ -31,16 +31,17 @@ def async_trigger(hass, config, action):
|
|||||||
event_type = config.get(CONF_EVENT_TYPE)
|
event_type = config.get(CONF_EVENT_TYPE)
|
||||||
event_data_schema = vol.Schema(
|
event_data_schema = vol.Schema(
|
||||||
config.get(CONF_EVENT_DATA),
|
config.get(CONF_EVENT_DATA),
|
||||||
extra=vol.ALLOW_EXTRA)
|
extra=vol.ALLOW_EXTRA) if config.get(CONF_EVENT_DATA) else None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def handle_event(event):
|
def handle_event(event):
|
||||||
"""Listen for events and calls the action when data matches."""
|
"""Listen for events and calls the action when data matches."""
|
||||||
try:
|
if event_data_schema:
|
||||||
event_data_schema(event.data)
|
try:
|
||||||
except vol.Invalid:
|
event_data_schema(event.data)
|
||||||
# If event data doesn't match requested schema, skip event
|
except vol.Invalid:
|
||||||
return
|
# If event data doesn't match requested schema, skip event
|
||||||
|
return
|
||||||
|
|
||||||
hass.async_run_job(action, {
|
hass.async_run_job(action, {
|
||||||
'trigger': {
|
'trigger': {
|
||||||
|
@ -75,8 +75,6 @@ class XiaomiSensor(XiaomiDevice):
|
|||||||
return False
|
return False
|
||||||
elif self._data_key == 'humidity' and (value <= 0 or value > 100):
|
elif self._data_key == 'humidity' and (value <= 0 or value > 100):
|
||||||
return False
|
return False
|
||||||
elif self._data_key == 'illumination' and value == 0:
|
|
||||||
return False
|
|
||||||
elif self._data_key == 'pressure' and value == 0:
|
elif self._data_key == 'pressure' and value == 0:
|
||||||
return False
|
return False
|
||||||
self._state = round(value, 2)
|
self._state = round(value, 2)
|
||||||
|
@ -45,7 +45,7 @@ class SmartPlugSwitch(SwitchDevice):
|
|||||||
def __init__(self, smartplug, name):
|
def __init__(self, smartplug, name):
|
||||||
"""Initialize the switch."""
|
"""Initialize the switch."""
|
||||||
self.smartplug = smartplug
|
self.smartplug = smartplug
|
||||||
self._name = None
|
self._name = name
|
||||||
self._state = None
|
self._state = None
|
||||||
# Set up emeter cache
|
# Set up emeter cache
|
||||||
self._emeter_params = {}
|
self._emeter_params = {}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"""Constants used by Home Assistant components."""
|
"""Constants used by Home Assistant components."""
|
||||||
MAJOR_VERSION = 0
|
MAJOR_VERSION = 0
|
||||||
MINOR_VERSION = 56
|
MINOR_VERSION = 56
|
||||||
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user