Beispiel #1
0
    def template_if(opp: OpenPeerPower,
                    variables: TemplateVarsType = None) -> bool:
        """Validate template based if-condition."""
        value_template.opp = opp

        return condition.async_numeric_state(opp, config[ATTR_ENTITY_ID],
                                             max_pos, min_pos, value_template)
Beispiel #2
0
    def check_numeric_state(entity, from_s, to_s):
        """Return True if criteria are now met."""
        if to_s is None:
            return False

        variables = {
            "trigger": {
                "platform": "numeric_state",
                "entity_id": entity,
                "below": below,
                "above": above,
            }
        }
        return condition.async_numeric_state(opp, to_s, below, above,
                                             value_template, variables)
Beispiel #3
0
    def _process_numeric_state(self, entity_observation):
        """Return True if numeric condition is met."""
        entity = entity_observation["entity_id"]

        try:
            return condition.async_numeric_state(
                self.opp,
                entity,
                entity_observation.get("below"),
                entity_observation.get("above"),
                None,
                entity_observation,
            )
        except ConditionError:
            return False
Beispiel #4
0
 def check_numeric_state(entity_id, from_s, to_s):
     """Return whether the criteria are met, raise ConditionError if unknown."""
     return condition.async_numeric_state(
         opp, to_s, below, above, value_template, variables(entity_id), attribute
     )