How to set away_temp of generic_thermostat?

Oh I see. You mean the automation works but the climate.salon entity attribute away_temp remains at 18? I have checked the dual mode generic component you are using and there is nothing in the code to cause this.
Post your homeassistant.log around 30 seconds either side of the automation run.

EDIT: Hang on!
Before posting the log, set the logger level to debug in your logger.yaml …

logger:
  default: info #--ASSUMING this is what you have for other logs? 
  logs:
    custom_components.dualmode_generic: debug

…then restart HA, then run the automation, then post the log.

And done!
Here is the log:


2021-02-09 16:29:51 INFO (MainThread) [custom_components.dualmode_generic.climate] Obtained current and target temperature. Generic Dual-mode thermostat active. 19.35, 19.5
2021-02-09 16:29:51 INFO (MainThread) [homeassistant.components.automation.heating_salon_when_enabling_timer_or_restoring_from_away_select_the_appropriate_temperature] Heating Salon when enabling timer or restoring from away select the appropriate temperature: Running automation actions
2021-02-09 16:29:51 INFO (MainThread) [homeassistant.components.automation.heating_salon_when_enabling_timer_or_restoring_from_away_select_the_appropriate_temperature] Heating Salon when enabling timer or restoring from away select the appropriate temperature: Choose at step 1: choice 2: Running automation actions
2021-02-09 16:29:51 INFO (MainThread) [homeassistant.components.automation.heating_salon_when_enabling_timer_or_restoring_from_away_select_the_appropriate_temperature] Heating Salon when enabling timer or restoring from away select the appropriate temperature: Choose at step 1: choice 2: Executing step call service
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.components.automation.heating_salon_set_temp_weekday_evenings] Heating Salon set temp (weekday evenings): Running automation actions
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.components.automation.heating_salon_set_temp_weekday_evenings] Heating Salon set temp (weekday evenings): Executing step call service
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.components.automation.heating_chambres_set_temp_weekday_evenings] Heating Chambres set temp (weekday evenings): Running automation actions
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.components.automation.heating_chambres_set_temp_weekday_evenings] Heating Chambres set temp (weekday evenings): Executing step call service
2021-02-09 16:30:00 INFO (MainThread) [custom_components.dualmode_generic.climate] Turning on heater switch.chauffage_chambres
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.components.automation.heating_chambres_when_enabling_timer_or_restoring_from_away_select_the_appropriate_temperature] Heating Chambres when enabling timer or restoring from away select the appropriate temperature: Running automation actions
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.components.automation.heating_chambres_when_enabling_timer_or_restoring_from_away_select_the_appropriate_temperature] Heating Chambres when enabling timer or restoring from away select the appropriate temperature: Choose at step 1: choice 3: Running automation actions
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.components.automation.heating_chambres_when_enabling_timer_or_restoring_from_away_select_the_appropriate_temperature] Heating Chambres when enabling timer or restoring from away select the appropriate temperature: Choose at step 1: choice 3: Executing step call service
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.helpers.script.chauffage_chambres] Chauffage Chambres: Running template script
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.helpers.script.chauffage_chambres] Chauffage Chambres: Executing step call service
2021-02-09 16:30:00 INFO (MainThread) [custom_components.dualmode_generic.climate] Turning on heater switch.chauffage_chambres
2021-02-09 16:30:00 WARNING (MainThread) [homeassistant.helpers.script.chauffage_chambres] Chauffage Chambres: Already running
2021-02-09 16:30:00 INFO (MainThread) [homeassistant.helpers.script.chauffage_chambres] Chauffage Chambres: Executing step delay 0:00:30
2021-02-09 16:30:30 INFO (MainThread) [homeassistant.helpers.script.chauffage_chambres] Chauffage Chambres: Executing step call service
2021-02-09 16:38:33 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_salon_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat Salon away_temp value when input "Temp Absent" is changed: Running automation actions
2021-02-09 16:38:33 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_salon_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat Salon away_temp value when input "Temp Absent" is changed: Executing step call service
2021-02-09 16:38:33 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_chambres_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat Chambres away_temp value when input "Temp Absent" is changed: Running automation actions
2021-02-09 16:38:33 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_chambres_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat Chambres away_temp value when input "Temp Absent" is changed: Executing step call service
2021-02-09 16:38:33 INFO (SyncWorker_6) [homeassistant.components.python_script] Executing set_state.py: {'entity_id': 'climate.thermostat_salon', 'away_temp': 19.5}
2021-02-09 16:38:33 INFO (SyncWorker_13) [homeassistant.components.python_script] Executing set_state.py: {'entity_id': 'climate.thermostat_chambres', 'away_temp': 19.5}

Executing set_state.py: {‘entity_id’: ‘climate.thermostat_salon’, ‘away_temp’: 19.5}

Does looks good! I don’t get it

edit: Yes the entity_id is correct…

Your log is not consistent with your config. So either you have posted the wrong config or the wrong log file. The two do not match in regard to what is specified as a configuration versus the content of the log file. Consequently I conclude that the log output is not consistent with your config posted here How to set away_temp of generic_thermostat?

My impression is that you are still not using the prescribed instructions which I have provided. There is no value to be had if you are not going to apply the specific instructions as provide them. So I will have one more go; for a final time…:

  1. Create and use set_state_or_attr.py as I provided above.
  2. Using your config you posted above, in automation updating_thermostat_when_away_temp_changed use instructions that I provided above more than once.
  • use the correct python_script service call as I stated.
  • use the correct entity (you currently have two!! - not one)
  1. Restart HA
  2. Induce the trigger
  3. Repost log file

I followed you instructions by the letter, and my automation is:

- id: updating_thermostat_when_away_temp_changed
  alias: Updating Thermostat away_temp value when input "Temp Absent" is changed
  trigger:
  - platform: state
    entity_id: input_number.away_temp
  action:
  - service: python_script.set_state_or_attr
    data_template:
      entity_id: climate.thermostat_salon,climate.thermostat_chambres
      away_temp: "{{ states('input_number.away_temp') }}"

using the script you posted above : set_state_or_attr.py

I use dualmode_generic which is an extension of generic_thermostat. So this may be normal to have logs under generic_thermostat as well. So I have turned on the debug logs for it as well as python_script:

logger:
  default: info
  logs:
    custom_components.dualmode_generic: debug
    homeassistant.components.generic_thermostat: debug
    homeassistant.components.python_script: debug

Here are the logs:

2021-02-10 08:23:12 INFO (SyncWorker_5) [homeassistant.components.python_script] Executing set_state_or_attr.py: {'entity_id': 'climate.thermostat_salon,climate.thermostat_chambres', 'away_temp': 20.0}
2021-02-10 08:23:12 WARNING (SyncWorker_5) [homeassistant.components.python_script.set_state_or_attr.py] ===== unknown entity_id: climate.thermostat_salon,climate.thermostat_chambres

Looks like set_state_or_attr.py is not able to handle two entities separated by a semicolon.
So I’ll go one step further and will remove one entity, like this:

      entity_id: climate.thermostat_chambres

      instead of entity_id: climate.thermostat_salon,climate.thermostat_chambres

Reloading automations and inducing the trigger again, here are the logs:

2021-02-10 08:27:17 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat away_temp value when input "Temp Absent" is changed: Executing step call service
2021-02-10 08:27:17 INFO (SyncWorker_11) [homeassistant.components.python_script] Executing set_state_or_attr.py: {'entity_id': 'climate.thermostat_chambres', 'away_temp': 19.0}
2021-02-10 08:27:17 DEBUG (SyncWorker_11) [homeassistant.components.python_script.set_state_or_attr.py] inputStateObject = <state climate.thermostat_chambres=heat; hvac_modes=['cool', 'heat', 'off'], min_temp=14.0, max_temp=28.0, preset_modes=['none', 'away'], current_temperature=21.0, temperature=20.0, hvac_action=idle, preset_mode=none, friendly_name=Thermostat Chambres, supported_features=17 @ 2021-02-10T08:20:41.719723+01:00>
2021-02-10 08:27:17 DEBUG (SyncWorker_11) [homeassistant.components.python_script.set_state_or_attr.py] inputState = heat
2021-02-10 08:27:17 DEBUG (SyncWorker_11) [homeassistant.components.python_script.set_state_or_attr.py] inputAttributesObject = {'hvac_modes': ['cool', 'heat', 'off'], 'min_temp': 14.0, 'max_temp': 28.0, 'preset_modes': ['none', 'away'], 'current_temperature': 21.0, 'temperature': 20.0, 'hvac_action': 'idle', 'preset_mode': 'none', 'friendly_name': 'Thermostat Chambres', 'supported_features': 17}
2021-02-10 08:27:17 DEBUG (SyncWorker_11) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = entity_id
2021-02-10 08:27:17 DEBUG (SyncWorker_11) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = entity_id; value = climate.thermostat_chambres
2021-02-10 08:27:17 DEBUG (SyncWorker_11) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = away_temp
2021-02-10 08:27:17 DEBUG (SyncWorker_11) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = away_temp; value = 19.0
2021-02-10 08:27:17 DEBUG (SyncWorker_11) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: inputAttributesObject[item] = 19.0

Now you are posting the correct info. Your previous logs and config did not relate to one another and that is a fact because I analysed them. Aside, you have now posted the correct output.
I was not going to reply because - despite me saying this three times now you were still not following my instructions.

You need to use entity id: climate.thermostat_salon not two entities. Now you have at last corrected this…

And now your logs show that the script is running and is setting the away temp for climate.thermostat_chambres

Updating Thermostat away_temp value when input "Temp Absent" is changed: Executing step call service

Executing set_state_or_attr.py: {'entity_id': 'climate.thermostat_chambres', 'away_temp': 19.0}

inputStateObject = <state climate.thermostat_chambres=heat; hvac_modes=['cool', 'heat', 'off'], min_temp=14.0, max_temp=28.0, preset_modes=['none', 'away'], current_temperature=21.0, temperature=20.0, hvac_action=idle, preset_mode=none, friendly_name=Thermostat Chambres, supported_features=17 @ 2021-02-10T08:20:41.719723+01:00>
 inputState = heat

inputAttributesObject = {'hvac_modes': ['cool', 'heat', 'off'], 'min_temp': 14.0, 'max_temp': 28.0, 'preset_modes': ['none', 'away'], 'current_temperature': 21.0, 'temperature': 20.0, 'hvac_action': 'idle', 'preset_mode': 'none', 'friendly_name': 'Thermostat Chambres', 'supported_features': 17}

LOOP: item = entity_id
LOOP: item = entity_id; value = climate.thermostat_chambres
LOOP: item = away_temp
LOOP: item = away_temp; value = 19.0
LOOP: inputAttributesObject[item] = 19.0

So as far as the automation you have posted to this thread, and the script you are using, and the thermostat entity, it is all working now. So if this value is not being reflected in the front end card then there is something else changing the value - but you have not posted your entire config.

NOTE: that your thermostat is in the “none” mode AND NOT THE “away” mode so that may be causing you an issue. Confirmed by your log output:

inputStateObject = <state climate.thermostat_chambres=heat; hvac_modes=['cool', 'heat', 'off'], min_temp=14.0, max_temp=28.0, preset_modes=['none', 'away'], current_temperature=21.0, temperature=20.0, hvac_action=idle, preset_mode=none, friendly_name=Thermostat Chambres, supported_features=17 @ 2021-02-10T08:20:41.719723+01:00>
 inputState = heat

look at the preset_mode=none So you are not in “away” mode

If that does not remedy the situation, then after the automation has run, use the developer tools to check the entity state. Then, use the template editor to confirm, you can use:

{{ states[climate.thermostat_chambres] }}

Note square brackets, not the ‘normal’ round.

Let me help you:-
In future, when posting to the forum and if you want to get the help you need, you must ensure that you post the output requested by members. You need to ensure that you post the correct and the current output. You didn’t do this here until your very recent post. Members who are familiar with HA will have known this by the content of your config and your logs. Fact. Continually disputing this is only going to reduce the support you receive. It will also increase frustration which will manifest itself in the manner in which responses are typed up - you may have picked up on my frustration! I like others are trying to help you, there is a lot of experienced helpful kind people on here, many far more so than myself. In this case it was so tempting and so much easier for me to give up and help someone who is helping themselves.
You have not made this easy for yourself or me because you do understand what I am requesting, but you seemingly have just chosen either to ignore it or be “lazy”. Sorry but that is my perception.
By the way, I am no God or guru either, and I am probably guilty of the same in the past.

1 Like

Thanks for your help, trying to be as consistent as possible while trying many things to make this works. I did shortcuts that assume would be understood, but you are not me and I’m not you. Errors are part of the human nature, as well as frustration. Writing not helping here, it removes a lot of the human interactions that would have helped understanding each others :slight_smile:

Anyway, thanks to your help to put me on track, I think I’ve found the problem!
For what I can see and understand, there is no way of changing away_temp dynamically.

Looking at the logs show this (doing two changes one after the other to gather more logs):

2021-02-10 11:22:32 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat away_temp value when input "Temp Absent" is changed: Running automation actions
2021-02-10 11:22:32 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat away_temp value when input "Temp Absent" is changed: Executing step call service
2021-02-10 11:22:32 INFO (SyncWorker_1) [homeassistant.components.python_script] Executing set_state_or_attr.py: {'entity_id': 'climate.thermostat_chambres', 'away_temp': 19.5}
2021-02-10 11:22:32 DEBUG (SyncWorker_1) [homeassistant.components.python_script.set_state_or_attr.py] inputStateObject = <state climate.thermostat_chambres=heat; hvac_modes=['cool', 'heat', 'off'], min_temp=14.0, max_temp=28.0, preset_modes=['none', 'away'], current_temperature=18.7, temperature=18.0, hvac_action=heating, preset_mode=away, friendly_name=Thermostat Chambres, supported_features=17, away_temp=20.0 @ 2021-02-10T11:00:54.029532+01:00>
2021-02-10 11:22:32 DEBUG (SyncWorker_1) [homeassistant.components.python_script.set_state_or_attr.py] inputState = heat
2021-02-10 11:22:32 DEBUG (SyncWorker_1) [homeassistant.components.python_script.set_state_or_attr.py] inputAttributesObject = {'hvac_modes': ['cool', 'heat', 'off'], 'min_temp': 14.0, 'max_temp': 28.0, 'preset_modes': ['none', 'away'], 'current_temperature': 18.7, 'temperature': 18.0, 'hvac_action': 'heating', 'preset_mode': 'away', 'friendly_name': 'Thermostat Chambres', 'supported_features': 17, 'away_temp': 20.0}
2021-02-10 11:22:32 DEBUG (SyncWorker_1) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = entity_id
2021-02-10 11:22:32 DEBUG (SyncWorker_1) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = entity_id; value = climate.thermostat_chambres
2021-02-10 11:22:32 DEBUG (SyncWorker_1) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = away_temp
2021-02-10 11:22:32 DEBUG (SyncWorker_1) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = away_temp; value = 19.5
2021-02-10 11:22:32 DEBUG (SyncWorker_1) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: inputAttributesObject[item] = 19.5
2021-02-10 11:22:38 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat away_temp value when input "Temp Absent" is changed: Running automation actions
2021-02-10 11:22:38 INFO (MainThread) [homeassistant.components.automation.updating_thermostat_away_temp_value_when_input_temp_absent_is_changed] Updating Thermostat away_temp value when input "Temp Absent" is changed: Executing step call service
2021-02-10 11:22:38 INFO (SyncWorker_3) [homeassistant.components.python_script] Executing set_state_or_attr.py: {'entity_id': 'climate.thermostat_chambres', 'away_temp': 19.0}
2021-02-10 11:22:38 DEBUG (SyncWorker_3) [homeassistant.components.python_script.set_state_or_attr.py] inputStateObject = <state climate.thermostat_chambres=heat; hvac_modes=['cool', 'heat', 'off'], min_temp=14.0, max_temp=28.0, preset_modes=['none', 'away'], current_temperature=18.7, temperature=18.0, hvac_action=heating, preset_mode=away, friendly_name=Thermostat Chambres, supported_features=17, away_temp=19.5 @ 2021-02-10T11:00:54.029532+01:00>
2021-02-10 11:22:38 DEBUG (SyncWorker_3) [homeassistant.components.python_script.set_state_or_attr.py] inputState = heat
2021-02-10 11:22:38 DEBUG (SyncWorker_3) [homeassistant.components.python_script.set_state_or_attr.py] inputAttributesObject = {'hvac_modes': ['cool', 'heat', 'off'], 'min_temp': 14.0, 'max_temp': 28.0, 'preset_modes': ['none', 'away'], 'current_temperature': 18.7, 'temperature': 18.0, 'hvac_action': 'heating', 'preset_mode': 'away', 'friendly_name': 'Thermostat Chambres', 'supported_features': 17, 'away_temp': 19.5}
2021-02-10 11:22:38 DEBUG (SyncWorker_3) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = entity_id
2021-02-10 11:22:38 DEBUG (SyncWorker_3) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = entity_id; value = climate.thermostat_chambres
2021-02-10 11:22:38 DEBUG (SyncWorker_3) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = away_temp
2021-02-10 11:22:38 DEBUG (SyncWorker_3) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: item = away_temp; value = 19.0
2021-02-10 11:22:38 DEBUG (SyncWorker_3) [homeassistant.components.python_script.set_state_or_attr.py] LOOP: inputAttributesObject[item] = 19.0

‘current_temperature’: 18.7, ‘temperature’: 18.0, ‘hvac_action’: ‘heating’, ‘preset_mode’: ‘away’, ‘friendly_name’: ‘Thermostat Chambres’, ‘supported_features’: 17, ‘away_temp’: 19.5

Using developper tools when in “away” to check entity_state gives me those informations:

hvac_modes:
  - cool
  - heat
  - 'off'
min_temp: 14
max_temp: 28
preset_modes:
  - none
  - away
current_temperature: 19.1
temperature: 18
hvac_action: idle
preset_mode: away
friendly_name: Thermostat Chambres
supported_features: 17

“away_temp” is not known by the entity “climate.thermostat_chambres”. The only known temperature relative value is “temperature”

using template editor with:

{{ states[climate.thermostat_chambres] }}

Gives me:
"UndefinedError: 'climate' is undefined"

But using:

{{ states(‘climate.thermostat_chambres’) }}

Gives me:

heat

"18.0"

What I understand is that: the temperature hardcoded in the dualmode_generic thermostat is used when switching to “away” by copying it to the “temperature” variable. The fact to set “away_temp” in the entity “climate.thermostat_chambres” does add it into it, but is not used by the away mode functionnality that keeps using the “away_temp” variable hardcoded in the yaml file where the termostat is created.

The only way I see to do what I want is then to modify the dualmode_generic thermostat to add an “away_temp_cool” variable, and use this variable when the thermostat is in “cool” mode instead of “away_temp”. “away_temp” would be the “away” value for “heat” mode only…

Now that I know it is working for you, and knowing that the only difference we have is this “dualmode_generic” dual thermostat. I have tried to create a “test” thermostat using generic_thermostat like you, and do the test again. But the result is the same: not working! the “temperature” value is still the one hardcoded in “away_temp”.

Just for the ones in the same case than me, problem has been bypassed by having two away_temp variables, one for each mode:

  • one “away_temp_heater” for heater
  • one “away_temp_cooler” for cooler

I’ve modified the code of the dualmode generic Thermostat created by zacs and proposed a fork.
If the code is not merged, the fork is available here: https://github.com/brizoo/ha-dualmodegeneric

Special thanks to @ninjaef for his patience and his support that leaded me to find a simpler and easier alternative to this problem :slight_smile:

Ah, I see.
I did not fully appreciate what you are trying to do. Indeed using one entity attribute to drive two outputs, “dual away” if you like, is not going to work.
The code you refer to does not account for such a scenario and you are right to point this out and also right to fork the original author’s repo. What I would recommend is that you raise a Git Issue against the code for an agreed pull request at a later date but you will need agree suitable test regime with the author IMHO. The author may consider this a “Feature Request” introduced by your code/requirement.
In defence though, the Generic Thermostat is not the greatest model of a thermostat IMHO and the “Away” mode function is less than obvious. The model is a very basic implementation so anything you and the dualmode author code up , can only ostensibly improve matters.

Yes! All this because my AC unit is a unit that does both heating AND cooling!
So having two thermostat for one single physical device was a nonsense to me.

This is why I choosed to use the dualmode_generic implementation of the generic_thermostat by zacs because it allowed me to specify both heater and cooler in the same thermostat. Which is exactly what I need!

This being said, the next problem was that having only one away_temp for both heater and cooler looked wrong to me… I first tryed to solve this by dynamically change “away_temp” but realized that the right way to do this was to add another “away_temp” variable. One for each mode! Makes sense :slight_smile:

So, yes I have modified the code (was really easy btw) and have created a Feature Request as well as a pull request related to the feature request ! I hope zacs will agree and merge the code now :slight_smile:

I also have asked to HA a Feature Request to improve thermostat into having Heater and Cooler functionality in one single Thermostat which makes sense when you have a two way unit like me!
Here is the Feature Request, do not hesitate to upvote it :slight_smile:

Yeah, I understood that.

It was this bit ^^^^ I did not appreciate you were trying to it for ‘both away_temps’ when of course there is only one.

LoL good luck with that , there must be hundreds of ideas for its improvement but it does not seem to get updated accordingly.

It is possible to change away_temp but I sense the issue for you is that when changing modes , away_temp will return to the value defined in the component config, I think this is what you are saying (?) and that would be my understanding too.
Although I have changed the GT code for the component in my local area - it’s just too much hard work (effort) and wait time to get the component updated in Git/HA. Certainly from my telescope there appears to be more effort put into justifying why an update will not be implemented than just getting on and improving it. I am impatient consequently after a while [my] resistance is futile and so I am forced to live with my “local hack” but at least it works the way I need it to and I don’t have to waste time incessantly trying to counter arguments in order to get simple updates incorporated into the code. I do have a home life after all.

1 Like