Update current temperature for Z-Wave thermostats

thank you! :slight_smile:

Hello, I use the edit script in pairs. I have a lot of mistakes in the log. Is there a solution to my problem?

2019-09-04 14:56:15 ERROR (SyncWorker_0) [homeassistant.components.python_script.thermostat_update.py] entity_id climate.danfoss_z_thermostat_014g0013_heating_1_10.
2019-09-04 14:56:15 ERROR (SyncWorker_2) [homeassistant.components.python_script.thermostat_update.py] entity_id sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2.
2019-09-04 14:56:15 ERROR (SyncWorker_0) [homeassistant.components.python_script.thermostat_update.py] Values: climate.danfoss_z_thermostat_014g0013_heating_1_10 - sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2.
2019-09-04 14:56:15 ERROR (SyncWorker_2) [homeassistant.components.python_script.thermostat_update.py] Values: climate.danfoss_z_thermostat_014g0013_heating_1_10 - sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2.
2019-09-04 14:56:16 ERROR (SyncWorker_3) [homeassistant.components.python_script.thermostat_update.py] thermostats ['climate.danfoss_z_thermostat_014g0013_heating_1', 'climate.danfoss_z_thermostat_014g0013_heating_1_2', 'climate.danfoss_z_thermostat_014g0013_heating_1_3', 'climate.danfoss_z_thermostat_014g0013_heating_1_4', 'climate.danfoss_z_thermostat_014g0013_heating_1_5', 'climate.danfoss_z_thermostat_014g0013_heating_1_6', 'climate.danfoss_z_thermostat_014g0013_heating_1_7', 'climate.danfoss_z_thermostat_014g0013_heating_1_8', 'climate.danfoss_z_thermostat_014g0013_heating_1_9', 'climate.danfoss_z_thermostat_014g0013_heating_1_10'].
2019-09-04 14:56:16 ERROR (SyncWorker_3) [homeassistant.components.python_script.thermostat_update.py] sensors ['sensor.temperature_chambre_parentale', 'sensor.temperature_chambre_noham', 'sensor.temperature_salon', 'sensor.temperature_salon', 'sensor.temperature_salon', 'sensor.temperature_chambre_theo', 'sensor.temperature_chambre_sacha', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2'].
2019-09-04 14:56:16 ERROR (SyncWorker_3) [homeassistant.components.python_script.thermostat_update.py] entity_id sensor.fibaro_system_fgsd002_smoke_sensor_temperature.
2019-09-04 14:56:16 ERROR (SyncWorker_3) [homeassistant.components.python_script.thermostat_update.py] Values: climate.danfoss_z_thermostat_014g0013_heating_1_8 - sensor.fibaro_system_fgsd002_smoke_sensor_temperature.
2019-09-04 14:56:16 ERROR (SyncWorker_4) [homeassistant.components.python_script.thermostat_update.py] thermostats ['climate.danfoss_z_thermostat_014g0013_heating_1', 'climate.danfoss_z_thermostat_014g0013_heating_1_2', 'climate.danfoss_z_thermostat_014g0013_heating_1_3', 'climate.danfoss_z_thermostat_014g0013_heating_1_4', 'climate.danfoss_z_thermostat_014g0013_heating_1_5', 'climate.danfoss_z_thermostat_014g0013_heating_1_6', 'climate.danfoss_z_thermostat_014g0013_heating_1_7', 'climate.danfoss_z_thermostat_014g0013_heating_1_8', 'climate.danfoss_z_thermostat_014g0013_heating_1_9', 'climate.danfoss_z_thermostat_014g0013_heating_1_10'].
2019-09-04 14:56:16 ERROR (SyncWorker_4) [homeassistant.components.python_script.thermostat_update.py] sensors ['sensor.temperature_chambre_parentale', 'sensor.temperature_chambre_noham', 'sensor.temperature_salon', 'sensor.temperature_salon', 'sensor.temperature_salon', 'sensor.temperature_chambre_theo', 'sensor.temperature_chambre_sacha', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2'].
2019-09-04 14:56:16 ERROR (SyncWorker_4) [homeassistant.components.python_script.thermostat_update.py] entity_id sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4.
2019-09-04 14:56:16 ERROR (SyncWorker_4) [homeassistant.components.python_script.thermostat_update.py] Values: climate.danfoss_z_thermostat_014g0013_heating_1_9 - sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4.
2019-09-04 14:57:06 ERROR (SyncWorker_6) [homeassistant.components.python_script.thermostat_update.py] thermostats ['climate.danfoss_z_thermostat_014g0013_heating_1', 'climate.danfoss_z_thermostat_014g0013_heating_1_2', 'climate.danfoss_z_thermostat_014g0013_heating_1_3', 'climate.danfoss_z_thermostat_014g0013_heating_1_4', 'climate.danfoss_z_thermostat_014g0013_heating_1_5', 'climate.danfoss_z_thermostat_014g0013_heating_1_6', 'climate.danfoss_z_thermostat_014g0013_heating_1_7', 'climate.danfoss_z_thermostat_014g0013_heating_1_8', 'climate.danfoss_z_thermostat_014g0013_heating_1_9', 'climate.danfoss_z_thermostat_014g0013_heating_1_10'].
2019-09-04 14:57:06 ERROR (SyncWorker_6) [homeassistant.components.python_script.thermostat_update.py] sensors ['sensor.temperature_chambre_parentale', 'sensor.temperature_chambre_noham', 'sensor.temperature_salon', 'sensor.temperature_salon', 'sensor.temperature_salon', 'sensor.temperature_chambre_theo', 'sensor.temperature_chambre_sacha', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4', 'sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2'].
2019-09-04 14:57:06 ERROR (SyncWorker_6) [homeassistant.components.python_script.thermostat_update.py] entity_id climate.danfoss_z_thermostat_014g0013_heating_1_6.
2019-09-04 14:57:06 ERROR (SyncWorker_6) [homeassistant.components.python_script.thermostat_update.py] Values: climate.danfoss_z_thermostat_014g0013_heating_1_6 - sensor.temperature_chambre_theo.
2019-09-04 14:57:12 ERROR (SyncWorker_1) [homeassistant.components.python_script.thermostat_update.py] thermostats ['climate.danfoss_z_thermostat_014g0013_heating_1', 'climate.danfoss_z_thermostat_014g0013_heating_1_2', 'climate.danfoss_z_thermostat_014g0013_heating_1_3', 'climate.danfoss_z_thermostat_014g0013_heating_1_4', 'climate.danfoss_z_thermostat_014g0013_heating_1_5', 'climate.danfoss_z_thermostat_014g0013_heating_1_6', 'climate.danfoss_z_thermostat_014g0013_heating_1_7', 'climate.danfoss_z_thermostat_014g0013_heating_1_8', 'climate.danfoss_z_thermostat_014g0013_heating_1_9', 'climate.danfoss_z_thermostat_014g0013_heating_1_10'].

python_script thermostat_update.py

VERSION = '0.2.6'

ATTR_THERMOSTAT = 'thermostat'
ATTR_SENSOR = 'sensor'
ATTR_HEAT = 'heat_state'
ATTR_IDLE = 'idle_state'
ATTR_IDLE_HEAT = 'idle_heat_temp'
ATTR_CURRENT_TEMP = 'current_temperature'
ATTR_OPERATION_LIST = 'operation_list'
ATTR_OPERATION_MODE = 'operation_mode'
ATTR_TEMPERATURE = 'temperature'
ATTR_THERMOSTATS = 'thermostats'
ATTR_SENSORS = 'sensors'
ATTR_ENTITY_ID = 'entity_id'

ATTR_HEAT_STATE = 'heat'
ATTR_IDLE_STATE = 'off'
ATTR_IDLE_HEAT_STATE = 8

thermostat_id = data.get(ATTR_THERMOSTAT)
sensor_id = data.get(ATTR_SENSOR)
entity_id = data.get(ATTR_ENTITY_ID)
thermostats = data.get(ATTR_THERMOSTATS)
sensors = data.get(ATTR_SENSORS)
heat_state = data.get(ATTR_HEAT, ATTR_HEAT_STATE)
idle_state = data.get(ATTR_IDLE, ATTR_IDLE_STATE)
idle_heat_temp = data.get(ATTR_IDLE_HEAT, ATTR_IDLE_HEAT_STATE)

logger.error("thermostats {}.".format(thermostats))
logger.error("sensors {}.".format(sensors))
logger.error("entity_id {}.".format(entity_id))

def getIndex(list, value):
    if value in list:
        return list.index(value)
    return -1

if entity_id:
    index = getIndex(thermostats, entity_id)
    if index>=0:
        thermostat_id = entity_id
        sensor_id = sensors[index]
    else:
        index = getIndex(sensors, entity_id)
        if index>=0:
            sensor_id = entity_id
            thermostat_id = thermostats[index]

logger.error("Values: {} - {}.".format(thermostat_id, sensor_id))

if thermostat_id and sensor_id:
    try:
        temp = float(hass.states.get(sensor_id).state)
    except ValueError:
        logger.error("Could not get state of {}.".format(sensor_id))
    thermostat = hass.states.get(thermostat_id)
    if thermostat is None:
        logger.error("Could not get state of {}.".format(thermostat_id))
    else:
        attributes = thermostat.attributes.copy()
        attributes[ATTR_CURRENT_TEMP] = temp
        attributes[ATTR_OPERATION_LIST] = [heat_state, idle_state]
        if float(attributes[ATTR_TEMPERATURE]) > idle_heat_temp:
            state = heat_state
            attributes[ATTR_OPERATION_MODE] = heat_state
        else:
            state = idle_state
            attributes[ATTR_OPERATION_MODE] = idle_state
        hass.states.set(thermostat_id, state, attributes)
else:
    logger.error("Expected {} and {} entity_id, got: {} and {}.".format(
        ATTR_THERMOSTAT, ATTR_SENSOR, thermostat_id, sensor_id))

Automation

  alias: 'Heating Update Thermostats'
  trigger:
    platform: state
    entity_id:
      - sensor.temperature_chambre_parentale
      - sensor.temperature_chambre_noham
      - sensor.temperature_salon
      - sensor.temperature_salon
      - sensor.temperature_salon
      - sensor.temperature_chambre_theo 
      - sensor.temperature_chambre_sacha
      - sensor.fibaro_system_fgsd002_smoke_sensor_temperature
      - sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4
      - sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2
      - climate.danfoss_z_thermostat_014g0013_heating_1
      - climate.danfoss_z_thermostat_014g0013_heating_1_2
      - climate.danfoss_z_thermostat_014g0013_heating_1_3
      - climate.danfoss_z_thermostat_014g0013_heating_1_4
      - climate.danfoss_z_thermostat_014g0013_heating_1_5
      - climate.danfoss_z_thermostat_014g0013_heating_1_6
      - climate.danfoss_z_thermostat_014g0013_heating_1_7
      - climate.danfoss_z_thermostat_014g0013_heating_1_8
      - climate.danfoss_z_thermostat_014g0013_heating_1_9
      - climate.danfoss_z_thermostat_014g0013_heating_1_10
  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.thermostat_update
    data_template:
      sensors:
        - sensor.temperature_chambre_parentale
        - sensor.temperature_chambre_noham
        - sensor.temperature_salon
        - sensor.temperature_salon
        - sensor.temperature_salon
        - sensor.temperature_chambre_theo 
        - sensor.temperature_chambre_sacha
        - sensor.fibaro_system_fgsd002_smoke_sensor_temperature
        - sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4
        - sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2
      thermostats:
        - climate.danfoss_z_thermostat_014g0013_heating_1
        - climate.danfoss_z_thermostat_014g0013_heating_1_2
        - climate.danfoss_z_thermostat_014g0013_heating_1_3
        - climate.danfoss_z_thermostat_014g0013_heating_1_4
        - climate.danfoss_z_thermostat_014g0013_heating_1_5
        - climate.danfoss_z_thermostat_014g0013_heating_1_6
        - climate.danfoss_z_thermostat_014g0013_heating_1_7
        - climate.danfoss_z_thermostat_014g0013_heating_1_8
        - climate.danfoss_z_thermostat_014g0013_heating_1_9
        - climate.danfoss_z_thermostat_014g0013_heating_1_10
      entity_id: '{{trigger.entity_id}}'

Thank you in advance for your assistance. Sorry for my english

You are using modified version of the script. I’m not author of this modification. My version is here https://github.com/bieniu/ha-thermostat-update

Yes I understand but I have problems when I want to rename my thermostats and smoke detector that serves as a temperature sensor. Does your version allow us to keep our names or can it work in pairs without the room ?

  • climate1
  • climate2
  • climate3
  • sensor1
  • sensor2
  • sensor3

You can use AppDaemon app https://github.com/bieniu/ha-ad-thermostats-update if you don’t want to rename entities.

Thank you for your help and proposal but I have never managed to work with the AppDaemon version.

I just found a solution to my problem. So I managed to rename as requested your initial version with
Climate Group + rename my smoke detector

- platform: template
  sensors:
    # Temperature detecteur fummée couloir entrée
    temperature_couloir_entree:
      friendly_name: "Température Couloir Entrée"
      unit_of_measurement: '°C'
      value_template: >-
        {% if states('sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2') %}
          {{ states('sensor.fibaro_system_fgsd002_smoke_sensor_temperature_2') }}
        {% else %}
          {{ states('temperature_couloir_entree') }}
        {% endif %}
    # Temperature detecteur fummée couloir 1er
    temperature_couloir_1er:
      friendly_name: "Température Couloir 1er"
      unit_of_measurement: '°C'
      value_template: >-
        {% if states('sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4') %}
          {{ states('sensor.fibaro_system_fgsd002_smoke_sensor_temperature_4') }}
        {% else %}
          {{ states('temperature_couloir_1er') }}
        {% endif %}
    # Temperature detecteur fummée palier enfants
    temperature_palier_enfants:
      friendly_name: "Température Palier Enfants"
      unit_of_measurement: '°C'
      value_template: >-
        {% if states('sensor.fibaro_system_fgsd002_smoke_sensor_temperature') %}
          {{ states('sensor.fibaro_system_fgsd002_smoke_sensor_temperature') }}
        {% else %}
          {{ states('temperature_palier_enfants') }}
        {% endif %}

off topic :wink:

There is no longer a beautiful card. If a person has the skill to adapt this Jeedom widget. I leave a file with the png of the Danfoss head and the Jeedom script. widget Jeedom

Thank you very much for your script.

Hey
Im testing your app right now and having som problems. I have a Danfoss LC13 that is standing on the table right now (removed from the radiator).

I installed the AppDeamon app via HACS and made “apps.yaml” and placed that in folder “config\appdaemon\apps”.

apps.yaml

thermostats_update:
  module: thermostats-update
  class: ThermostatsUpdate
  rooms:
    kitchen:
      thermostat: climate.danfoss_z_thermostat_014g0013_heating_1
      sensor: sensor.tvattstuga_temperature_2
  heat_state: 'auto'
  idle_state: 'idle'
  idle_heat_temp: 10
  state_only: true
  wait_for_zwave: true

And the code for the simple-thermostat:

card:
  type: 'custom:simple-thermostat'
  entity: climate.danfoss_z_thermostat_014g0013_heating_1
  sensors:
    - entity: sensor.tvattstuga_temperature_2

But I have No temperature or state.
Added sensor. to display actual temperature in the room.

simple-thermostat

Whats wrong?
No errors or messages in log that related to this!

No errors in AppDaemon log?

hmm there might be a problem with appDaemon… =/

Error: Asked to process document index 0 but there are only 0 document(s)
Usage:
  yq delete [yaml_file] [path] [flags]
Aliases:
  delete, d
Examples:
yq delete things.yaml a.b.c
yq delete --inplace things.yaml a.b.c
yq d -i things.yaml a.b.c
yq d things.yaml a.b.c
	
Flags:
  -d, --doc string   process document index number (0 based, * for all documents) (default "0")
  -h, --help         help for delete
  -i, --inplace      update the yaml file inplace
Global Flags:
  -t, --trim      trim yaml output (default true)
  -v, --verbose   verbose mode
19:41:01 main [ERRO] Asked to process document index 0 but there are only 0 document(s)

Cant start AppDeamon. Dont know whats wrong!??

How do You install AppDaemon?

Via hassio and Add-On Store! How do you mean?

There are few ways to install AppDaemon (as Hass.io addon, via pip, via pip in venv). I don’t use Hass.io so I can’t help you.

Ah, you meant it like that…

Hmm, and the other way with automations you have to have the sensors and thermostat with the same name or…?

Yes, you have to have entities with similar names eg. climate.thermostat_kitchen and sensor.temperature_kitchen to use python_script version.

okey, will try that instead…

would it be possible to get some more detailed instructions?
for me it is not clear at all how to install and how to set up at the end

for example:
You can install this script via HACS or just download thermostat_update.py file and save it in /config/python_scripts folder.

both options are not working

Both options are working. With HACS you can install script from Home Assistant UI. There is readme file in repository and in HACS with configuration example. Ask a specific question and I’ll try to help.

Ok, so i copy that file to that specific folder.

Than what?
Is this “configuration” to be put in configuration.yaml or automatisation.yaml? (Looks more like an automisation than a configuration. If it needs to be in automatisation please rename automatisation and not configuration, thid is missleading)

Furthermure: if this is working, are the thermostats than working with the google assistant? (Right now they are visible but everything is greyed out and i can’t set a setpoint temp)

in conifgurtation.yaml, i get an error when checking the config in the HA UI.
so I have put it in the automtions.yaml. That’s fine, checking the log, I see the following:

## Log Details (ERROR)

Sun Sep 22 2019 15:55:41 GMT+0200 (Mitteleuropäische Sommerzeit)

Error while executing automation automation.update_thermostats. Service not found for call_service at pos 1: Unable to find service python_script/thermostat_update

it is installed via HACS!!

and here the error code if working with the app deamon

[19:08:07] INFO: Starting AppDaemon...
2019-09-22 19:08:09.533036 INFO AppDaemon Version 3.0.5 starting
2019-09-22 19:08:09.533542 INFO Configuration read from: /config/appdaemon/appdaemon.yaml
2019-09-22 19:08:09.536344 INFO AppDaemon: Starting Apps
2019-09-22 19:08:09.544687 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2019-09-22 19:08:09.806022 INFO AppDaemon: HASS: HASS Plugin Initializing
2019-09-22 19:08:09.806799 INFO AppDaemon: HASS: HASS Plugin initialization complete
2019-09-22 19:08:09.807449 INFO Dashboards are disabled
2019-09-22 19:08:09.807716 INFO API is disabled
2019-09-22 19:08:12.617603 INFO AppDaemon: HASS: Connected to Home Assistant 0.99.2
2019-09-22 19:08:13.281243 INFO AppDaemon: Got initial state from namespace default
2019-09-22 19:08:14.731451 INFO AppDaemon: Reading config
2019-09-22 19:08:14.737418 WARNING AppDaemon: Error loading configuration
2019-09-22 19:08:14.737865 WARNING AppDaemon: parser says
2019-09-22 19:08:14.738670 WARNING AppDaemon:   in "<unicode string>", line 7, column 1:
    ������������sensor:��sensor.temperature ... 
    ^
2019-09-22 19:08:14.739077 WARNING AppDaemon: could not find expected ':' while scanning a simple key
2019-09-22 19:08:14.739619 WARNING AppDaemon: File '/config/appdaemon/apps/thermostats-update/apps.yaml' invalid structure - ignoring
2019-09-22 19:08:14.741087 WARNING AppDaemon: ------------------------------------------------------------
2019-09-22 19:08:14.741493 WARNING AppDaemon: Unexpected error loading config file: /config/appdaemon/apps/thermostats-update/._apps.yaml
2019-09-22 19:08:14.742112 WARNING AppDaemon: ------------------------------------------------------------
2019-09-22 19:08:14.747882 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/appdaemon/appdaemon.py", line 1677, in read_config_file
    config_file_contents = yamlfd.read()
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 37: invalid start byte
2019-09-22 19:08:14.748987 WARNING AppDaemon: File '/config/appdaemon/apps/thermostats-update/._apps.yaml' invalid structure - ignoring
2019-09-22 19:08:14.749628 INFO AppDaemon: /config/appdaemon/apps/thermostats-update/apps.yaml added or modified
2019-09-22 19:08:14.748283 WARNING AppDaemon: ------------------------------------------------------------
2019-09-22 19:08:14.750275 INFO AppDaemon: /config/appdaemon/apps/thermostats-update/._apps.yaml added or modified
2019-09-22 19:08:14.750812 INFO AppDaemon: /config/appdaemon/apps/thermostats-update/apps.yaml added or modified
2019-09-22 19:08:14.751350 INFO AppDaemon: /config/appdaemon/apps/thermostats-update/._apps.yaml added or modified
2019-09-22 19:08:14.752345 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2019-09-22 19:08:14.753263 INFO AppDaemon: Adding /config/appdaemon/apps/thermostats-update to module import path
2019-09-22 19:08:14.754581 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/thermostats-update/thermostats-update.py - ignoring
2019-09-22 19:08:14.756555 INFO AppDaemon: App initialization complete