frenck / spook

A scary 👻 powerful toolbox 🧰 for Home Assistant 🏡
https://spook.boo
MIT License
381 stars 36 forks source link

Add time.set_duration service #438

Closed bendikrb closed 4 months ago

bendikrb commented 6 months ago

Description

Introduced a service to timer which allows the user to set a timer`s duration.

Motivation and Context

Setting duration in timer.start was deprecated in https://github.com/home-assistant/core/pull/93471, hence making it impossible to have timers that is user configurable (i.e. for light auto-off timers, with a configurable delay time).

How has this been tested?

Screenshots (if appropriate):

image

Types of changes

Checklist

sonarcloud[bot] commented 6 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

danielbrunt57 commented 4 months ago

Once I learned that timers had fixed durations that were not user UI configurable, I abandoned trying to simply start a timer and had workarounds in place to start timers specifying varying durations using input_numbers that users could change in the UI. This new service means changing existing + additional automation(s) to set the duration, or just leave well enough alone! Having alternatives is great and I appreciate the effort!

if:
  - condition: state
    entity_id: input_boolean.sleep_mode
    state: "on"
then:
  - service: timer.start
    data:
      duration: "60"
    target:
      entity_id: timer.bathroom_light
    alias: Start Bathroom Timer 60 seconds
else:
  - service: timer.start
    data:
      duration: "{{states('input_number.bathroom_delay_off')}}"
    target:
      entity_id: timer.bathroom_light
    alias: Start Bathroom Timer
alias: Start variable timer