Skip to content

Commit f981174

Browse files
authored
Merge pull request #322 from danobot/develop
Develop
2 parents f267df8 + 06cfe55 commit f981174

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

custom_components/entity_controller/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from datetime import date, datetime, time, timedelta
2929
from threading import Timer
3030
import pprint
31-
from typing import Optional
31+
from typing import Optional, List
3232

3333
import homeassistant.helpers.config_validation as cv
3434
import voluptuous as vol
@@ -1117,10 +1117,10 @@ def config_times(self, config):
11171117
# parsed_start = datetime.now() + timedelta(seconds=5)
11181118
# parsed_end = datetime.now() + timedelta(seconds=10)
11191119
# FOR OPTIONAL DEBUGGING: subsequently use normal delay
1120-
sparts = re.search("^(now\s*[+-]\s*\d+)", config.get(CONF_START_TIME))
1120+
sparts = re.search(r"^(now\s*[+-]\s*\d+)", config.get(CONF_START_TIME))
11211121
if sparts is not None:
11221122
self._start_time_private = sparts.group(1)
1123-
eparts = re.search("^(now\s*[+-]\s*\d+)", config.get(CONF_END_TIME))
1123+
eparts = re.search(r"^(now\s*[+-]\s*\d+)", config.get(CONF_END_TIME))
11241124
if eparts is not None:
11251125
self._end_time_private = eparts.group(1)
11261126

@@ -1364,7 +1364,7 @@ def _parse_time(self, time_str, name=None):
13641364
parsed_time = None
13651365
sun = None
13661366
offset = 0
1367-
parts = re.search("^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)$", str(time_str))
1367+
parts = re.search(r"^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)$", str(time_str))
13681368
if parts:
13691369
this_time = datetime(
13701370
int(parts.group(1)),
@@ -1377,7 +1377,7 @@ def _parse_time(self, time_str, name=None):
13771377
)
13781378
parsed_time = dt.as_local(this_time)
13791379
else:
1380-
parts = re.search("^(\d+):(\d+):(\d+)$", str(time_str))
1380+
parts = re.search(r"^(\d+):(\d+):(\d+)$", str(time_str))
13811381
if parts:
13821382
today = dt.as_local(dt.now())
13831383
time_temp = time(
@@ -1401,7 +1401,7 @@ def _parse_time(self, time_str, name=None):
14011401
offset = 0
14021402
else:
14031403
parts = re.search(
1404-
"^sunrise\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str)
1404+
r"^sunrise\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str)
14051405
)
14061406
if parts:
14071407

@@ -1424,7 +1424,7 @@ def _parse_time(self, time_str, name=None):
14241424
parsed_time = self.sunrise(True) - td
14251425
else:
14261426
parts = re.search(
1427-
"^sunset\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str)
1427+
r"^sunset\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str)
14281428
)
14291429
if parts:
14301430
sun = "sunset"
@@ -1650,12 +1650,12 @@ def add(self, list, config, key=None):
16501650
else:
16511651
v = config
16521652

1653-
if type(v) is YamlObjects.NodeStrClass:
1654-
self.log.debug("Found string value %s for key %s, now adding to exiting list %s. (Type: %s)", v, key, list, type(v))
1653+
if isinstance(v,str):
1654+
self.log.debug("Found string value %s for key %s, now adding to existing list %s. (Type: %s)", v, key, list, type(v))
16551655
list.append(v)
16561656
return len(v) > 0
1657-
elif type(v) is YamlObjects.NodeListClass:
1658-
self.log.debug("Found list value %s for key %s, now adding to exiting list %s. (Type: %s)", v, key, list, type(v))
1657+
elif isinstance(v, List):
1658+
self.log.debug("Found list value %s for key %s, now adding to existing list %s. (Type: %s)", v, key, list, type(v))
16591659
list.extend(v)
16601660
return len(v) > 0
16611661
elif v == None:
@@ -1714,7 +1714,7 @@ def debug_time_wrapper(self, timet):
17141714
See config_times.
17151715
"""
17161716
s = timet
1717-
parts = re.search("^now\s*([+-])\s*(\d+)\s*\(?(\d+)?\)?$", timet)
1717+
parts = re.search(r"^now\s*([+-])\s*(\d+)\s*\(?(\d+)?\)?$", timet)
17181718
if parts:
17191719
sign = parts.group(1)
17201720
first_delay = parts.group(3)

info.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
Entity Controller (EC) is an implementation of "When This, Then That" using a finite state machine that ensures basic automations do not interfere with the rest of your home automation setup. This component encapsulates common automation scenarios into a neat package that can be configured easily and reused throughout your home. Traditional automations would need to be duplicated _for each instance_ in your config. The use cases for this component are endless because you can use any entity as input and outputs (there is no restriction to motion sensors and lights).
77

8+
#**Full Documentation:** [Documentation](https://github.com/danobot/entity-controller)
89

910
## :clapper: Video Demo
1011
I created the following video to give a high-level overview of all EC features, how they work and how you can configure them for your use cases.
12+
[Link](https://youtu.be/HJQrA6sFlPs)
1113

1214
[![Video](images/video_thumbnail.png)](https://youtu.be/HJQrA6sFlPs)
1315

@@ -21,10 +23,12 @@ entity_controller:
2123
entity: light.table_lamp # required, [entity,entities]
2224
delay: 300 # optional, overwrites default delay of 180s
2325
```
26+
2427
## Support
2528
Maintaining and improving this integration is very time consuming because of the sheer number of supported use cases. If you use this component in your home please consider donating or checking the issue tracker to help with the implementation of new features.
2629
2730
[Buy me a coffee](https://gofund.me/7a2487d5)
2831
29-
## Full Documentation
30-
[Documentation](https://github.com/danobot/entity-controller)
32+
There are other ways to support development as well: [Ways to support EC](https://danielbkr.net/ways-to-support/)
33+
34+

0 commit comments

Comments
 (0)