TuYa TS0601 local temperature as senor in HA: state as sensor value

Hi all,

I am trying te read out the local_temperature value from the TuYa TS0601 valve. I have it connected via zigbee2mqtt and can control it with the generic thermostate.

For this project i want to read the local temperature from 3 valves in one (big) room, take the average temperature and use a “master” thermostate for all 3 thermostates. (one thermostate to rule them all :sunglasses:) To make this happen i want to use the local temperature as a sensor in HA as input for this master thermostate.

I see the local temperature in the generic thermostate card, but cannot find a way to read it as a sensor. Any help would be highly appreciated. :+1:

Kind regards,

Barry

I understand that there is no temperature sensor created for this device? Then maybe it’s stored as attribute.

Don’t worry. Since you are using zigbee2mqtt, all data can be found. You can create your own (manually configured) mqtt sensors. Having 3 temp sensors, create another one: min_max sensor to represent average temp.

Hi Mazym,

You are right, no sensor is created. Stored is attribute, did some reading, does not make sense to me yet :slight_smile: Quite a new user to HA.

In zigbee2mqtt these are the exposed values:

i would like to use the follwing code to get a average temp from the room:

sensors:
  - platform: template
    sensors:
      average_temperature:
        friendly_name: "Average temperature"
        unit_of_measurement: "°C"
        device_class: temperature
        value_template: >
          {% set hall = states('sensor.hall_sonoff_temperature') | float %}
          {% set landing = states('sensor.landing_sonoff_temperature') | float %}
          {% set front_room = states('sensor.front_room_sonoff_temperature') | float %}
          {{ ((hall + landing + front_room) / 3) | round(1) }}

## code from https://blog.defsdoor.org/home-assistant-heating-control/ ##

The docs in zigbee2mqtt state that the local_temperature cannot be read as a attribute:


Climate #

This climate device supports the following features: current_heating_setpoint, local_temperature, system_mode, local_temperature_calibration, away_mode, preset.

  • current_heating_setpoint: Temperature setpoint. To control publish a message to topic zigbee2mqtt/FRIENDLY_NAME/set with payload {"current_heating_setpoint": VALUE} where VALUE is the °C between 5 and 35. To read send a message to zigbee2mqtt/FRIENDLY_NAME/get with payload {"current_heating_setpoint": ""}.
  • local_temperature: Current temperature measured on the device (in °C). Reading (/get) this attribute is not possible.

After a bit more reading i found this site that uses a state as a sensor:
https://www.hiscorebob.lu/2017/11/home-assistant-plot-a-graph-with-objects-attributes/

I’ve adapted the code to:

sensor:
  - platform: template
    sensors:
      valve1_temp:
        value_template: {{climate.valve1.attributes.local_temperature}}

I’ve put it in the configuration.yaml but after checking my setup i get:
Configuration invalid

                      Error loading /config/configuration.yaml: invalid key: "OrderedDict([('climate.valve1.attributes.local_temperature', None)])"

in “/config/configuration.yaml”, line 19, column 0

the states that are available are:

hvac_modes:
  - auto
min_temp: 5
max_temp: 35
target_temp_step: 0.5
preset_modes:
  - manual
current_temperature: 22.5
temperature: 12
preset_mode: manual
auto_lock: MANUAL
away_mode: 'OFF'
away_preset_days: 1
away_preset_temperature: 15
battery_low: false
boost_time: 300
child_lock: UNLOCK
comfort_temperature: 20
current_heating_setpoint: 12
eco_temperature: 15
force: normal
holidays:
  - hour: 6
    minute: 0
    temperature: 20
  - hour: 8
    minute: 0
    temperature: 15
  - hour: 11
    minute: 30
    temperature: 15
  - hour: 12
    minute: 30
    temperature: 15
  - hour: 17
    minute: 30
    temperature: 20
  - hour: 22
    minute: 0
    temperature: 15
linkquality: 57
local_temperature: 22.5
local_temperature_calibration: -1
max_temperature: 35
min_temperature: 5
position: 0
preset: manual
system_mode: auto
valve_detection: null
week: 5+2
window_detection: 'OFF'
window_detection_params:
  minutes: 10
  temperature: 5
workdays:
  - hour: 6
    minute: 0
    temperature: 20
  - hour: 8
    minute: 0
    temperature: 15
  - hour: 11
    minute: 30
    temperature: 15
  - hour: 12
    minute: 30
    temperature: 15
  - hour: 17
    minute: 30
    temperature: 20
  - hour: 22
    minute: 0
    temperature: 15
friendly_name: valve1
supported_features: 17

Found the solution:

sensor:
  - platform: mqtt
    name: tempvalve1
    state_topic: "zigbee2mqtt/valve1"
    value_template: '{{ value_json.local_temperature|float }}'
1 Like

As the way MQTT configurations are entered has recently changed, thought I’d contribute my settings.

In this case for the device ‘Bedroom Radiator’

mqtt:
  sensor:
  - name: "Bedroom Radiator local temperature"
    state_topic: "zigbee2mqtt/Bedroom Radiator"
    state_class: measurement
    device_class: temperature
    value_template: '{{ value_json.local_temperature|float }}'
1 Like