Xiaomi temp sensor below 19 degree start tado heating not working on my setup

Something wrong with this because the real temperature now 20.5 degree. Aktivat the automation and changed the temperature from 21.5 to 22 and changed the heating mode from auto to heat on the thermostat. But I need that If the temp more than 19 no change the thermostat settings.

service: climate.set_temperature
data:
  temperature: 22
  hvac_mode: |
    {% if states('sensor.0x00158d0002b57f51_temperature')|float > 19 %}
      auto
    {% else %}
      heat
    {% endif %}
entity_id: climate.room_1

And this trigger not working I think because put the sensor outside 2 degree and not start automation when falling down continuosly the temp. Of course changed the time condition.

- platform: state
  entity_id: sensor.0x00158d0002b57f51_temperature

and get this error in the log: Heating xiaomi trigger: Already running

I’m getting lost
 It definetely should work. There’s nothing wrong in the code, at least not in mine. Why did you make changes in the code?. Look the following and the last one you posted, see the difference, right after “hvac_mode”. Change that and give it a shot.

What’s the temp you usually use in your auto mode during the day?

So you don’t want to change the temp? you just want to change the mode? explain yourself in detail please

To be honest I believe you’ll do yourself a favor getting all the examples we provided and trying to figure it out yourself from here. You know what you want and I’m positive you’ll get there with all this tools.

Don’t hesitate to ask though if you get stuck

service: climate.set_temperature
data:
  temperature: 22
  hvac_mode: >
    {% if states('sensor.0x00158d0002b57f51_temperature')|float > 19 %}
      auto
    {% else %}
      heat
    {% endif %}
entity_id: climate.room_1

I’m not change. In the automation change it after save the automation. Don’t know why.

Temp what I use:
8:00 -16:00 19.5
16:00- 22:00 21.5
22:00-5:40 19.5
5:40-8:00 21.5

I want to change temp and mode but only then if xiaomi sensor below 19
If the sensor above 19 leave the thermostat on auto mode.
Thats why need 22 degree because the termostat temp sensor all night about 20-21.5 celsius (because fire place). So on about 22 C can start heating.

What I sent that 2 automation is working ok, but I want to try what you write in one automation.

alias: Heat switch 21
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.0x00158d0002b57f51_temperature
    below: '19'
  - platform: time
    at: '01:00'
condition:
  - condition: time
    after: '01:00'
    before: '5:30'
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: heat
    entity_id: climate.room_1
  - service: climate.set_temperature
    data:
      temperature: 22
    entity_id: climate.room_1
mode: single



alias: Heat switch back to auto mode
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.0x00158d0002b57f51_temperature
    above: '19'
condition: []
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: auto
    entity_id: climate.room_1
mode: single

If it works for you, just leave it this way. Good enough. I would just add this to the second automation:

alias: Heat switch back to auto mode
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.0x00158d0002b57f51_temperature
    above: '19'
  - platform: time
    at: '05:30'
condition: []
action:
  - service: climate.set_hvac_mode
    data:
      hvac_mode: auto
    entity_id: climate.room_1
mode: single

Bah, you lured me in
 I believe this will do it. It falls back to auto and 19.5 degrees, which fits your temperature settings from 22.00-5:40. It falls back there as well at 05:31. Make sure you have the sensor.time enabled

alias: Heating xiaomi trigger
description: ''
mode: single
trigger:
  - platform: state
    entity_id: sensor.0x00158d0002b57f51_temperature
  - platform: time
    at: '01:00:00'
condition:
  - condition: time
    after: '01:00:00'
    before: '05:30:00'
action:
  - service: climate.set_temperature
    data:
      temperature: >
        {% if states('sensor.0x00158d0002b57f51_temperature')|float > 19 %}
          19.5
        {% else %}
          22
        {% endif %}
      hvac_mode: >
        {% if states('sensor.0x00158d0002b57f51_temperature')|float > 19 %}
          auto
        {% else %}
          heat
        {% endif %}
    entity_id: climate.room_1
  - wait_template: "{{is_state('sensor.time', '05:31')}}"
  - service: climate.set_temperature
    data:
      temperature: 19.5
      hvac_mode: auto

btw, have you considered this:

Ok, will try it too this last automation. Looks good. :slight_smile:
What happend if the temperature trigger triggered and wait template activated and then the temp again triggered? The first automation run and after second and etc. This is not problem?
I know that they have radiator thermostat but not cheap. So if I can solve this with xiaomi it is ok for me.
Anyway with that 2 automations worked good in the night. :wink:

That’s why I set the wait_template at 05:31, so that never happens. I don’t think it’s necessary though, I believe setting it at 05:30 will always work because it is the last action from the sequence.

In the long run it’ll be cheaper to buy that than heating at 22ÂșC the whole house just for one room. An it looks much cleaner than doing this. It’s up to you. I’m glad it’s working.

The whole house not heat up, because when in the night must start heating only in the bedroom have 19 or belowe. In the living room and kitchen and bathroom about 20.5 because fire place do the heating there. So when start the heating on 22 and in bedrom reach the need 19 above from about 18.6 in the living room temp will about 20.7. So never warm up 22 in the night. Thats why give that higher 22 number to make sure start the heating.

Problem with the template, always change this “>” to “|” when save the automation. Don’t know why.

temperature: |
  {% if states('sensor.0x00158d0002b57f51_temperature')|float > 19 %}
    19.5
  {% else %}
    22
  {% endif %}

:man_shrugging: I doesn’t do that to me. Is the template green in your automation.yaml?


I think it is blue. Always copy paste the whole code in yaml editor.

Not working. Get this error in log:

Error executing script. Invalid data for call_service at pos 1: expected float for dictionary value @ data[‘temperature’]

Ok I think getting closer. So the problem is this:

- wait_template: "{{is_state('sensor.time', '05:31')}}"

removed it and the last service call. Now when change the temperature do what we need.

Only one thing what isn’t good and don’t know how to setup.
So in this:

action:
  - service: climate.set_temperature
    data:
      temperature: >
        {% if states('sensor.0x00158d0002b57f51_temperature')|float > 19 %}
          19.5
        {% else %}
          22
        {% endif %}

Don’t need to set 19.5 temp because if set to auto mode it set the temp himself.

alias: Heating xiaomi trigger
description: ''
trigger:
  - platform: state
    entity_id: sensor.0x00158d0002b57f51_temperature
  - platform: time
    at: '23:00:00'
condition:
  - condition: time
    after: '23:00:00'
    before: '05:30:00'
action:
  - service: climate.set_temperature
    data:
      temperature: |
        {% if states('sensor.0x00158d0002b57f51_temperature')|float < 19 %}
          22
        {% endif %}
    entity_id: climate.room_1
  - service: climate.set_hvac_mode
    data:
      hvac_mode: |
        {% if states('sensor.0x00158d0002b57f51_temperature')|float > 19 %}
          auto
        {% else %}
          heat
        {% endif %}
    entity_id: climate.room_1
mode: single

Now I have this. It is working but have a lot of error in log.

While executing automation automation.heating_xiaomi_trigger
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 404, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1026, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 242, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 250, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 457, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1399, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 218, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 341, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 337, in _exec
    v = func(v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 215, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 341, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 339, in _exec
    v = func(path, v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: expected float for dictionary value @ data['temperature']

and:

Already running
Heating xiaomi trigger: Error executing script. Invalid data for call_service at pos 1: expected float for dictionary value @ data['temperature']

Ok so found the solution what I need another way. It is working good. Only one problem have in the log always get “already running” warning.:

Edit: warning messages solved. Changed the automation mode from default “single” to “restart”. Now everything perfect.

alias: Heating xiaomi trigger
description: ''
trigger:
  - platform: state
    entity_id: sensor.0x00158d0002b57f51_temperature
condition:
  - condition: time
    after: '23:00:00'
    before: '05:30:00'
 action:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.0x00158d0002b57f51_temperature
            below: '19'
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 22
            entity_id: climate.room_1
      - conditions:
          - condition: numeric_state
            entity_id: sensor.0x00158d0002b57f51_temperature
            above: '19'
        sequence:
          - service: climate.set_hvac_mode
            data:
              hvac_mode: auto
            entity_id: climate.room_1
    default: []
mode: restart