Heaty will die, Schedy be born!

Updated AppDaemon, all fixed. Thank you all.

Is there a way to integrate a timer into schedy?

E.g.: the heating will turn down the temperature in case nobody is at home. But if I am briefly away, the heating should not stop. So for example I need a timer which waits 2h before shutting down.

I dont want to do this in hassio if there is a way in schedy. Because schedy is the only one who should wait.

@Se7enair This has been asked often already. The short answer is: no. You’ll have to create a binary_sensor or input_boolean which is toggled with the desired delay. Schedy’s goal is to support state checking of any entity available in hass, it doesn’t try to duplicate the whole automation/script/template system.

I thought there is maybe a option with timestamps and some easy calculating.
Then I will do it with a input_boolean.

I thought there is maybe a option with timestamps and some easy calculating.

While you could do arbitrary calculations in your schedule rules, there has to be something causing Schedy to reevaluate the schedule after you were absent for the desired time. This is what you normally achieve via watched_entities, which triggers schedule reevaluation when one of the watched entities changes its state. But in your case, you just don’t have an entity that changes its state in the moment the schedule needs to be reevaluated.

i am currently trying to integrate some switches into schedy. unfortunately the test switch does not switch yet. however, it works if i switch it manually in the interface. can someone give me a hint what the problem is?

schedy_switches:
  module: hass_apps_loader
  class: SchedyApp

  actor_type: switch

  rooms:

  Wohnzimmer:      
      actors:
        switch.ladestation:
      schedule:
      - {v: "on", start: "19:00", end: "21:00", weekdays: "1-5"}
      - v: "off"
  

Hi @broken.pipe

The schedule looks good so far. The issue you’re facing probably is that Schedy remembers what it last set your switch to (even across restarts of AppDaemon) and will only reset if the scheduled value changes. So if you comment out the first rule temporarily and then activate it again, you should see your switch toggle. Alternatively, if you want Schedy to always apply the schedule upon startup, there is a setting called reset_at_startup you can set to true. See here for more info.

I expanded my heating control a little bit.

As i wrote in my post above, I have a input_boolean which is set to active when nobody is at home for 2 hours.
This input_boolean is controlled by an automation.
Additionally to that I added a zone which is called “preheat”.
So if I am not at home for 2 hours OR leave the zone “preheat” then the heating will turn down to my absent temperature.
The clou about that, when I now enter the zone “preheat” the input_boolean for the long absent is set to off. So the heating will start before I am at home.

Just as a idea for your heating plans.

1 Like

Hi All

Can anyone point me in a direction of controlling Schedy by month as well as day

During winter my setup works perfect but now it’s warming up I don’t really need the same schedule but don’t want to have to change twice a year as the seasons change

What would really be nice and would like to do is one of two things

  1. Set a schedule based on outside ambient temp set schedule group “summer” or “winter” or
  2. Based on month 10 - 03 set “winter” schedule and month 04 - 09 “summer” schedule

I am sure if I had one schedule it would work but as I have multiple based on various input/factors of who’s home etc they would need to be grouped to apply based on the above

That raise another question which may be my answer, can I group schedule together so that it applies summer, then within summer it evaluates my rules but in winter it evaluates the winter rules

Thanks

Hi,

If you want two independant schedules, I would go the way of two Schedy instances in AppDaemon. It will be easier then some complicated rules.

And having some input in HA to distinguish which schedule to run.

Config somethign like this:

schedy_heating_winter:
  module: hass_apps_loader
  class: SchedyApp

  actor_type: thermostat

  schedule_prepend:
  # Master switch
  - x: "Abort() if is_off('binary_sensor.winter_heating_enabled') else Next()"

  watched_entities:
  - binary_sensor.winter_heating_enabled

  ... your winter schedule ...


schedy_heating_summer:
  module: hass_apps_loader
  class: SchedyApp

  actor_type: thermostat

  schedule_prepend:
  # Master switch
  - x: "Abort() if is_on('binary_sensor.winter_heating_enabled') else Next()"

  watched_entities:
  - binary_sensor.winter_heating_enabled

  ... your summer schedule ...

Or you can use similar logic for the main switch and use schedule snippets as described in docs.

@TriStone

Thanks for the response, not sure what I have not got right here so I have scaled down to just one room for testing

I see it tries to re-evaluate in the Appdaemon logs when I change the input_select it shows the following but never actually seems to re-evalutae the new scedule based on summer or winter and the room temp seems to stay on the winter temp

2020-04-06 16:52:25.662156 INFO schedy_summer_heating: --> Attribute 'state' of 'input_select.heating_season' changed from 'Winter' to 'Summer', reevaluating <Room R:office>.

My guess its not getting to the summer scedule and would be somthing to do with my existing rules

I changed to an input_select so the other half can change back to winter mode if we have a cold spell etc

The input_seelct.heating_mode just sets home or away and works on my current single schedule

Any thoughts? My config below

schedy_winter_heating:
  module: hass_apps_loader
  class: SchedyApp
  actor_type: thermostat
  expression_environment: |
    def heating_mode():
        return state("input_select.heating_mode")
    def heating_season():
        return state("input_select.heating_season")

  schedule_prepend:
  - x: "Abort() if heating_season() == 'Summer' else Next()"
  watched_entities:
  - input_select.heating_season
  - input_select.heating_mode

  rooms:
    office:
  #    rescheduling_delay: 60
      actors:
        climate.bedroom2_heater:
      schedule:
      - v: 17
        rules:
        - weekdays: 1-5
          rules:
          - rules:
            - x: "Next() if heating_mode() == 'Home' else Break()"
            - { v: 20.5, start: "08:00", end: "18:30" }
          - rules:
            - x: "Next() if heating_mode() == 'Away' else Break()"
            - { v: 16 }
          - rules:
            - x: "Next() if heating_mode() != 'Home' else Break()"
        - weekdays: 6-7
          rules:
          - rules:
            - x: "Next() if heating_mode() == 'Home' else Break()"
          - rules:
            - x: "Next() if heating_mode() == 'Away' else Break()"
            - { v: 16 }
          - rules:
            - x: "Next() if heating_mode() != 'Home' else Break()"

schedy_summer_heating:
  module: hass_apps_loader
  class: SchedyApp
  actor_type: thermostat
  expression_environment: |
    def heating_mode():
        return state("input_select.heating_mode")
    def heating_season():
        return state("input_select.heating_season")

  schedule_prepend:
  - x: "Abort() if heating_season() == 'Winter' else Next()"
  watched_entities:
  - input_select.heating_season
  - input_select.heating_mode

  rooms:
    office:
#      rescheduling_delay: 120
      actors:
        climate.bedroom2_heater:
      schedule:
      - v: 17
        rules:
        - weekdays: 1-5
          rules:
          - rules:
            - x: "Next() if heating_mode() == 'Home' else Break()"
            - { v: 18, start: "08:00", end: "18:30" }
          - rules:
            - x: "Next() if heating_mode() == 'Away' else Break()"
            - { v: 16 }
          - rules:
            - x: "Next() if heating_mode() != 'Home' else Break()"
        - weekdays: 6-7
          rules:
          - rules:
            - x: "Next() if heating_mode() == 'Home' else Break()"
          - rules:
            - x: "Next() if heating_mode() == 'Away' else Break()"
            - { v: 16 }
          - rules:
            - x: "Next() if heating_mode() != 'Home' else Break()"
            - { v: 16 }

Im not 100% sure but I think they have to be two individual files.

Thank you for you post! I had a tough time finding a unified heating and cooling schedule. Here is my spin on this. I added an input_select for a few schedule selections. I have three modes, home (here all day), work week (away from 9am-5pm), and vacation (away). For anyone interested, this does not automatically change the heating/cooling modes, you have to do that manually in HA or on the thermostat directly, then based on the mode Schedy sets the temperature accordingly.

thermostat_schedule:
  module: hass_apps_loader
  class: SchedyApp

  actor_type: thermostat

  expression_environment: |
    def hvac_mode():
      return state("climate.thermostat_main")

  schedule_snippets:
    cooling_season:
    - v: 69
      rules:
      - x: "Next() if state('input_select.thermostat_schedule_main') != 'Vacation' else Break()"
      - {start: "19:30", end: "07:00", weekdays: 1-7}
    - v: 73
      rules:
      - weekdays: 1-5
        rules:
        - rules:
          - x: "Next() if state('input_select.thermostat_schedule_main') == 'Work week' else Break()"
          - { start: "17:00", end: "19:30" }
        - rules:
          - x: "Next() if state('input_select.thermostat_schedule_main') == 'Home' else Break()"
          - { start: "7:00", end: "19:30" }
      - weekdays: 6-7
        rules:
        - x: "Next() if state('input_select.thermostat_schedule_main') != 'Vacation' else Break()"
        - { start: "07:00", end: "19:30" }
    - v: 75

    heating_season:
    - v: 67
      rules:
      - {start: "19:30", end: "07:00", weekdays: 1-7}
    - v: 72
      rules:
      - weekdays: 1-5
        rules:
        - rules:
          - x: "Next() if state('input_select.thermostat_schedule_main') == 'Work week' else Break()"
          - { start: "7:00", end: "9:00" }
          - { start: "17:00", end: "19:30" }
        - rules:
          - x: "Next() if state('input_select.thermostat_schedule_main') == 'Home' else Break()"
          - { start: "7:00", end: "19:30" }
      - weekdays: 6-7
        rules:
        - x: "Next() if state('input_select.thermostat_schedule_main') != 'Vacation' else Break()"
        - { start: "07:00", end: "19:30" }
    - v: 67

  rooms:
    whole_house:
      actors:
        climate.thermostat_main:
          supports_hvac_modes: false
          max_temp: 75
          min_temp: 67
      schedule:
        - x: "IncludeSchedule(schedule_snippets['heating_season']) if state('climate.thermostat_main') == 'heat' else Next()"
        - x: "IncludeSchedule(schedule_snippets['cooling_season']) if state('climate.thermostat_main') == 'cool' else Break()"

  watched_entities:
    - climate.thermostat_main
    - input_select.thermostat_schedule_main

Here is my input select:

input_select:
  thermostat_schedule_main:
    name: Thermostat Schedule
    options:
     - Work week
     - Home
     - Vacation
    icon: mdi:calendar-clock

@denver

Thanks, I tried two, maybe I had something wrong in one so will give it a go again as each one works on its own

I have further simplified with no if’s, and’s or but’s :slight_smile:

2 x schedules in sepereate files as follows
1 x input_select for Summer & Winter

schedy_winter_heating:
  module: hass_apps_loader
  class: SchedyApp
  actor_type: thermostat
  expression_environment: |
    def heating_season():
        return state("input_select.heating_season")

  watched_entities:
  - input_select.heating_season

  schedule_prepend:
  - x: "Abort() if heating_season() == 'Summer' else Next()"

  rooms:
    bedroom2:
      actors:
        climate.bedroom2_heater:
      schedule:
      - v: 17
        rules:
        - weekdays: 1-7
          rules:
          - rules:
            - { v: 20.5, start: "07:00", end: "16:30" }

and

schedy_summer_heating:
  module: hass_apps_loader
  class: SchedyApp
  actor_type: thermostat
  expression_environment: |
    def heating_season():
        return state("input_select.heating_season")

  watched_entities:
  - input_select.heating_season

  schedule_prepend:
  - x: "Abort() if heating_season() == 'Winter' else Next()"

  rooms:
    bedroom2:
      actors:
        climate.bedroom2_heater:
      schedule:
      - v: 17
        rules:
        - weekdays: 1-7
          rules:
          - rules:
            - { v: 18, start: "07:00", end: "16:30" }

Based on the logs it detects the input_select but never actually seems to re-evaluate

Based on the logs it detects the input_select but never actually seems to re-evaluate

There seems to be a misunderstanding here in how Schedy decides whether to apply a value. It only applies a value when the schedule evaluation result has changed compared to the previous evaluation. Since Abort() is no result by itself, it never detects a change. So all of this won’t work reliably at all.

Having two Schedy instances running side by side causes other problems as well, for instance when processing schedy_reevaluate or schedy_set_value events, these have to be addressed to a single instance explicitly then, so your automations would need to decide which instance to send events to based on the input_select.

After all, it’s a lot simpler if you just have two Schedy config files you swap out twice a year :slight_smile:

And if that’s something you absolutely want to avoid, use sub-schedules based on the input_select, just the regular way for doing conditional sub-schedules:

- rules:
  - x: "Next() if state(...) == 'summer' else Break()"
  - ...

- rules:
  - x: "Next() if state(...) == 'winter' else Break()"
  - ...

@roschi Thanks

I have added the following rueles into my existing schedules and seems to be working as expected now

When set to “Summer” it sets to 18, when set to winter it follows the normal rules - I hope, wont know until further testing

          - rules:
            - x: "Next() if heating_season() == 'Summer' else Break()"
            - { v: 18 }
          - rules:
            - x: "Next() if heating_season() == 'Winter' else Next()"

full schedule

        - weekdays: 1-7
          rules:
          - rules:
            - x: "Next() if heating_season() == 'Summer' else Break()"
            - { v: 18 }
          - rules:
            - x: "Next() if heating_season() == 'Winter' else Next()"
          - rules:
            - x: "Next() if heating_mode() == 'Home' else Break()"
            - { v: 20.5, start: "08:00", end: "16:30" }
          - rules:
            - x: "Next() if heating_mode() == 'Holiday' else Break()"
            - { v: 16 }
          - rules:
            - x: "Next() if heating_mode() == 'Off Work' else Break()"
          - rules:
            - x: "Next() if heating_mode() == 'Away' else Break()"
            - { v: 16 }
          - rules:
            - x: "Next() if heating_mode() == 'Special' else Break()"
          - rules:
            - x: "Next() if heating_mode() != 'Home' else Break()"
- x: "Next() if heating_season() == 'Winter' else Next()"

Think you got the Next’s wrong there

so it should be

            - x: "Next() if heating_season() == 'Winter' else Break()"

Just reading the docs to try and get my logic right around “Next” & “Break” and not yet completed winter testing, just that it does change the tempo between Summer and Winter setting

Thanks again

Hi,
is it possible to make ‘v:’ read a value from an input_number entity? I would like to change the defaults in the HA frontend