nielsfaber / scheduler-component

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

Thermostat not setting temperature correctly when turned on at 12:00am #136

Closed daelsc closed 2 years ago

daelsc commented 2 years ago

Checklist

Expected behavior

I have a schedule scheme to control my thermostat. The scheme has the thermostat OFF until 12am.

At 12am it is scheduled to turn on and change the temperature.

Actual behavior

It turns on but does not adjust the temperature and returns to the previously set temperature.

Steps to Reproduce

Create a thermostat schedule that changes from "off" to "heating" with a temperature change at midnight.

schedule

history

nielsfaber commented 2 years ago

I set up a schedule similar to yours to test this as well: image

I will let you know in a few days.

nielsfaber commented 2 years ago

The results are in:

image

image

Conclusion: At midnight the climate operation mode was set from 'off' to 'heat' and setpoint was raised from 15C to 20C.

I think the problem is related to your climate integration. Most likely it cannot handle setting the operation mode + temperature setpoint together, but requires some pause in between or otherwise it would ignore the change in setpoint.

This pause is actually present in the code, but perhaps too low for your device: https://github.com/nielsfaber/scheduler-component/blob/61b22dacd074ab047bc796f0f035d15d49da3153/custom_components/scheduler/actions.py#L68

Could you try increasing it from 1 to 10 seconds (or something)? It's OK to overwrite this in the custom_components/scheduler/actions.py file. Just change the line to

                CONF_SERVICE_DATA: {CONF_DELAY: 10}

And restart HA to make the change effective.

Please post the results

chris117de commented 2 years ago

I also have the same problem and as workarund set the delay to 3 seconds. CONF_SERVICE_DATA: {CONF_DELAY: 3}

daelsc commented 2 years ago

Confirming setting the delay to 10s solved it for me. For reference, I am using it to control a climate_group thermostat provided by this custom component: https://github.com/daenny/climate_group

nielsfaber commented 2 years ago

OK clear, I will implement this change in a next release.

nielsfaber commented 2 years ago

@daelsc I released a new version v3.2.3 with some improvements which should fix the issue. Could you please update and confirm that the issue is solved for you? You can close the issue if so.

chris117de commented 2 years ago

I have installed the version but unfortunately it does not always work for me. The device is switched on but the temperature is not set. Would it be possible to check whether the temperature was set and try the process again within the minute?

nielsfaber commented 2 years ago

@chris117de Please enable debug logging for scheduler by adding this to your configuration.yaml (and restart HA afterwards):

logger:
  default: warning
  logs:
    custom_components.scheduler: debug

That way you can see what scheduler sends. If the data is sent correctly but your thermostat does not react to it, I think the problem is caused there.

Would it be possible to check whether the temperature was set and try the process again within the minute?

Possible yes, but I don't think this belongs in scheduler. There is no behaviour implemented which is specific to certain entity types (i.e. a command for turning on a lamp is handled in the same way as a command for turning on a thermostat), and I would like to keep it that way. If scheduler is designed correctly and so is your thermostat, there should be no reason for re-sending commands and it should just work in all cases. So let's focus on that.

chris117de commented 2 years ago

Hello @nielsfaber

First of all I apologize for my bad English. My comments were translated so that I can talk here. If I understand the debug log correctly, the temperature is set first and the device is only switched on afterwards.

Here are the debug logg for a scheduled Task.

2021-12-01 10:15:00 DEBUG (MainThread) [custom_components.scheduler.timer] Timer 7bfe5a has reached slot 0
2021-12-01 10:15:00 DEBUG (MainThread) [custom_components.scheduler.switch] Schedule 7bfe5a is triggered, proceed with actions
2021-12-01 10:15:00 DEBUG (MainThread) [custom_components.scheduler.actions] [7bfe5a]: Executing service climate.set_temperature on entity climate.tyst11_yw7cahqs_w7cahqs_4f96b2fe_thermostat
2021-12-01 10:15:00 DEBUG (MainThread) [custom_components.scheduler.actions] [7bfe5a]: Postponing next action for 5 seconds
2021-12-01 10:15:05 DEBUG (MainThread) [custom_components.scheduler.actions] [7bfe5a]: Executing service climate.set_hvac_mode on entity climate.tyst11_yw7cahqs_w7cahqs_4f96b2fe_thermostat
2021-12-01 10:15:05 DEBUG (MainThread) [custom_components.scheduler.actions] [7bfe5a]: finished execution of actions

I had understood the problem as that the device is not reachable in time and therefore the temperature is not set. Therefore, this was only a suggestion from me, the focus of a scheduler is of course different.

nielsfaber commented 2 years ago

Hi @chris117de

If I understand the debug log correctly, the temperature is set first and the device is only switched on afterwards.

Yes this is correct. From the log you can see that scheduler first sends the temperature setting, waits 5 seconds, and then sets the thermostat to heating mode. This is what I would expect as well, I don't see anything wrong.

My feeling is that the problem that you have is not related to scheduler. You can test it manually using thermostat card. Starting with the thermostat off, set the slider to a random position, and 5 seconds later click on the 🔥 icon. It will have exactly the same effect as with scheduler. Could you test if this also creates problems with your thermostat?

chris117de commented 2 years ago

hi @nielsfaber ,

This seems to be my problem. I can not set a temperature before turning on the device. The device must first be switched on before I can regulate the temperature.

nielsfaber commented 2 years ago

@chris117de That is weird behaviour. You should be able to change the temperature setpoint at any time. Which integration are you using? Scheduler can only work with climate devices which either:

If your climate device does not work with either, scheduler is not compatible and I cannot help you. For me it is not possible to switch the order in which the services are sent. You could consider keeping it in the heat mode at all times and changing only the temperature (so set it very low instead of off).

tane64 commented 2 years ago

Same problem here.
All works fine except setpoints. Setpoints wil start after editing the schedule. Where can I set the workaround delay?

nielsfaber commented 2 years ago

@tane64 which climate integration are you using? If I understand correctly the thermostat does switch to the heating mode, but does not update the temperature setting? You could play with the delay between both commands here. But I have my doubts there is a need for more than 5 seconds delay in order to have it executed correctly.

tane64 commented 2 years ago

I'm using zwave / Zigbee / Wifi thermostaat

I don't change the Heating mode in most cases. Popp Zigbee is always one just changing the temperatuur low /high (17-21) Heat-It / Danfoss Zwave same probleem.

When run from Node Red it's running fine. (it's just to complex to make a simple scheduler) The setpoints from the scheduler are also set when reediting the scheduler settings

Concept of the Scheduler is great and easy. On/Off for the lights is perfect. maybe a update in the future to set the color etc per light

nielsfaber commented 2 years ago

@tane64 @chris117de Can I ask you to make a script to test the following:

You can use the following code (paste in scripts.yaml and reload HA or reload scripts) and make changes from there (the code below is exactly the same as what scheduler currently does):

thermostat_test:
  sequence:
    - service: climate.set_temperature
      data:
        entity_id: climate.my_climate #replace by correct entity
        temperature: 22
    - delay: 5
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.my_climate  #replace by correct entity
        hvac_mode: heat

Make sure to start with the climate entity in state off and with a temperature setting other than 22, so you can see the effect after running the script.

Please share the results with me, so I know what adaptations need to be made for making things compatible for you. Thanks for the help 👍

tane64 commented 2 years ago

Probleem seems to be solved in v3.2.3. Maybe just reinstall related did not find any heating related not. Just installed v3.2.4. Will check the schedules today.

chris117de commented 2 years ago

@nielsfaber

I have tested the script in both variants and with me it was only possible to set the temperature after the hvac_mode was set. With a delay of between 3 and 5 seconds, it always ran smoothly in the tests. However, a delay of 1 second was not sufficient.

nielsfaber commented 2 years ago

@chris117de thank you for this information. I will see if I can make a change to scheduler to send temperature both before AND after setting the mode (I don’t see any other way to make things compatible for everyone). The 5 sec of delay is already implemented in scheduler, so should be OK. Could you tell me which integration you use for the climate device? Is it Fritz!Dect or different?

chris117de commented 2 years ago

@nielsfaber I use a HAMA climate device over zigbee.

nielsfaber commented 2 years ago

@chris117de @daelsc Can you confirm the problems are solved after updating to v3.2.6?

tane64 commented 2 years ago

No problems all working fine. including setpoints.

chris117de commented 2 years ago

Hello @nielsfaber, i can confirm that everything is working now. Thanks for the implementation and the great work.

Dycelll commented 2 years ago

My feeling is that the problem that you have is not related to scheduler. You can test it manually using thermostat card. Starting with the thermostat off, set the slider to a random position, and 5 seconds later click on the 🔥 icon. It will have exactly the same effect as with scheduler. Could you test if this also creates problems with your thermostat?

Just as a reference so others may find this.. I'm having trouble scheduling my Tado thermostats using the intergration. I've just set it to debug. When I create a thermostat card and try to change to change the temperature, it just flips back.

It seems that there is no problem with the schedule intergration, but with the thermostat intergration. The thermostat card is a good indicator to ascertain this. Thanks, @nielsfaber

/Edit: Disabling the Tado intergration option 'Fallback mode will switch to Smart Schedule at next schedule switch after manually adjusting a zone.' seems to fix the problem. This can be found in Home Asssintant -> devices and services -> intergrations -> Tado -> Configure -> Enable fallback mode should not be enabled

nielsfaber commented 2 years ago

@Dycelll The Tado thermostat is known to not accept a temperature setpoint while it is off (setpoint simply becomes equal to the actual temperature). This behaviour has nothing to do with scheduler (but you should be able to set them to heat using scheduler).

I also have Tado TRVs in my home, and I was so bothered by this behaviour that I created a custom_component just for having it behave like a normal climate entity (so setpoint is kept regardless whether its on or off). You can find it here, feel free to use it if it helps you too (although I really made it for my own use only). Note that I only use it for heat / off modes, I don't think you can configure it to have it follow the settings in the Tado app (such as the Smart Schedule).

Fun fact: The scheduler project was actually inspired by the Smart Schedule in the Tado app, they look quite similar.

@daelsc I'm closing this issue assuming all works OK now. If this is not the case, please let me know.