home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.02k stars 31.06k forks source link

Energy Counter (kWh) not supported on smart TUYA plug #129409

Open Lafferfr opened 4 weeks ago

Lafferfr commented 4 weeks ago

The problem

I have LIDL Smart Plugs which support energy metering. There is also a parameter which holds the value of energy consumption in kWh. But this is not shown in the Tuya Integration for HomeAssistant, but in HomeAssistant Diagnosis logs (attached) it is shown (look for add_ele):

HOW can it be activated and usable in HomeAssistant?

{
    "id": "bf3cfc75c7594d67efhcjc",
    "name": "Playstation",
    "category": "cz",
    "product_id": "j1v25l17",
    "product_name": "Socket",
    "online": true,
    "sub": true,
    "time_zone": "+02:00",
    "active_time": "2024-10-15T09:07:57+00:00",
    "create_time": "2024-10-15T09:07:57+00:00",
    "update_time": "2024-10-15T09:07:57+00:00",
    "function": {
      "switch_1": {
        "type": "Boolean",
        "value": {}
      },
      "countdown_1": {
        "type": "Integer",
        "value": {
          "unit": "s",
          "min": 0,
          "max": 43200,
          "scale": 0,
          "step": 1
        }
      },
      "relay_status": {
        "type": "Enum",
        "value": {
          "range": [
            "power_off",
            "power_on",
            "last"
          ]
        }
      },
      "light_mode": {
        "type": "Enum",
        "value": {
          "range": [
            "none",
            "relay",
            "pos"
          ]
        }
      }
    },
    "status_range": {
      "switch_1": {
        "type": "Boolean",
        "value": {}
      },
      "countdown_1": {
        "type": "Integer",
        "value": {
          "unit": "s",
          "min": 0,
          "max": 43200,
          "scale": 0,
          "step": 1
        }
      },
      "add_ele": {
        "type": "Integer",
        "value": {
          "unit": "kwh",
          "min": 0,
          "max": 100000000,
          "scale": 3,
          "step": 100
        }
      },
      "cur_current": {
        "type": "Integer",
        "value": {
          "unit": "mA",
          "min": 0,
          "max": 30000,
          "scale": 0,
          "step": 1
        }
      },
      "cur_power": {
        "type": "Integer",
        "value": {
          "unit": "W",
          "min": 0,
          "max": 50000,
          "scale": 1,
          "step": 1
        }
      },
      "cur_voltage": {
        "type": "Integer",
        "value": {
          "unit": "V",
          "min": 0,
          "max": 5000,
          "scale": 1,
          "step": 1
        }
      },
      "relay_status": {
        "type": "Enum",
        "value": {
          "range": [
            "power_off",
            "power_on",
            "last"
          ]
        }
      },
      "light_mode": {
        "type": "Enum",
        "value": {
          "range": [
            "none",
            "relay",
            "pos"
          ]
        }
      }
    },
    "status": {
      "switch_1": true,
      "countdown_1": 0,
      "add_ele": 960,
      "cur_current": 24,
      "cur_power": 50,
      "cur_voltage": 2360,
      "relay_status": "power_off",
      "light_mode": "relay"
    },
    "home_assistant": {
      "name": "Playstation",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "select.playstation_verhalten_beim_einschalten",
            "state": "power_off",
            "attributes": {
              "options": [
                "power_off",
                "power_on",
                "last"
              ],
              "friendly_name": "Playstation Verhalten beim Einschalten"
            },
            "last_changed": "2024-10-29T11:34:30.084049+00:00",
            "last_reported": "2024-10-29T11:34:30.084049+00:00",
            "last_updated": "2024-10-29T11:34:30.084049+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "select.playstation_anzeigelichtmodus",
            "state": "relay",
            "attributes": {
              "options": [
                "none",
                "relay",
                "pos"
              ],
              "friendly_name": "Playstation Anzeigelichtmodus"
            },
            "last_changed": "2024-10-29T11:34:30.084250+00:00",
            "last_reported": "2024-10-29T11:34:30.084250+00:00",
            "last_updated": "2024-10-29T11:34:30.084250+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "current",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": "A",
          "state": {
            "entity_id": "sensor.playstation_stromstarke",
            "state": "0.024",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "A",
              "device_class": "current",
              "friendly_name": "Playstation Stromst\u00e4rke"
            },
            "last_changed": "2024-10-29T12:39:39.230364+00:00",
            "last_reported": "2024-10-29T12:39:39.230364+00:00",
            "last_updated": "2024-10-29T12:39:39.230364+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "power",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": "W",
          "state": {
            "entity_id": "sensor.playstation_leistung",
            "state": "5.0",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "W",
              "device_class": "power",
              "friendly_name": "Playstation Leistung"
            },
            "last_changed": "2024-10-29T12:39:39.230621+00:00",
            "last_reported": "2024-10-29T12:39:39.230621+00:00",
            "last_updated": "2024-10-29T12:39:39.230621+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "voltage",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": "V",
          "state": {
            "entity_id": "sensor.playstation_spannung",
            "state": "236.0",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "V",
              "device_class": "voltage",
              "friendly_name": "Playstation Spannung"
            },
            "last_changed": "2024-10-29T12:42:34.619431+00:00",
            "last_reported": "2024-10-29T12:42:34.619431+00:00",
            "last_updated": "2024-10-29T12:42:34.619431+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "outlet",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.playstation_steckdose_1",
            "state": "on",
            "attributes": {
              "device_class": "outlet",
              "friendly_name": "Playstation Steckdose 1"
            },
            "last_changed": "2024-10-29T12:37:11.107840+00:00",
            "last_reported": "2024-10-29T12:37:11.107840+00:00",
            "last_updated": "2024-10-29T12:37:11.107840+00:00"
          }
        }
      ]
    },
    "set_up": true,
    "support_local": true
  },

What version of Home Assistant Core has the issue?

core-2024.10.4

What was the last working version of Home Assistant Core?

core-2024.10.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tuya

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tuya

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Lafferfr commented 1 week ago

Hello Devs, can I add it manually somehow?