Update current temperature for Z-Wave thermostats

Shouldn’t this be integrated for all climate devices in Home Assistant by default without the need for using external things (like app daemon)? Just being curious …

The Danfoss thermostats don’t return the actual temperature so HA can’t determine whether it is idle or heating. That’s why you have to manipulate it externally in combination with a temperature sensor. I seriously doubt that this hack would be accepted as a change for the generic thermostat.

Oh, missed that part. You’re right then.

There is a thread on github with the idea of adding to the HA component the ability to read current temperature from an external sensor. I think that few comments supporting the idea would increase its chances of implementation.

New version of the scripts:
AppDaemon: https://github.com/bieniu/ha-ad-thermostats-update
Configuration example:

heating_thermostats_update:
  module: heating_thermostats_update
  class: HeatingThermostatsUpdate
  rooms:
    kitchen:
      thermostat: climate.thermostat_kitchen
      sensor: sensor.temperature_kitchen
    room:
      thermostat: climate.thermostat_room
      sensor: sensor.temperature_room
    bathroom:
      thermostat: climate.thermostat_bathroom
      sensor: sensor.temperature.bathroom
  heat_state: 'auto'
  idle_state: 'off'
  idle_heat_temp: 10
  wait_for_zwave: true

Python_script: https://github.com/bieniu/ha-thermostats-update
Configuration example:

service: python_script.heating_thermostat_update
data:
  thermostat: climate.thermostat_kitchen
  sensor: sensor.temperature_kitchen
  heat_stat: 'auto'
  idle_state: 'off'
  idle_heat_temp: 10
2 Likes

An earlier version of the script for AppDaemon had a stupid bug. There is now a fixed version on GitHub.
Thank again @cgtobi for feedback.

1 Like

For HA versions 0.64+, the current_temperature graphs isn’t drawn correctly (with scripts that add value from the external sensor). I’ve found that deleting from the HA database records with state ‘unknown’ for thermostats fixes this. In MySQL database, you can add this SQL command to the scheduler (I run this every 15 minutes):

DELETE FROM `states` WHERE `domain` = "climate" AND `state` = "unknown"

Now the graphs look like this:

Your automation probably only works if the names of your sensors and climates are the same, correct, @Bieniu ? I’m rather new to HA and am still trying to get my bearings with all this, so: sorry if the question is stupid.

There are no stupid questions :wink:
Yes, automation is based on entity_ids containing the room name (this is my most current version). Python script as arguments needs the entity names of the thermostat and sensor and they don’t have to be the same. If your thermostats and sensors have different names, you can change them using the entity registry (entity_registry.yaml file) or change the automation rule.

Where I have to put the Example? I think that this isn’t an Automation right? Thanks

thermostat_current_temp.py is a python script for python_script component.
This - id: heating_update_current_temperature is an automation rule.

Thanks, that works for my but the state is ‘Unknown’ the whole time… Any Idea? I didn’t use AppDeamon.

What version of heating_thermostat_update.py do you use? Most recent is 0.2.2. Show me your automation rule.

heating_thermostat_update.py script now supports custom_updater. Add this component and this to your configuration and stay up-to-date.

custom_updater:
  track:
    - python_scripts
  python_script_urls:
    - https://raw.githubusercontent.com/bieniu/home-assistant-config/master/python_scripts/python_scripts.json

image

Hi, first of all thanks for sharing your code.
I have also 1 Danfoss LC13. And try to remove the “Unknown” state.

I placed heating_thermostat_update.py (version 0.2.4) in \config\python_scripts on my pi.
And edited the entity_id’s for my situation. Restarted and toggled the automation.
But the current state is still “Unknown”

Can you please check my automation?

- id: heating_update_thermostats
  alias: 'Heating Update Thermostats'
  trigger:
    platform: state
    entity_id:
      - sensor.temperature_livingroom
      - climate.thermostat_livingroom
  condition:
    condition: template
    value_template: >-
      {% if 'thermostat' in trigger.entity_id and trigger.to_state.attributes.current_temperature == none %}
        true
      {% elif 'sensor' in trigger.entity_id %}
        true
      {% else %}
        false
      {% endif %}
  action:
    service: python_script.heating_thermostat_update
    data_template:
      thermostat: >-
        {% if 'thermostat' in trigger.entity_id %}
          {{ trigger.entity_id }}
        {% else %}
          climate.thermostat_{{ trigger.entity_id | replace('sensor.temperature_', '') }}
        {% endif %}
      sensor: >-
        {% if 'sensor' in trigger.entity_id %}
          {{ trigger.entity_id }}
        {% else %}
          sensor.temperature_{{ (trigger.entity_id | replace('climate.thermostat_', '')) }}
        {% endif %}
      heat_state: 'auto'

Automation looks good. Any errors in log?

I found what I was missing. I didn’t added the component to confihuration.yaml :woozy_face:
Now that I added that I works :smiley:

Do you’ve managed to create an automation based on the external temperature sensor?
What I mean is that you let the automation check if it is, let’s say, below 21 degrees the Danfoss is going the heat?
I think I know how to make such automation/node red sequence. But what do you tell the Danfoss to do? Just change the temperature to, let’s say, 25 degrees and wait until the external temperature sensor reaches 21 degrees? Or is there a “heat” function that I can activate?

If you set the target_temperature to 21degrees, the thermostat will open/close the valve so that the 21 degrees get in the room. No automation is needed for this.

Wow! That’s cool! :sunglasses:

The only thing what not working yet is the heat state. I only see “Auto”. Even when I set the temperature a lot higher. It supposed to say “Heat” right?

These thermostats don’t support states. My script only changes status in frontend based on target_temperature. In the script, at the begining, it is description what and how can you change. Remove from your config heat_state = auto and state will be default heat.