Getting values from diagnostic data

Hi all, I’m using the HA just two days, so please don’t kill me for this stupid question - is it possible to get a property value from diagnostic data?

I have a device with following attributes
hvac_modes: off, heat_cool, heat_cool
min_temp: 5
max_temp: 35
target_temp_step: 0.5
preset_modes: eco, program
current_temperature: 22.3
temperature: 22
preset_mode: null
friendly_name: XXX
supported_features: 17

but I need “valve_state” attribute to use it in my automation. I can see this attribute in diagnostic data, but I’m unable to get it from there and I don’t know if it’s even possible. Or is it possible to get this attribute value by some other way?

Here’s the diag data

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.11.1",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.6",
    "docker": true,
    "arch": "aarch64",
    "timezone": "XXX",
    "os_name": "Linux",
    "os_version": "6.1.21-v8",
    "supervisor": "2023.11.0",
    "host_os": "Home Assistant OS 11.1",
    "docker_version": "24.0.6",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {},
  "integration_manifest": {
    "domain": "tuya",
    "name": "Tuya",
    "codeowners": [
      "@Tuya",
      "@zlinoliver",
      "@frenck"
    ],
    "config_flow": true,
    "dependencies": [
      "ffmpeg"
    ],
    "dhcp": [
      {
        "macaddress": "105A17*"
      },
      {
        "macaddress": "10D561*"
      },
      {
        "macaddress": "1869D8*"
      },
      {
        "macaddress": "381F8D*"
      },
      {
        "macaddress": "508A06*"
      },
      {
        "macaddress": "68572D*"
      },
      {
        "macaddress": "708976*"
      },
      {
        "macaddress": "7CF666*"
      },
      {
        "macaddress": "84E342*"
      },
      {
        "macaddress": "D4A651*"
      },
      {
        "macaddress": "D81F12*"
      }
    ],
    "documentation": "https://www.home-assistant.io/integrations/tuya",
    "integration_type": "hub",
    "iot_class": "cloud_push",
    "loggers": [
      "tuya_iot"
    ],
    "requirements": [
      "tuya-iot-py-sdk==0.6.6"
    ],
    "is_built_in": true
  },
  "data": {
    "endpoint": "https://openapi.tuyaeu.com",
    "auth_type": 0,
    "country_code": "420",
    "app_type": "smartlife",
    "mqtt_connected": true,
    "disabled_by": null,
    "disabled_polling": false,
    "name": "XXX",
    "model": "",
    "category": "wk",
    "product_id": "7qx0q329p61h1ace",
    "product_name": "Floor Heating",
    "online": true,
    "sub": false,
    "time_zone": "+01:00",
    "active_time": "2023-11-09T19:07:53+00:00",
    "create_time": "2023-10-27T13:58:25+00:00",
    "update_time": "2023-11-09T19:07:54+00:00",
    "function": {
      "switch": {
        "type": "Boolean",
        "value": {}
      },
      "mode": {
        "type": "Enum",
        "value": {
          "range": [
            "auto",
            "manual"
          ]
        }
      },
      "frost": {
        "type": "Boolean",
        "value": {}
      },
      "temp_set": {
        "type": "Integer",
        "value": {
          "unit": "\u2103",
          "min": 50,
          "max": 3000,
          "scale": 1,
          "step": 5
        }
      },
      "upper_temp": {
        "type": "Integer",
        "value": {
          "unit": "",
          "min": 50,
          "max": 3000,
          "scale": 1,
          "step": 10
        }
      },
      "temp_unit_convert": {
        "type": "Enum",
        "value": {
          "range": [
            "c",
            "f"
          ]
        }
      },
      "lower_temp": {
        "type": "Integer",
        "value": {
          "unit": "",
          "min": 50,
          "max": 3000,
          "scale": 1,
          "step": 10
        }
      },
      "work_days": {
        "type": "Enum",
        "value": {
          "range": [
            "5_2",
            "6_1",
            "7"
          ]
        }
      },
      "child_lock": {
        "type": "Boolean",
        "value": {}
      }
    },
    "status_range": {
      "switch": {
        "type": "Boolean",
        "value": {}
      },
      "mode": {
        "type": "Enum",
        "value": {
          "range": [
            "auto",
            "manual"
          ]
        }
      },
      "frost": {
        "type": "Boolean",
        "value": {}
      },
      "temp_set": {
        "type": "Integer",
        "value": {
          "unit": "\u2103",
          "min": 50,
          "max": 3000,
          "scale": 1,
          "step": 5
        }
      },
      "upper_temp": {
        "type": "Integer",
        "value": {
          "unit": "",
          "min": 50,
          "max": 3000,
          "scale": 1,
          "step": 10
        }
      },
      "temp_unit_convert": {
        "type": "Enum",
        "value": {
          "range": [
            "c",
            "f"
          ]
        }
      },
      "temp_current": {
        "type": "Integer",
        "value": {
          "unit": "\u2103",
          "min": -300,
          "max": 1000,
          "scale": 1,
          "step": 1
        }
      },
      "lower_temp": {
        "type": "Integer",
        "value": {
          "unit": "",
          "min": 50,
          "max": 3000,
          "scale": 1,
          "step": 10
        }
      },
      "work_days": {
        "type": "Enum",
        "value": {
          "range": [
            "5_2",
            "6_1",
            "7"
          ]
        }
      },
      "valve_state": {
        "type": "Enum",
        "value": {
          "range": [
            "close",
            "open"
          ]
        }
      },
      "child_lock": {
        "type": "Boolean",
        "value": {}
      },
      "fault": {
        "type": "Bitmap",
        "value": {
          "label": [
            "e1",
            "e2",
            "e3"
          ]
        }
      }
    },
    "status": {
      "switch": true,
      "mode": "manual",
      "frost": false,
      "temp_set": 220,
      "upper_temp": 500,
      "temp_unit_convert": "c",
      "temp_current": 217,
      "lower_temp": 50,
      "work_days": "5_2",
      "valve_state": "close",
      "child_lock": false,
      "fault": 0
    },
    "home_assistant": {
      "name": "XXX",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "climate.XXX",
            "state": "heat_cool",
            "attributes": {
              "hvac_modes": [
                "off",
                "heat_cool",
                "heat_cool"
              ],
              "min_temp": 5.0,
              "max_temp": 300.0,
              "target_temp_step": 0.5,
              "current_temperature": 21.7,
              "temperature": 22.0,
              "friendly_name": "XXX",
              "supported_features": 1
            },
            "last_changed": "2023-11-10T07:25:13.760231+00:00",
            "last_updated": "2023-11-10T08:10:06.641673+00:00"
          }
        }
      ]
    }
  }
}

I have the same question, did you ever get this or a workaround figured out?

I’m looking for a way to do this but I haven’t found it yet. Can anyone help?

You can get attributes by getting the entity_id for the device and put it into Developer Tools - Template with this format: {{ state_attr('entity_id', 'state_attribute') }}

For example, I can get my phones battery level with:

{{ state_attr('device_tracker.my_iphone', 'battery_level') }}

Unless I’m mis-understanding what you’re trying to get.