Making some progress now adding conditions

I want to thank all those that have helped this newbie get as far as I have. I have the following working to turn a light on and off with a motion detector. This unit sense lux as well and I would like to disable or not trigger the automation when there is light sensed.

Here is what I have working:

  - data:
      entity_id: light.level
    service: light.turn_on
  alias: When movement in MB WC turn light on
  condition: []
  id: '1521395553520'
  trigger:
  - entity_id: binary_sensor.sensor
    from: 'off'
    platform: state
    to: 'on'
- action:
  - data:
      entity_id: light.level
    service: light.turn_off
  alias: When no movement in MB WC turn light off
  condition: []
  id: '1521395698760'
  trigger:
  - entity_id: binary_sensor.sensor
    from: 'on'
    platform: state
    to: 'off'
    for:
        minutes: 2

All of this was done via the automation configuration too in the homeassistant UI. Well except for the 2 minute delay which took a lot of reading and trying different things. I am guess I need to add a condition, and would like to try do this in the UI under the automation for turning the lights on.

Not sure about formatting for:

image

I have read about states, but not sure about the formatting here and how to get a list of states and how to know how to compare the state to some value to honor the condition. I am trying to avoid editing the automations.yaml file directly because a few times I hosed it up somehow and could not find the mistakes in it. Besides, learning from what the tool does may be the best way for me to translate to what I see in the yaml files.

Also, if I do it manually, does it matter where in the configuration after the “- action” tag I put it? I am guess it would go under the action where the lights get turned on.

Something like:

  - data:
      entity_id: light.level
    service: light.turn_on
  alias: When movement in MB WC turn light on
  condition:
  - below: '2000'
    condition: numeric_state
    entity_id: sensor.dome_motion_detector_luminance
  id: '1521395553520'
  trigger:
  - entity_id: binary_sensor.sensor
    from: 'off'
    platform: state
    to: 'on'
- action:
  - data:
      entity_id: light.level
    service: light.turn_off
  alias: When no movement in MB WC turn light off
  condition: []
  id: '1521395698760'
  trigger:
  - entity_id: binary_sensor.sensor
    from: 'on'
    platform: state
    to: 'off'
    for:
      minutes: 2

I am also trying to figure out what the current value is on the sensor. When I look at the entities it was always 22.0 for the luminance state for the sensor. I turned a light on in the room with the sensor, but it did not change. Not sure how often it updates the luminance.

I think for that type of sensor, it would be returning a level ( number ) instead of a state.

Under the developer tools go to the states page and find your lux sensor to see what it’s current value is.

From there you can determine what value to put in to your condition.

You would need to select the word ‘numeric_state’ instead of ‘state’ and your condition would be something like ‘above: 80’ or ‘below: 40’ or both, depending on what values you come up with.

below: '2000'
   condition: numeric_state
   entity_id: sensor.dome_motion_detector_luminance

Is what the UI tool put in above. Is there a way to see what is being pulled at any given time. Right now it is light in the area and the state shows 22.0 which is what it showed when it was dark in the room. Not sure it is reading the luminance properly so wanted to know if there was another way to interrogate it.

The sensor graph shows:

image

This implies it has not been updated for 12 hours?

Ok, added the polling value of 60000 to the entity. Checking if that gets things rolling.

Polling does not seem to be working. I have this in my zwave_device_config.yaml:

sensor.dome_motion_detector_luminance:
  ignored: false
  polling_intensity: 60000

But still the entities state remains 22.0. Not sure if another setting is needed.