Slowly Increase Climate Temp

@jchh Wow… you really know your automation magic! Perhaps you can help as I have a similar situation.

I’m chasing a nasty problem with my pellet stove and it’s driving me absolutely nuts for the past year. The stove will randomly and for no apparent reason turn itself completely off. I’ve replaced all temp sensors, main board, and control board with the help of the vendor support to no avail. I think there is just some shoddy programming in this unit.

So… I’m brute force fixing it with HA. The stove’s Tuya based climate entity incorrectly reports the current temp as -4 degrees at all times (more shoddy tuya platform coding) so I built an esphome temp sensor that I put in the same room and that gives me current temp. I can read set temp from the tuya values, and luckily I can turn the stove back on via a Tuya command.

I’d like to create an automation that mimics a thermostat, since I can’t use the thermostat entity without a working current temp. Basically I want to turn the stove on when current temp is 5 degrees less than set temp. That means it’s failed as the stove normally has a 3 degree “back on” differential from its set temp, when it’s working correctly. Here’s what I have:



As you can see, it’s currently working ok as the temp diff is 68-65.5=2.5 degrees.

My current automation works, but only at a fixed temp. I really want to chase the set temp and turn it on when it’s 5 degrees less than set temp (my wife changes it all the time)

id: '1647433044968'
  alias: On Error, Turn wood stove on.
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.house_temperature
    below: 60
  condition: []
  action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: heat
    target:
      entity_id:
      - climate.big_house_wood_pellet_stove
  - service: notify.mobile_app_jeffs_iphone_se
    data:
      message: Wood stove turned on due to Living room <60

This automation will be the basis for controlling the new Esphome firmware I finally flashed in my test bench Tuya MCU unit yesterday once I can solve several problems there. That is a saga in and of itself! There’s another guy battling the same thing I am so this will all be worth it for both of us.

If interested, that saga is here New Device Definition Request - Wood Pellet Stove with 8 dps · Issue #1104 · rospogrigio/localtuya · GitHub

Thanks and of course I’ll try to help.

You might want to change your trigger to a template (so you can compare sensor.house_temperature with sensor.set_temp).

so, assuming that sensor.set_temp is the correct name, try this for the trigger:

trigger:
  - platform: template
    value_template "{{ states('sensor.house_temperature') +5 <= states('sensor.set_temp') }}"

The problem is that this could trigger every time sensor.house_temperature changes and is also 5 degrees below sensor.set_temp. We can avoid that by adding the condition that the trigger_from state must also be greater than 5 degrees less. so…

trigger:
  - platform: template
    value_template "{{ states('sensor.house_temperature') +5 <= states('sensor.set_temp') }}"
condition:
  - platform: template
    value_template: "{{ trigger.from_state.state +5 > states('sensor.set_temp') }}"

Let me know if that helps :slight_smile:

By the way, I have a Hive controller for my heating (heat and water, no cooling). I still use the Hive hub and Hive integration but am about to dump that and switch entirely to local control (via Z2M).

Even though I am using the (cloud based) Hive integration I control my heating & water 100% within HA and you’re welcome to have my package and dashboard that does it. You’d need to customise it for your situation but the logic is all there. My dash looks like this…

I also have a ‘read only’ single button version of the 4 mode buttons (in a vertical-stack in the top left hand corner to the left of the thermostat) which I use in other dashboards so I can always see what is going on. I rarely have to visit this page, but it is where I have my settings and diagnostics.

The 4 modes are:

  • Off.
  • On. 3 temps set based on whether the house is ‘awake’, asleep’, I am ‘away’ (for a couple of hours) and just adding when I am ‘on holiday’ (away for days). I press a button at night which puts the house ‘asleep’ (sets lights to dim if activated by motion, sets the heating, turns off day-only devices etc). ‘Awake’ is set by the first motion downstairs after 7am. ‘Away’ is set using person.james: not_home but could also be set by zone.home state: 0 (for multiple people).
  • Schedule. 4 possible temp/time windows with a minimum temp for outside those windows. Temp also drops when I am away. Easily adjustable to be less or more windows.
  • Boost. Can set the relative temp increase and the boost time. Not effected by my presence.

Awesome! Templating gives me fits. I’ll give it a try in the AM. Gotta get some sleep now!

let me know!

Ok, now you’re getting me excited! That looks exactly like what I need to figure out. My stove also has 4 modes and 2 eco settings. The datapoints that come out of esphome are all there and I can see them, and I’ve mapped them. I just need to figure out how to get them into a useable format so I can control them. The thread I mentioned is where that fun is unfolding.
There’s another guy who’s done amazing things with his thermostat

Jeff

yes, I took a look at it - very interesting stuff! What time zone are you? Idaho. Got it. PST.

I’m MUCH better on the hardware side if things. I’m a hack programmer at best! Yawn… :wink:

I don’t want to stop you sleeping but wish I had your skills on the hardware side - it looks very impressive.

Me too but us hackers get better with practice…and age!

I defined this sensor and checked it works in the dev tools template checker and returns a value of 68 which is correct.

 - platform: template
    sensors:
      house_set_temp:
        value_template:  "{{ state_attr('climate.big_house_wood_pellet_stove', 'temperature') }}"

{{ states(‘sensor.house_temperature’) +5 <= states(‘sensor.house_set_temp’) }}

gives this in the dev tools template checker:
TypeError: can only concatenate str (not “int”) to str

Here are the attributes of the pellet stove:

 "home_assistant": {
      "name": "Big house Wood Pellet Stove",
      "entities": [
        {
          "unit_of_measurement": null,
          "state": {
            "entity_id": "climate.big_house_wood_pellet_stove",
            "state": "off",
            "attributes": {
              "hvac_modes": [
                "off",
                "heat"
              ],
              "min_temp": 50,
              "max_temp": 122,
              "target_temp_step": 1.0,
              "current_temperature": -4,
              "temperature": 68,
              "friendly_name": "Big house Wood Pellet Stove",
              "supported_features": 1
            },

Did I mention I DESPISE TEMPLATING? :slight_smile:

yep, sorry - forgot to add the |float() to convert from a string to a real number so you can then add ‘5’ to it.

Note I have selected 0 and 99 as the default values. So the automation will go off if the sensors fail for any reason. You can change that if you want.

Try this:

{{ states(‘sensor.house_temperature’)|float(0) +5 <= states(‘sensor.house_set_temp’)|float(99) }}

This works

{{ states("sensor.house_temperature")|float(0) +8 <= states("sensor.house_set_temp")|float(99) }}

Looks like 8 is the magic value that turns it TRUE.

Now the Automation

Invalid condition configuration

Unexpected value for condition: ‘[{‘platform’: ‘template’, ‘value_template’: “{{ trigger.from_state.state +5 > states(‘sensor.house_temperature’) }}”}]’. Expected and, device, not, numeric_state, or, state, sun, template, time, trigger, zone

…so the actual temp is currently 8 below the set point?

I think this may be the same problem. try:

“{{ trigger.from_state.state|float(0) +5 > states(‘sensor.house_temperature’)|float(99) }}”

…sorry for the errors - I am not doing this from my computer where I can check for typos and errors etc.

edit: Actually if +8 works, +5 should also work - you might want to check that.

No go:
In ‘template’ condition: UndefinedError: ‘trigger’ is undefined

alias: "Fix wood stove error "
description: ""
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.house_temperature')|float(0) +8 <=
      states('sensor.house_set_temp')|float(99) }}
condition:
  - condition: template
    value_template: >-
      {{ trigger.from_state.state|float(0) +5 >
      states('sensor.house_temperature')|float(99) }}
action: []
mode: single

So I had to break it up. I defined a sensor

 - platform: template
    sensors:
      stove_error:
        value_template: "{{ states('sensor.house_temperature')|float(0) +5  <= states('sensor.house_set_temp')|float(0) }}"

Then tested that sensor in an automation. I could not find a way to trigger the automation other than when house temp falls below a certain threshold, nor could I use the template sensor in the automation without errors. Then the condition has to be met before it runs.

alias: "Fix wood stove error "
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.house_temperature
    below: 63
condition:
  - condition: state
    entity_id: sensor.stove_error
    state: "True"
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: heat
    target:
      entity_id: climate.big_house_wood_pellet_stove
  - service: notify.mobile_app_jeffs_128gb_ipad
    data:
      message: >-
        Stove Error. House Temp={{ states('sensor.house_temperature')}}. Set
        temp={{states('sensor.house_set_temp')}}
  - service: notify.mobile_app_jeffs_128gb_ipad
    data:
      message: >-
        Stove Error. House Temp={{ states('sensor.house_temperature')}}. Set
        temp={{states('sensor.house_set_temp')}}
mode: single

Very frustrating. Did I mention I hate templates? I just opened my front door and it does work! It’s 15F here… which is why I had to get this working!

Sorry for all the hassle but glad it is working for you now!

…I am not sure why the condition didn’t work - I’ll look into that.

The trigger I set up fails if the temp doesn’t rise above the trigger temp and then back down past it again, I woke up to a really cold house this am… And to complicate things, the BME280 sometimes doesnt register on the i2e bus… which causes me to change it’s address in the config file before it’s recognized again. very strange.

[07:21:35][C][i2c.arduino:044]:   Recovery: bus successfully recovered
[07:21:35][I][i2c.arduino:054]: Results from i2c bus scan:
[07:21:35][I][i2c.arduino:060]: Found i2c device at address 0x77

Now I need to figure out a reliable trigger.

yes, my logic made the assumption that the temp was high enough to start with - it was basically only triggering as the temp fell down past the 5 degree difference. If it is already below that aren’t you already in trouble?

Another way to do it is to maybe have:
trigger: house_temperature is >=5 degrees below house_set_temp
condition: house_temperature is falling
…this would trigger even if the start point was already more than 5 degrees below the set_point. Would that help?

I sincerely appreciate the help you’ve offered up. I’m going to implement the newly esphome/Tuya MCU flashed control module tomorrow on my main stove, and many of the problems you helped me solve will be incorporated into that.

I have some challenges though. The biggest is that normally the Tuya control app changes the target temp on the stove itself. It’s all self contained in the stove. The Tuya MCU ESPHome code is not bidirectional in the same way. The only control I have is the on/off switch on the stove. Which means the Im going to have to set the set temp value on the stove to a maximum temp I can stand and hope the esphome control sw is reliable in shutting the stove off when the set temp detected by home assistant is reached.

In theory it should work fine. I can read the room temp reliably from the stove and turn it on and off reliably via esphome, at least in my extensive bench tests. Time will tell!

I wish I knew who the programmers are for the Tuya MCU modules in ESPHome. I have LOTS of questions and thoughts on their implementation. Ie, why can the OEM Vendor’s Tuya based control app programatically set the target temp on the stove and ESPHOME cannot? The same with ECO Mode and the P1-P4 power levels. I can read those values set via the front panel of the stove thru Tuya MCU, but there is no way to set them. It’s unidirectional only, and limited by design. I’m not sure why…

Regardless, the frigging stove in my main house shut off no less than 5 times today, again for no reason, and now I can detect it and turn it back on. Happy wife, happy life as they say!

1 Like