Sun event related timers

the sliders are working now, i made mistake and forgot one change.
now the lamp keeps goiing on after few minutes, maybe another error from me…

I try this code now. it looks great!
but when i move the sliders the start and and time doesnt change?
I changed input_slider for input_number because it gaves problems.
maybe thats why its not working?

I do get “failed config” the following components and platforms could not be set up. * input_slider

I do get the automations in place.

Input_number is the new name for input_slider.

1 Like

Hello

I’m new in Home assistant.
I want insert the modified script of caspercba in my configuration for swith on my led in my raspberry pi. Can you help me?

This is my raspberry configuration

switch:

  • platform: rpi_gpio
    ports:
    11: Luce principale

Thank you all

- platform: time

appears to have changed to

- platform: time_pattern

I think you might like this :
Universal Persistent Timer
It can add a timer to anything including multiple scripts, lights etc. with separate start and stop actions, and will resume in the event of downtime and requires no programming skills once installed. All lights, switches etc can be accessed from auto populated lists; and you can specify days of the week, repetitions, intervals, and much more. Timers can be paused, backed up and give activation notifications etc.
https://youtu.be/rUeTIU1uAP0

Hi Everyone,
I’m hoping for a gentle nudge in the right direction, I’ve loaded and updated the timer light package into the latest version of Hassio, and my sunset timer is working, sort of. At the moment, it is meant to trigger at 1734 and turn of at 2134. The problem I am having is that Hassio is ignoring the first number of the time, and is turning on my light at 0734 and off again at 1134. If anyone could tell me where the error is, that would be fantastic.
Thanks,
Mat

input_number:
  auto_light_minutes:
    name: Minutes after sunset
    icon: mdi:timer
    initial: 30
    min: 0
    max: 120
    step: 10
  auto_light_duration:
    name: Duration hours
    icon: mdi:timer
    initial: 4
    min: 0
    max: 8
    step: 0.5

sensor:
- platform: template
  sensors:
      auto_light_start:
        friendly_name: 'Lights on at'
        value_template: '{{ (as_timestamp(states.sun.sun.attributes.next_setting) + (states("input_number.auto_light_minutes") | int)  * 60)  | timestamp_custom("%H:%M") }}'
        entity_id:
          - sun.sun
          - input_number.auto_light_minutes

      auto_light_stop:
        friendly_name: 'Lights out at'
        value_template: '{{ ( as_timestamp(states.sun.sun.attributes.next_setting) + (states("input_number.auto_light_minutes") | int)  * 60 + (states("input_number.auto_light_duration") | float) * 60 * 60  )  | timestamp_custom("%H:%M") }}'
        entity_id:
          - sun.sun
          - input_number.auto_light_minutes
          - input_number.auto_light_duration

      auto_light_minutes:
        friendly_name: 'Lights on '
        value_template: '{{ "%d minutes after sunset" | format(states("input_number.auto_light_minutes") | int) }}'
        entity_id:
          - input_number.auto_light_minutes

      auto_light_duration:
        friendly_name: 'Lights on for'
        value_template: '{{ "%0.1f hours" | format(states("input_number.auto_light_duration") | float) }}'
        entity_id:
          - input_number.auto_light_duration

- platform: time_date
  display_options:
    - 'time'

automation old:
  - alias: "Auto Light On Enabled"
    trigger:
      platform: state
      entity_id: input_number.auto_light_minutes, input_number.auto_light_duration
    action:
    - service: homeassistant.turn_on
      data:
        entity_id:
          - automation.auto_light_on
    - service: homeassistant.turn_on
      data:
        entity_id:
          - automation.auto_light_off
  - alias: 'auto_light_on'
    initial_state: True
    trigger:
      - platform: time_pattern
        minutes: '/1'
        seconds: 10
    condition:
      - condition: template
        value_template: '{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) == states.sensor.auto_light_start.state }}'
    action:
      - service: homeassistant.turn_on
        entity_id: "light.hallway_light"
  - alias: 'auto_light_off'
    initial_state: True
    trigger:
      - platform: time_pattern
        minutes: '/1'
        seconds: 10
    condition:
      - condition: template
        value_template: '{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) == states.sensor.auto_light_stop.state }}'
    action:
      - service: homeassistant.turn_off
        entity_id: "light.hallway_light"
        
group:

  Sunset Switch:
    name: Sunset Switch
    control: hidden
    entities:
    - automation.auto_light_off
    - automation.auto_light_on
    - input_number.auto_light_minutes
    - sensor.auto_light_minutes
    - sensor.auto_light_start
    - input_number.auto_light_duration
    - sensor.auto_light_duration
    - sensor.auto_light_stop

Hi all, I know this is an old post but wondered if anyone actually got this package working? Looking for adjustable times to turn on and off garden lights after sunset. any pointers would help… Thanks