From a83ef0500ded11f8d9ee94d3e8c6d65061184b97 Mon Sep 17 00:00:00 2001 From: Daniel Mason Date: Mon, 12 Oct 2020 21:35:48 +1100 Subject: [PATCH] fix: Context ID too long for recorder component #200 (#203) --- custom_components/entity_controller/__init__.py | 9 +++++---- custom_components/entity_controller/const.py | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/custom_components/entity_controller/__init__.py b/custom_components/entity_controller/__init__.py index 46376c3..19e43c0 100644 --- a/custom_components/entity_controller/__init__.py +++ b/custom_components/entity_controller/__init__.py @@ -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, @@ -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 ( @@ -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( diff --git a/custom_components/entity_controller/const.py b/custom_components/entity_controller/const.py index e04389a..3326ed6 100644 --- a/custom_components/entity_controller/const.py +++ b/custom_components/entity_controller/const.py @@ -81,3 +81,6 @@ {'name': 'active', 'children': ['timer', 'stay_on'], 'initial': False}] CONF_IGNORE_STATE_CHANGES_UNTIL = "grace_period" + + +CONTEXT_ID_CHARACTER_LIMIT = 36