Python Script Integration - tado automation in home assistant

Dears all, I’m trying to configure in Home Assistant a python scritp that automatically change the tado valves temperature offset based on an external temperature sensor configured in Home Assistant.

The project of the script has been developed by Jacopo and reported in this topic:

The script works, infact the tado offset changes in time, and I can see that from the phone tado app.

The problem is the home assistant integration.

So far.

I have add the following in my sensors.yaml file (included in my configuration.yaml as: sensor: !include sensors.yaml)

  - platform: command_line
    name: TadoOffset_Sala
    command: 'python3 /config/Tado_script_Sala.py'
    value_template: "{{value_json.offset}}"
    json_attributes:
      - info_message
    unit_of_measurement: '°C'
    scan_interval: 180

the json attributes are generated by the python script as:

object = {
    'offset': NEW_OFFSET,
    'info_message': info,
}
json_dump = json.dumps(object)
print(json_dump)

After the Home Assistant restarts the entity sensors.tadooffset_sala appairs, but it is inactive

Looking in logs I have found the follow error:

2020-06-22 16:38:56 ERROR (SyncWorker_9) [homeassistant.components.command_line.sensor] Command failed: python3 /config/Tado_script_Sala.py

2020-06-22 16:38:56 WARNING (SyncWorker_9) [homeassistant.components.command_line.sensor] Empty reply found when expecting JSON data

Can someone help me please?

Sorry for the request, I have solved the issue.

in the script where missed

import json

1 Like