Giter Club home page Giter Club logo

esphome-component-dynamic-on-time's Introduction

ESPHome: Dynamic 'on-time' component

Overview

Basically, it functions similar to time.on_time trigger, but allows changing the schedule dynamically.

Schedule aspects supported

  • Hour and minute
  • Days of week (multiple ones are fine)
  • Second is internally set to zero
  • All days of months are enabled internally
  • All months are enabled internally

Usage

The ESPHome configuration should consider following components:

  • Number to fetch hours and minutes from
  • Switch to fetch days of week from

The component then updates its schedule dynamically as soon as the components below change their values.

Multiple instances of the component are supported.

Configuration variables

  • rtc (Required, Time): Time component to attach the schedule to
  • hour (Required, Number): Component to get scheduled hour from
  • minute (Required, Number): Component to get scheduled minute from
  • mon (Required, Switch): Component indicating the schedule is enabled for Monday
  • tue (Required, Switch): Similarly but for Tuesday
  • wed (Required, Switch): Similarly but for Wednesday
  • thu (Required, Switch): Similarly but for Thursday
  • fri (Required, Switch): Similarly but for Friday
  • sat (Required, Switch): Similarly but for Saturday
  • sun (Required, Switch): Similarly but for Sunday
  • disabled (Required, Switch): Component to disable scheduled actions
  • on_time (Requred, Automation) Automation to run when schedule triggers

Example

The code below triggers sprinkler controller for full cycle as per schedule. The HomeAssistant UI will present switches for each particular day of week, and two number inputs for hour and minute.

external_components:
  source: github://hostcc/esphome-component-dynamic-on-time

switch:
  - platform: template
    id: lawn_sprinklers_mon
    name: "Lawn sprinklers: Mon"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config
  - platform: template
    id: lawn_sprinklers_tue
    name: "Lawn sprinklers: Tue"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config
  - platform: template
    id: lawn_sprinklers_wed
    name: "Lawn sprinklers: Wed"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config
  - platform: template
    id: lawn_sprinklers_thu
    name: "Lawn sprinklers: Thu"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config
  - platform: template
    id: lawn_sprinklers_fri
    name: "Lawn sprinklers: Fri"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config
  - platform: template
    id: lawn_sprinklers_sat
    name: "Lawn sprinklers: Sat"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config
  - platform: template
    id: lawn_sprinklers_sun
    name: "Lawn sprinklers: Sun"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config
  - platform: template
    id: lawn_sprinklers_disabled
    name: "Lawn sprinklers: Disable"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config

number:
  - platform: template
    id: lawn_sprinklers_hour
    name: "Lawn sprinklers: Hour"
    entity_category: config
    optimistic: true
    restore_value: true
    initial_value: 0
    min_value: 0
    max_value: 23
    step: 1
    mode: box
  - platform: template
    name: "Lawn sprinklers: Minute"
    id: lawn_sprinklers_minute
    entity_category: config
    optimistic: true
    restore_value: true
    initial_value: 0
    min_value: 0
    max_value: 59
    step: 1
    mode: box

time:
  - platform: homeassistant
    id: homeassistant_time

dynamic_on_time:
  - id: lawn_schedule
    rtc: homeassistant_time
    hour: lawn_sprinklers_hour
    minute: lawn_sprinklers_minute
    mon: lawn_sprinklers_mon
    tue: lawn_sprinklers_tue
    wed: lawn_sprinklers_wed
    thu: lawn_sprinklers_thu
    fri: lawn_sprinklers_fri
    sat: lawn_sprinklers_sat
    sun: lawn_sprinklers_sun
    disabled: lawn_sprinklers_disabled
    on_time:
      - logger.log:
          format: 'schedule: Starting full sprinkler cycle'
          tag: lawn_sprinklers
          level: 'INFO'
      - sprinkler.start_full_cycle: lawn_sprinklers

esphome-component-dynamic-on-time's People

Contributors

hostcc avatar

Stargazers

 avatar Teuchezh Nurbiy avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

veeon2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.