Skip to content

Commit

Permalink
Merge pull request #322 from danobot/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
danobot authored Feb 14, 2024
2 parents f267df8 + 06cfe55 commit f981174
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
24 changes: 12 additions & 12 deletions custom_components/entity_controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from datetime import date, datetime, time, timedelta
from threading import Timer
import pprint
from typing import Optional
from typing import Optional, List

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

Expand Down Expand Up @@ -1364,7 +1364,7 @@ def _parse_time(self, time_str, name=None):
parsed_time = None
sun = None
offset = 0
parts = re.search("^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)$", str(time_str))
parts = re.search(r"^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)$", str(time_str))
if parts:
this_time = datetime(
int(parts.group(1)),
Expand All @@ -1377,7 +1377,7 @@ def _parse_time(self, time_str, name=None):
)
parsed_time = dt.as_local(this_time)
else:
parts = re.search("^(\d+):(\d+):(\d+)$", str(time_str))
parts = re.search(r"^(\d+):(\d+):(\d+)$", str(time_str))
if parts:
today = dt.as_local(dt.now())
time_temp = time(
Expand All @@ -1401,7 +1401,7 @@ def _parse_time(self, time_str, name=None):
offset = 0
else:
parts = re.search(
"^sunrise\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str)
r"^sunrise\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str)
)
if parts:

Expand All @@ -1424,7 +1424,7 @@ def _parse_time(self, time_str, name=None):
parsed_time = self.sunrise(True) - td
else:
parts = re.search(
"^sunset\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str)
r"^sunset\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str)
)
if parts:
sun = "sunset"
Expand Down Expand Up @@ -1650,12 +1650,12 @@ def add(self, list, config, key=None):
else:
v = config

if type(v) is YamlObjects.NodeStrClass:
self.log.debug("Found string value %s for key %s, now adding to exiting list %s. (Type: %s)", v, key, list, type(v))
if isinstance(v,str):
self.log.debug("Found string value %s for key %s, now adding to existing list %s. (Type: %s)", v, key, list, type(v))
list.append(v)
return len(v) > 0
elif type(v) is YamlObjects.NodeListClass:
self.log.debug("Found list value %s for key %s, now adding to exiting list %s. (Type: %s)", v, key, list, type(v))
elif isinstance(v, List):
self.log.debug("Found list value %s for key %s, now adding to existing list %s. (Type: %s)", v, key, list, type(v))
list.extend(v)
return len(v) > 0
elif v == None:
Expand Down Expand Up @@ -1714,7 +1714,7 @@ def debug_time_wrapper(self, timet):
See config_times.
"""
s = timet
parts = re.search("^now\s*([+-])\s*(\d+)\s*\(?(\d+)?\)?$", timet)
parts = re.search(r"^now\s*([+-])\s*(\d+)\s*\(?(\d+)?\)?$", timet)
if parts:
sign = parts.group(1)
first_delay = parts.group(3)
Expand Down
8 changes: 6 additions & 2 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

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).

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

## :clapper: Video Demo
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.
[Link](https://youtu.be/HJQrA6sFlPs)

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

Expand All @@ -21,10 +23,12 @@ entity_controller:
entity: light.table_lamp # required, [entity,entities]
delay: 300 # optional, overwrites default delay of 180s
```
## Support
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.
[Buy me a coffee](https://gofund.me/7a2487d5)
## Full Documentation
[Documentation](https://github.com/danobot/entity-controller)
There are other ways to support development as well: [Ways to support EC](https://danielbkr.net/ways-to-support/)

0 comments on commit f981174

Please sign in to comment.