nielsfaber / scheduler-component

Custom component for HA that enables the creation of scheduler entities
GNU General Public License v3.0
638 stars 41 forks source link

Ability to set an offset for climate entities via a service call #326

Closed bensuffolk closed 6 months ago

bensuffolk commented 8 months ago

Checklist

Proposal

This only applies to schedules used for climate entities. I would like to apply an offset to the set temperature in a schedule based on if I am away from home, or even based on the distance I am away from home.

For example, if I am at work a few miles away, then drop the set temperature by 2 degrees.

If I am 50 Miles away, then drop if by 5 degrees as I'm not going to be home any time soon.

Additional info

You would use an automation to call a service to set an offset. This would then update the current schedule immediately and keep it applied for all future time slots, until a new offset (or zero offset) is called when you get home.

nielsfaber commented 8 months ago

How would you do this in HA (outside of scheduler)? If some service call exist to increase/decrease temperature setting I can add support for this in scheduler.

bensuffolk commented 8 months ago

I don't think you can do it on HA. But the way I assumed it would work is you must already store a set temperature for each schedule slot. So I if you also store the offset value, you would do a little bit of math and then set the thermostat to the shceuled temp less the offset.

The offset would only be settable via call so no need to change the GUI at all. I was thinking it would be a global offset for eery schedule.

mhaket commented 8 months ago

The way I solved this is, is by defining two different schedules and switching between the two with a binary switch. Being able to do this within a single schedule would be nice but in my opinion not perse necessary.

bensuffolk commented 8 months ago

@mhaket yes I can see that would work. Its a bit more of a faff to alter multiple schedules though. I was thinking of having the offset slide on a scale based on how far away I was form home (e.g. if I'm an 8 hour drive away, I'm not coming home any time soon so can have it get cooler than if I was at the office 30 mins away).

But its a cludge to implement something now. Thanks for the suggestion.

jbergler commented 7 months ago

Another approach to this is to use a script for changing the climate entity with input parameters. In the script you can apply custom logic to adjust the requested temperature.

You then control this script from the schedule.

The script I use (not for this use case exactly) is

alias: Set heatpump
description: Sets climate parameters for scheduler-card
variables:
  target_entity: climate.heat_pump
sequence:
  - repeat:
      count: 2
      sequence:
        - service: climate.set_hvac_mode
          target:
            entity_id: "{{ target_entity }}"
          data:
            hvac_mode: "{{ hvac_mode }}"
        - delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0
        - service: climate.set_temperature
          data:
            temperature: "{{ temperature }}"
          target:
            entity_id: "{{ target_entity }}"
        - delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0
        - service: climate.set_fan_mode
          target:
            entity_id: "{{ target_entity }}"
          data:
            fan_mode: "{{ fan_mode }}"
        - delay:
            hours: 0
            minutes: 0
            seconds: 30
            milliseconds: 0
mode: single
icon: mdi:air-conditioner

I've configured the scheduler card like this

  - type: custom:scheduler-card
    title: false
    discover_existing: false
    time_step: 15
    include:
      - binary_sensor.anyone_home
      - sensor.heatpump_mode
      - climate.heat_pump
    exclude: []
    display_options:
      primary_info: '{entity}: {action}'
      secondary_info:
        - relative-time
      icon: action
    show_header_toggle: false
    customize:
      script.set_heatpump:
        actions:
          - service: script.set_heatpump
            name: Set heatpump
            icon: mdi:air-conditioner
            variables:
              hvac_mode:
                name: Mode
                options:
                  - value: 'off'
                    icon: mdi:power-off
                  - value: heat_cool
                    icon: mdi:renew
                  - value: heat
                    icon: mdi:fire
                  - value: cool
                    icon: mdi:snowflake
                  - value: dry
                    icon: mdi:air-humidifer
                  - value: fan_only
                    icon: mdi:fan
              temperature:
                name: Temperature
                min: 16
                max: 25
              fan_mode:
                name: Fan mode
                options:
                  - value: auto
                    icon: mdi:fan-auto
                  - value: low
                    icon: mdi:fan-speed-1
                  - value: medium
                    icon: mdi:fan-speed-2
                  - value: high
                    icon: mdi:fan-speed-3
github-actions[bot] commented 6 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days