Hi Danny,
I noticed you had a 2.0.0 on your repo so I had some time today to give it a early test. I found something when multiple entities are configured.
It seems the control entity from the first LightingSM instance is assumed as the state_entity for all following instances.
If a state_entity is explicitly set for each LightingSM instance that is correctly used.
I think the config parser just references the first instance if it doesnât see a state_entity.
Below you can see the configuration I used and then some logging to show that for mudroom the light.office_lamp_level was used.
motion_office:
sensors:
- binary_sensor.office_auto_lights
entities:
- light.office_lamp_level
delay: 600
motion_mudroom:
sensors:
- binary_sensor.garage_man_door_sensor
- binary_sensor.mudroom_pir_sensor
- binary_sensor.mudroom_door_sensor
entities:
- light.mudroom
delay: 300
motion_garage:
sensors:
- binary_sensor.garage_man_door_sensor
- binary_sensor.garage_pir_sensor
- binary_sensor.single_garage_sensor
- binary_sensor.dual_garage_sensor
entities:
- light.garage
delay: 600
2018-12-29 18:32:56 INFO (MainThread) [custom_components.lightingsm] Config Item motion_mudroom: OrderedDict([('sensors', ['binary_sensor.garage_man_door_sensor', 'binary_sensor.mudroom_pir_sensor', 'binary_sensor.mudroom_door_sensor']), ('entities', ['light.mudroom']), ('delay', 300)])
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Init LightingSM with: OrderedDict([('sensors', ['binary_sensor.garage_man_door_sensor', 'binary_sensor.mudroom_pir_sensor', 'binary_sensor.mudroom_door_sensor']), ('entities', ['light.mudroom']), ('delay', 300), ('name', 'motion_mudroom')])
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Name: motion_mudroom
2018-12-29 18:32:56 INFO (MainThread) [custom_components.lightingsm.motion_mudroom] Setting up state entities
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Setting up control entities
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Registering control: light.mudroom
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Using existing state entities: ['light.office_lamp_level']
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Control Entities: ['light.mudroom']
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Sensor Entities: ['binary_sensor.garage_man_door_sensor', 'binary_sensor.mudroom_pir_sensor', 'binary_sensor.mudroom_door_sensor']
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Registering sensor: binary_sensor.garage_man_door_sensor
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Registering sensor: binary_sensor.mudroom_pir_sensor
2018-12-29 18:32:56 DEBUG (MainThread) [custom_components.lightingsm.motion_mudroom] Registering sensor: binary_sensor.mudroom_door_sensor
2018-12-29 18:32:56 INFO (MainThread) [custom_components.lightingsm.motion_mudroom] serivce data set up: OrderedDict([('sensors', ['binary_sensor.garage_man_door_sensor', 'binary_sensor.mudroom_pir_sensor', 'binary_sensor.mudroom_door_sensor']), ('entities', ['light.mudroom']), ('delay', 300), ('name', 'motion_mudroom')])
<<snip>>
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] Sensor state change: on
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] state: idle
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] matches on
2018-12-29 18:46:55 INFO (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] <state light.office_lamp_level=off; node_id=70, value_index=0, value_instance=1, value_id=72057595217149953, friendly_name=Office Lamp, supported_features=1, icon=mdi:lamp @ 2018-12-29T18:32:59.290525-05:00>
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] * State of light.office_lamp_level is <state light.office_lamp_level=off; node_id=70, value_index=0, value_instance=1, value_id=72057595217149953, friendly_name=Office Lamp, supported_features=1, icon=mdi:lamp @ 2018-12-29T18:32:59.290525-05:00>
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] State entities are OFF.
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] Exiting idle
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] (night mode disabled): None
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] Using DAY MODE parameters: {'delay': 300, 'service_data': None}
2018-12-29 18:46:55 INFO (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] {'delay': 300, 'service_data': None}
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] Delay: 300
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] light params before turning on: {'delay': 300, 'service_data': None}
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] Turning on light.mudroom (no parameters passed to service call)
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] state: active_timer
2018-12-29 18:46:55 DEBUG (SyncWorker_0) [custom_components.lightingsm.motion_mudroom] state: active_timer
2018-12-29 18:46:56 DEBUG (SyncWorker_18) [custom_components.lightingsm.motion_mudroom] False