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
69.99k stars 29.07k forks source link

Tuya - incorrect scaling of current (amps) value #116031

Open wasp100 opened 2 months ago

wasp100 commented 2 months ago

The problem

I’ve recently connected a Tuya smart switch rated at 30 amps to control the water heater. I’ve integrated into Home Assistant using the official Tuya app. I’ve noticed that the current shown in the Tuya app is correct at 18A, however in HA, it shows as 0.018A!! It is wrong by a factor of a 1000. Can we please fix?

What version of Home Assistant Core has the issue?

2024.4

What was the last working version of Home Assistant Core?

No response

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

I have another Tuya smart switch controlling a pool pump (which draws about 5A) and this amp value is correct in HA. Could it be perhaps a limit in the code for the current drawn in HA? Perhaps, if it’s greater than 10A, it shows the wrong value??

home-assistant[bot] commented 2 months ago

Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this issue as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tuya` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tuya` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tuya documentation tuya source (message by IssueLinks)

wasp100 commented 2 months ago

Hi! Any feedback on this @frenck ? Thanks

wasp100 commented 1 month ago

@frenck can you please advise? Seems like HA is showing the mA value as an Amp value hence the value is out by a factor of a 1000.

frenck commented 1 month ago

Please attach a download of the diagnostic of this device from Home Assistant and attach it to this issue (as requested by the issue template as well).

Thanks already 👍

../Frenck

wasp100 commented 1 month ago

Hi @frenck , see below extract of diagnostic: I see the current is being measured in mA. I've drawn the diagnostics of another tuya device and that shows Amps. I can't seem to understand why the one device is measuring in mA and the other in Amps

"function": {
  "switch_1": {
    "type": "Boolean",
    "value": {}
  },
  "countdown_1": {
    "type": "Integer",
    "value": {
      "unit": "s",
      "min": 0,
      "max": 86400,
      "scale": 0,
      "step": 1
    }
  },
  "relay_status": {
    "type": "Enum",
    "value": {
      "range": [
        "power_off",
        "power_on",
        "last"
      ]
    }
  }
},
"status_range": {
  "switch_1": {
    "type": "Boolean",
    "value": {}
  },
  "countdown_1": {
    "type": "Integer",
    "value": {
      "unit": "s",
      "min": 0,
      "max": 86400,
      "scale": 0,
      "step": 1
    }
  },
  "relay_status": {
    "type": "Enum",
    "value": {
      "range": [
        "power_off",
        "power_on",
        "last"
      ]
    }
  },
  "add_ele": {
    "type": "Integer",
    "value": {
      "unit": "kwh",
      "min": 0,
      "max": 50000,
      "scale": 3,
      "step": 100
    }
  },
  "cur_current": {
    "type": "Integer",
    "value": {
      "unit": "mA",
      "min": 0,
      "max": 30000,
      "scale": 3,
      "step": 1
    }
  },
  "cur_voltage": {
    "type": "Integer",
    "value": {
      "unit": "V",
      "min": 0,
      "max": 5000,
      "scale": 1,
      "step": 1
    }
  },
  "cur_power": {
    "type": "Integer",
    "value": {
      "unit": "W",
      "min": 0,
      "max": 80000,
      "scale": 1,
      "step": 1
    }
  }
},
"status": {
  "switch_1": false,
  "countdown_1": 0,
  "relay_status": "power_off",
  "add_ele": 100,
  "cur_current": 0,
  "cur_voltage": 2397,
  "cur_power": 0
wasp100 commented 1 month ago

Diagnostics of the other Tuya device shows current in Amps (which is correct) "cur_current": { "type": "Integer", "value": { "unit": "A", "min": 0, "max": 50000, "scale": 3, "step": 100 }

wasp100 commented 1 month ago

@frenck Does this help with figuring out what’s going on with the incorrect current value? Thanks