Skip to content

External event as a sensor on event #333

@rzulian

Description

@rzulian

Description

I need that I can fire an event from automations that can act as a sensor.
The EC has its own sensors (duration and time reset) and it's time constrained.
I've tried to use activate

  - service: entity_controller.activate
    data:
      entity_id: entity_controller.my_ec

, but it's rising an error if the EC is constrained.

So I've modified the function in theentity_services.py to this

def async_entity_service_activate(self):
    """ Activates the entity controller"""

    if(self.model is None):
        return

    def async_entity_service_activate(self):
    """ Activates the entity controller"""

    if(self.model is None):
        return
    if self.model.is_idle() or self.model.is_active_timer() or self.model.is_blocked():
        self.model.log.debug("Activating the Entity Controller")
        self.model.set_context()
        self.model.update(last_triggered_by="external_event")
        self.model.sensor_on()
    
    # self.model.activate()

And it looks it's working just fine.
Do you think that this can be the right way? I might add an async_entity_service_sensor_on just for that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions