mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Reverting a previous change to ensure a parameter is a list
This commit is contained in:
parent
9351acb498
commit
4f7e032bb4
@ -3,7 +3,7 @@ from threading import RLock
|
||||
from datetime import datetime
|
||||
|
||||
from homeassistant.EventBus import Event
|
||||
from homeassistant.util import matcher
|
||||
from homeassistant.util import ensure_list, matcher
|
||||
|
||||
EVENT_STATE_CHANGED = "state_changed"
|
||||
|
||||
@ -55,8 +55,8 @@ class StateMachine(object):
|
||||
|
||||
def track_state_change(eventbus, category, from_state, to_state, action):
|
||||
""" Helper method to track specific state changes. """
|
||||
from_state = list(from_state)
|
||||
to_state = list(to_state)
|
||||
from_state = ensure_list(from_state)
|
||||
to_state = ensure_list(to_state)
|
||||
|
||||
def listener(event):
|
||||
assert isinstance(event, Event), "event needs to be of Event type"
|
||||
|
@ -4,7 +4,7 @@ import threading
|
||||
import time
|
||||
|
||||
from homeassistant.EventBus import Event
|
||||
from homeassistant.util import matcher
|
||||
from homeassistant.util import ensure_list, matcher
|
||||
|
||||
TIME_INTERVAL = 10 # seconds
|
||||
|
||||
@ -53,9 +53,9 @@ class Timer(threading.Thread):
|
||||
|
||||
|
||||
def track_time_change(eventbus, action, year='*', month='*', day='*', hour='*', minute='*', second='*', point_in_time=None, listen_once=False):
|
||||
year, month, day = list(year), list(month), list(day)
|
||||
hour, minute, second = list(hour), list(minute), list(second)
|
||||
|
||||
year, month, day = ensure_list(year), ensure_list(month), ensure_list(day)
|
||||
hour, minute, second = ensure_list(hour), ensure_list(minute), ensure_list(second)
|
||||
|
||||
def listener(event):
|
||||
assert isinstance(event, Event), "event needs to be of Event type"
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
def ensure_list(parameter):
|
||||
return parameter if isinstance(parameter, list) else [parameter]
|
||||
|
||||
def matcher(subject, pattern):
|
||||
""" Returns True if subject matches the pattern.
|
||||
Pattern is either a list of allowed subjects or a '*'. """
|
||||
|
Loading…
x
Reference in New Issue
Block a user