Entity Controller Mega Thread (Motion Lighting Controller)

You need to add it as a custom component

unrelated but Iā€™m so happy Iā€™m not the only person in the world with a mudroom. So many people ask me what that is :slight_smile:

Good stuff @danny itā€™s a very slick idea.

Mudroom is the most used place in the house as almost every entry or exit occurs from it.

It also has special abilities like a black-hole to consume kids homework and sometimes the occasional random winter mitt.

1 Like

@jwelter you have no idea how vindicated I feel right now :wink:

Awsome component, probobly best I ever used!
Thank you @danny !

1 Like

Hi I do not understand from github how the new installation works. Can anyone please help?

Before I just put lightingsm: in configuration and the file lightingsm.yaml in config folder, and lightingsm.py in custom_componentā€¦

and now?

Create a folder ā€œentity_controllerā€ under ā€œcustom_componentsā€ and copy the file ā€œinit.pyā€ from github in this folder.

Or use the custom_updater for installation and updating.

Edit:
I just saw that the filename was set to bold. The file must have 2 underscores at the beginning and at the end.

1 Like

Thanks for this component. I now use appdaemon for my bathroom motion light. In appdaemon i change light brightness to 50 for 15 seconds before turning it off. If it is in night mode raised it to 50 and if it is day mode lower to 50. Can i somehow mimic that in your component?

You could try custom service call parameters.

Can i run script instead light.turn_off? I want to change brightness for 10 seconds before turning off light. But every time i get error. Scripts work if i run them manually.
SOLVED.
https://github.com/danobot/entity-controller/issues/42

Configuration:

entity_controller:                                                              
  motion_light:                                       
    sensor: input_boolean.sensor1                                  
    sensor_type: duration                                                 
    entity: light.bed_light                                                   
    delay: 10                                                                 
    service_data:                                     
      brightness: 250                                              
    entity_off: script.bed_light_off                                                                                               
    night_mode:                                                               
      service_data:                                   
        brightness: 10                                             
      delay: 10                                                           
      start_time: '22:00:00'                                                  
      end_time: '07:00:00'                                                    
      entity_off: script.bed_light_off_night_mode     

Scripts:

bed_light_off:                                                                  
  alias: "Bed light off"                                                        
  sequence:                                                                     
    - service: light.turn_on                                                    
      entity_id: light.bed_light                                                
      data:                                                                     
        brightness: 50                                                          
    - delay:                                                                    
        seconds: 10                                                             
    - service: light.turn_off                                                   
      entity_id: light.bed_light                                                                                          
                                                                           
bed_light_off_night_mode:                                                       
  alias: "Bed light off"                                                        
  sequence:                                                                     
    - service: light.turn_on                                                    
      entity_id: light.bed_light                                                
      data:                                                                     
        brightness: 50                                                          
    - delay:                                                                    
        seconds: 10                                                             
    - service: light.turn_off                                                   
      entity_id: light.bed_light     

Error:

2019-03-08 14:40:39 DEBUG (SyncWorker_17) [custom_components.entity_controller.motion_light] Turning on s
2019-03-08 14:40:39 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/tmp/tcloop/python3.6.4/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/tc/.homeassistant/custom_components/entity_controller/__init__.py", line 381, in sensor_state_change
    self.sensor_off_duration()
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/core.py", line 383, in trigger
    return self.machine._process(func)
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/core.py", line 1047, in _process
    return trigger()
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/extensions/nesting.py", line 254, in _trigger
    return self._process(event_data)
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/core.py", line 409, in _process
    if trans.execute(event_data):
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/extensions/nesting.py", line 210, in execute
    return _super(NestedTransition, self).execute(event_data)
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/core.py", line 263, in execute
    self._change_state(event_data)
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/extensions/nesting.py", line 218, in _change_state
    lvl = source_state.exit_nested(event_data, dest_state)
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/extensions/nesting.py", line 153, in exit_nested
    return self.parent.exit_nested(event_data, target_state)
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/extensions/nesting.py", line 165, in exit_nested
    tmp_self.exit(event_data)
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/core.py", line 127, in exit
    event_data.machine.callback(handle, event_data)
  File "/home/tc/homeassistant/lib/python3.6/site-packages/transitions/core.py", line 1005, in callback
    func(*event_data.args, **event_data.kwargs)
  File "/home/tc/.homeassistant/custom_components/entity_controller/__init__.py", line 563, in on_exit_active
    self.turn_off_control_entities()
  File "/home/tc/.homeassistant/custom_components/entity_controller/__init__.py", line 869, in turn_off_control_entities
    self.call_service(e, 'turn_on')
  File "/home/tc/.homeassistant/custom_components/entity_controller/__init__.py", line 1105, in call_service
    domain, e = entity.split('.')
ValueError: not enough values to unpack (expected 2, got 1)

I am maybe blind ā€¦ or ignorant ā€¦ but where is the dicumentation to setup this awesome peace of softare? :slight_smile: I saw docker compose ā€¦ but thatā€™s all.

Could you please guide a blind chicken to the right seed? :slight_smile:

Add init.py to custom_components/entity_controller folder.

Please create an issue on github with this info. Turn on debug logging and post both initialisation logs and logs at the time of error.

Thanks

thanks ā€¦ was guessing this but not sure.

If i use custom scripts to turn on and off light, entity_controller block my sensor from triggering entity_on once entity_off script starts. Iā€™m guessing that is because light is now controlled by entity_off script and entity_controller donā€™t want to interfere with manually activated lights. Can these scripts somehow be excluded from blocking?

entity_controller:                              
  motion_light:                                                      
    sensor: input_boolean.sensor1                                             
    sensor_type: duration                   
    delay: 10             
    entity: light.bed_light                           
    entity_on: script.bed_light_on                                        
    entity_off: script.bed_light_off  

bed_light_on:
  alias: "Bed light on"
  sequence:             
    - service: script.turn_off
      data:                 
        entity_id: script.bed_light_off
    - service: light.turn_on
      entity_id: light.bed_light
      data:  
        brightness: 150
                                                  
bed_light_off:                         
  alias: "Bed light off"          
  sequence:                                       
    - service: light.turn_on  
      entity_id: light.bed_light  
      data:                                       
        brightness: 50        
    - delay:                     
        seconds: 10                              
    - service: light.turn_off    
      entity_id: light.bed_light

You probably need to define a custom state_entity to solve this. Check the docs :slight_smile:
you need to be careful as well with scripts containing delays as it will cause both the on and off scripts to be executing at the same time (when blocked mode is avoided as you describe)

I canā€™t make it work even with state_entity. In my entity_on script i have script.turn_off to cancel entity_off. But problem is delay in entity_off. As long as entity_off script is running with delay there is no way i can run on script.

I donā€™t understand why you would want to run the on script while the off script is running. That sounds like a recipe for trouble.

If sensor goes on -off- on then it runs entity_on script???

depends on your configuration, if its a duration sensor then yeah. Check out the new option called sensor_resets_timer I think, maybe it helps. That would reset the timer on the second ā€œonā€ trigger.