Skip to content

Commit

Permalink
Merge pull request #239 from danobot/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
danobot authored Feb 4, 2021
2 parents fedecd4 + 80318e3 commit 5d34448
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
31 changes: 20 additions & 11 deletions custom_components/entity_controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ async def async_setup(hass, config):
dest="blocked",
conditions=["is_state_entities_on"],
)
machine.add_transition(trigger="enable", source="idle", dest=None, conditions=["is_state_entities_off"])

# Blocked
machine.add_transition(trigger="enable", source="blocked", dest="idle", conditions=["is_state_entities_off"])
Expand Down Expand Up @@ -372,7 +373,7 @@ def __init__(self, hass, config, machine):
self.model = Model(hass, config, machine, self)
except AttributeError as e:
_LOGGER.error(
"Configuration error! Please ensure you use plural keys for lists. e.g. sensors, entities" + e
"Configuration error! Please ensure you use plural keys for lists. e.g. sensors, entities." + e
)
event.async_call_later(hass, 1, self.do_update)

Expand Down Expand Up @@ -547,6 +548,14 @@ def sensor_state_change(self, entity, old, new):
self.log.debug("sensor_state_change :: %10s Sensor state change to: %s" % ( pprint.pformat(entity), new.state))
self.log.debug("sensor_state_change :: state: " + pprint.pformat(self.state))

try:
if new.state == old.state:
self.log.debug("sensor_state_change :: Ignore attribute only change")
return
except AttributeError:
self.log.debug("sensor_state_change :: old NoneType")
pass

if self.matches(new.state, self.SENSOR_ON_STATE) and (
self.is_idle() or self.is_active_timer() or self.is_blocked()
):
Expand Down Expand Up @@ -706,10 +715,10 @@ def _override_entity_state(self):
s = self.hass.states.get(e)
try:
state = s.state
except AttributeError as e:
except AttributeError as ex:
self.log.error(
"Configuration error! Override Entity ({}) does not exist. Please check for spelling and typos.".format(
e
"Potential configuration error: Override Entity ({}) does not exist (yet). Please check for spelling and typos. {}".format(
e, ex
)
)
return None
Expand All @@ -736,10 +745,10 @@ def _sensor_entity_state(self):
s = self.hass.states.get(e)
try:
state = s.state
except AttributeError as e:
except AttributeError as ex:
self.log.error(
"Configuration error! Sensor Entity ({}) does not exist. Please check for spelling and typos.".format(
e
"Potential configuration error: Sensor Entity ({}) does not exist (yet). Please check for spelling and typos. {}".format(
e, ex
)
)
return None
Expand All @@ -762,10 +771,10 @@ def _state_entity_state(self):
self.log.info(s)
try:
state = s.state
except AttributeError as e:
except AttributeError as ex:
self.log.error(
"Configuration error! State Entity ({}) does not exist. Please check for spelling and typos.".format(
e
"Potential configuration error: State Entity ({}) does not exist (yet). Please check for spelling and typos. {}".format(
e, ex
)
)
state = 'off'
Expand Down Expand Up @@ -1182,7 +1191,7 @@ def start_time_callback(self, evt):
)

self.update(start_time=parsed_start)

if self.is_state_entities_on():
self.blocked()
else:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/entity_controller/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"domain": "entity_controller",
"name": "Entity Contoller",
"name": "Entity Controller",
"documentation": "https://github.com/danobot/entity-controller/blob/master/README.md",
"requirements": [
"transitions==0.6.9"
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "Entity Controller",
"homeassistant": "0.90.1"
"homeassistant": "0.117.0"
}

0 comments on commit 5d34448

Please sign in to comment.