entity-controller icon indicating copy to clipboard operation
entity-controller copied to clipboard

External event as a sensor on event

Open rzulian opened this issue 1 year ago • 1 comments

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.

rzulian avatar Jul 22 '24 20:07 rzulian

it's rising an error if the EC is constrained

This looks like expected behavior You can either go to idle or overridden The is a flow chart for all the states here https://danobot.github.io/ec-docs/images/state_diagram.png

I need that I can fire an event from automations that can act as a sensor.

Maybe a helper switch works for you. I think you can turn those on and off from an automation. EC should work just fine with those

Tabisch avatar Sep 24 '24 16:09 Tabisch