Tturn off Lutron Caseta lights after x of mins\hrs

Hi,

I got a Lutron Caseta and works great in my home. I wish the ‘Scenes’ were more flexible where I could turn off lights that are on based on an inactivity timer. Does anyone have some type of script that I could use to accomplish this in the Home Assistant world?

Thanks

What do you mean by inactivity?

Maybe I should have said if on for x number of mins\hrs, turn off

You could create an automation with a trigger that fires if a device has been on for a certain length of time. The action of the automation could then turn the device off.

This could have some undesirable results though. If you set this to, say, 30 minutes then, if you come back into the room after 25 minutes you’ll be in darkness after 5 minutes.

You could use a motion sensor to ‘reset’ the timer. This could be sufficient.

Alternatively you could use a presence sensor to actually detect the presence of people.

Couple things. Not really too familiar with how to code this. Second, the investment into the Caseta ecosystem was not cheap (probably well over $1000) between electrician costs along with the equipment. Third, I am not sure how well adding a motion sensor or people to multiple rooms would go over with wife. Unless I am not understanding this correctly.

Is this what you had mind:

Many thanks for offering suggestions.

This could be done with this automation:

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - light.all_lounge_lights
    to: "on"
    for:
      hours: 0
      minutes: 30
      seconds: 0
condition: []
action:
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.all_lounge_lights

Does the code take priority over the conditions sent on left side?

If you’re just learning how to create automations, I recommend you use the built-in Automation Editor (as opposed to the File Editor Add-on you’re using now).

  1. Copy the automation example from the forum post above
  2. Go to Settings > Automations
  3. Click the Create Automation button
  4. Click ‘Start with an empty automation’
  5. Click the overflow menu in the upper righthand corner (three vertical dots; facetiously called the ‘kebab menu’)
  6. Select ‘Edit in YAML’
  7. Delete whatever is displayed and paste what you copied from the forum post
  8. Click the Save button. If there any errors, they’ll be reported now and you’ll need to correct them (otherwise it will refuse to save the automation).
  9. To view the automation in visual mode, simply click the overflow menu again and select ‘Edit in visual editor’

I created the automation as you suggested and I don’t see it under the Automation GUI, but I do see it as a YAML file. Just does not appear to be executing. The code seemed to be fine, no errors

The steps I posted above were based on successfully creating an automation that becomes visible in Settings > Automation and executes when triggered.

If you’re not getting the same results then you may have done something different.