Skip to content

Commit

Permalink
fix: Context ID too long for recorder component #200 (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
danobot authored Oct 12, 2020
1 parent 455023d commit a83ef05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions custom_components/entity_controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from homeassistant.helpers.service import async_call_from_config

DEPENDENCIES = ["light", "sensor", "binary_sensor", "cover", "fan", "media_player"]

from .const import (
DOMAIN,
STATES,
Expand Down Expand Up @@ -91,7 +90,9 @@
CONF_STATE_ATTRIBUTES_IGNORE,
CONF_IGNORED_EVENT_SOURCES,
CONSTRAIN_START,
CONSTRAIN_END
CONSTRAIN_END,

CONTEXT_ID_CHARACTER_LIMIT
)

from .entity_services import (
Expand Down Expand Up @@ -490,8 +491,8 @@ def __init__(self, hass, config, machine, entity):
)
self.name = config.get(CONF_NAME, "Unnamed Entity Controller")
self.ignored_event_sources = [self.name]

self.context = Context(parent_id=DOMAIN, id="%s.%s" % (DOMAIN, self.name))
id = "ec.%s" % (self.name)
self.context = Context(parent_id=DOMAIN, id=id[:CONTEXT_ID_CHARACTER_LIMIT])


machine.add_model(
Expand Down
3 changes: 3 additions & 0 deletions custom_components/entity_controller/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@
{'name': 'active', 'children': ['timer', 'stay_on'],
'initial': False}]
CONF_IGNORE_STATE_CHANGES_UNTIL = "grace_period"


CONTEXT_ID_CHARACTER_LIMIT = 36

0 comments on commit a83ef05

Please sign in to comment.