Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Device Support Request] BlitzWolf BW-SHP13 smart plug (aka Tuya TS0121) #605

Closed
mallorca2288 opened this issue Nov 27, 2020 · 78 comments
Closed
Labels
stale Issue is inactivate and might get closed soon

Comments

@mallorca2288
Copy link
Contributor

Is your feature request related to a problem? Please describe.
BlitzWolf BW-SHP13 smart plug 16A EU version, same device as TuYa TS0121 smart plug.
imagen

Device joins zigbee network and it's recognized by home-assistant.

Entities are created for:

  • On/Off switch: It works
  • Electrical power measurement (W): Values updated correctly.
  • Energy metering (kWh): Entity is created but values are never updated.

This entities are missing:

  • Current (A).
  • Voltage (V).

Describe the solution you'd like
Please consider adding support for the missing values and fixing the electrical power measurement value.

Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line.

{
  "node_descriptor": "NodeDescriptor(byte1=1, byte2=64, mac_capability_flags=142, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=0)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0051",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0702",
        "0x0b04"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZ3000_3ooaz3ng",
  "model": "TS0121",
  "class": "zigpy.device.Device"
}

Additional context
This device doesn't support reporting of electrical measurement values, so it needs to be polled. It's supported on zigbee2mqtt, they fixed this by polling the values every 10 seconds.

Voltage value is correctly reported if I manually get the attribute value:
imagen

@CharlieBailly
Copy link
Contributor

Hi, yes it would be great if it was fully supported as you describ it.
I also have the same device, but with a slightly different signature : (the manufacturer part differ)

 {
  "node_descriptor": "NodeDescriptor(byte1=1, byte2=64, mac_capability_flags=142, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=0)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0051",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0702",
        "0x0b04"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZ3000_g5xawfcq",
  "model": "TS0121",
  "class": "zigpy.device.Device"
}

@TheJulianJES
Copy link
Collaborator

Z2M polls them every 60 seconds: https://github.com/Koenkk/zigbee-herdsman-converters/blob/c9ed6bb75a9682cf60b41e4e7647c653480f9a6c/devices.js#L1490-L1503 because they don't support attribute reports apparently (or at least don't do it properly).
It doesn't look like that zha-quirks has something similar yet. So I'm not sure how something like this would even be implemented correctly.

@dmulcahey
Copy link
Collaborator

ZHA already polls the electrical measurement cluster. Is this not an EM cluster?

@TheJulianJES
Copy link
Collaborator

It should be. Perhaps it's missing these constant attributes (https://github.com/Koenkk/zigbee-herdsman-converters/blob/c9ed6bb75a9682cf60b41e4e7647c653480f9a6c/devices.js#L1479-L1483) (or the binding above that)? (Just guessing at this point though).
The Xiaomi quirk does something similar: https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/xiaomi/__init__.py#L410-L415
(Although the Xiaomi Smart Plug (EU) with power reporting also worked before doing that for me)

@TheJulianJES
Copy link
Collaborator

I just re-read the issue. It looks like the electrical power measurement (W) is working correctly, right? Only voltage and current do not have entities created for them. The total "smart" (?) energy meter isn't updated.
That looks like the same "issue" basically all power measuring plugs have (at least the Xiaomi Plugs) (?)

@dmulcahey
Copy link
Collaborator

Yes, if that’s the case. We currently only support 1 sensor per cluster. This is currently a limitation in ZHA.

@TheJulianJES
Copy link
Collaborator

TheJulianJES commented Jan 18, 2021

Got my Blitzwolf plugs today. They seem to work well so far. (On/off + current consumption).
With Z2M you can also set the initial power on state: https://www.zigbee2mqtt.io/devices/TS0121_plug.html#power_outage_memory-enum
I guess that's something ZHA could also implement. Since that shouldn't be hard, I'll see if I get around to it in the next couple of days.

Edit: This would be addressed by #742
For all other issues (voltage, current not displaying), ZHA would need to be "changed".

@Hedda
Copy link
Contributor

Hedda commented Jan 28, 2021

Yes, if that’s the case. We currently only support 1 sensor per cluster. This is currently a limitation in ZHA.

Any plans to extend ZHA to support more than one sensor per cluster?

BlitzWolf BW-SHP13 smart plug 16A EU version, same device as TuYa TS0121 smart plug.

Device joins zigbee network and it's recognized by home-assistant.

Entities are created for:

  • On/Off switch: It works
  • Electrical power measurement (W): Values updated correctly.
  • Energy metering (kWh): Entity is created but values are never updated.

This entities are missing:

  • Current (A).
  • Voltage (V).

Hope to see full support for these Tuya smart plugs as there are few inexpensive Zigbee plugs featuring power/energy-metering.

Lonsonho also has Tuya model TS0121 branded variant which also features support. for power-metering and energy-metering:

https://zigbee.blakadder.com/Lonsonho_TS0121.html

https://www.aliexpress.com/item/4001118546894.html

Really like that and BlitzWolf BW-SHP13 because power/energy-metering and fact that they are both inexpensive and very small.

Here are some pictures of Lonsonho TS0121 version:

image

image

image

image

@Hedda
Copy link
Contributor

Hedda commented Jan 28, 2021

And this one from "Rehentele" looks to be yet another Tuya TS0121 variant with power-metering and energy-metering support:

https://www.aliexpress.com/item/4000449939329.html

Note that Rehentele seem to sell a TS0121 version with power-metering as well as a TS0111 version without that looks the same.

image

image

image

image

@vpomax
Copy link

vpomax commented Feb 12, 2021

It shows consumption in kWh (energy metering) as "unknow"... any solution about?

@sakara
Copy link

sakara commented Feb 12, 2021

Please, add the missing entities so i can move from z2m to ZHA.

@McLP11
Copy link

McLP11 commented Feb 12, 2021

same request from my side, this plug is perfect as size and power capability, so having the chance to see the consumption in ZHA will be the perfect match. I really hope this feature can be implemented, thanks.

@Gamester17
Copy link
Contributor

That looks like the same "issue" basically all power measuring plugs have (at least the Xiaomi Plugs) (?)

For all other issues (voltage, current not displaying), ZHA would need to be "changed".

What exactly needs to be "changed" in the ZHA integration to overcome the limit of 1 sensor per cluster?

How many sensors per cluster does other Zigbee implementations like example Zigbee2MQTT support?

@manouallou
Copy link

It would be nice to know if there is a roadmap for this "fix" (more than 1 sensor per cluster) or else we should make a decision to steer away from Zigbee power plugs.

@rklomp
Copy link

rklomp commented Mar 18, 2021

+1. Bought a Tuya TS0121 from aliexpress to measure consumption of different devices.

On/Off switch works and Electrical power measurement (W) updated correctly.

I can retrieve the total usage from the device in the Metering cluster (0x0702) using the current_summ_delivered attribute ( 0x0000), but unfortunately there is no sensor for this.

manufacturer: _TZ3000_rdtixbnu
model: TS0121

@flabbamann
Copy link
Contributor

flabbamann commented Apr 3, 2021

I did some research with my BW-SHP13 in Home Assistant via ZHA:

The current_summ_delivered attribute @rklomp mentioned gets written to zigbee.db. You could use a sql sensor to read the value from there.

You have to multiply that value by 10 to get Wh or by 0.01 to get kWh.

- platform: sql
  db_url: sqlite:////config/zigbee.db
  scan_interval: 30
  queries:
  - name: plug_metering
    query: "SELECT value * 0.01 as value FROM attributes WHERE ieee = 'YOUR_DEVICEID' AND cluster = 1794 AND attrid = 0"
    column: "value" 
    unit_of_measurement: kWh

So, the data is there. What needs to be done to show that via the device sensor?

Sidenote:
I cross checked my Blitzwolf with an old dumb metering plug a have and the Blitzwolf always shows about 50% higher values. The Blitzwolf shows 120W while my other plug shows 80W (power measurement). So in that case I would multiply by 0.0066 instead of 0.01 to get a more accurate value, but I'm unsure which device I should trust more. In the end both are very cheap and no high-precision metering devices 😉 . If I take that into account both devices metering (kWh) values match.

@Hedda
Copy link
Contributor

Hedda commented May 19, 2021

I just re-read the issue. It looks like the electrical power measurement (W) is working correctly, right? Only voltage and current do not have entities created for them. The total "smart" (?) energy meter isn't updated.
That looks like the same "issue" basically all power measuring plugs have (at least the Xiaomi Plugs) (?)

Yes, if that’s the case. We currently only support 1 sensor per cluster. This is currently a limitation in ZHA.

FYI, there is a developers/development discussion about this "issue" in this related PR by @stattin42 -> home-assistant/core#50471

There are also two problem discussion about the root cause in HA, see home-assistant/core#44539 and home-assistant/core#34090

Users tested/confirmed issue on BlitzWolf BW-SHP13, Innr SP 120 / SP120, Schwaiger ZHS15, Lonsonho 16A Energy Monitoring Plug

@juhanjuku
Copy link

I did some research with my BW-SHP13 in Home Assistant via ZHA:

The current_summ_delivered attribute @rklomp mentioned gets written to zigbee.db. You could use a sql sensor to read the value from there.

You have to multiply that value by 10 to get Wh or by 0.01 to get kWh.

- platform: sql
  db_url: sqlite:////config/zigbee.db
  scan_interval: 30
  queries:
  - name: plug_metering
    query: "SELECT value * 0.01 as value FROM attributes WHERE ieee = 'YOUR_DEVICEID' AND cluster = 1794 AND attrid = 0"
    column: "value" 
    unit_of_measurement: kWh

So, the data is there. What needs to be done to show that via the device sensor?

Sidenote:
I cross checked my Blitzwolf with an old dumb metering plug a have and the Blitzwolf always shows about 50% higher values. The Blitzwolf shows 120W while my other plug shows 80W (power measurement). So in that case I would multiply by 0.0066 instead of 0.01 to get a more accurate value, but I'm unsure which device I should trust more. In the end both are very cheap and no high-precision metering devices 😉 . If I take that into account both devices metering (kWh) values match.

You are correct, current_summ_delivered in in zigbee db, BUT it updates there very rarely ( once per day)
I have several different plugs and only one plug, BlitzWolf TS0121, updates correctly, every minute.

SQL query may be used if we could somehow force db value update.

@stattin42
Copy link

While sql sensors or events for attribute changes could be a way to handle multiple attributes per cluster, I am still struggling a little with the rationale behind selecting an optional attribute as the base entity/sensor for a cluster or channel. Wouldn't it be more useful to use a mandatory attribute for the sensor?

Now that things are what they are, I have some sympathy for not breaking things by changing existing behaviour. I cannot help thinking, though, that there is a sense of urgency finding a solution. Hopefully a solution which does not require templating for commonly used mandatory attributes. Support is currently broken for many compliant devices unless they support a certain optional attribute.

@Celer21
Copy link

Celer21 commented Nov 5, 2021

I update HA to 2021.11. The BW-SPH13 has now another sensors - great!
But i think, that sensors electrical_measurement_rms_current and total comsumption has to be divided by 1000.

It show, tahat my Washingmachine consume 2.400 W (correct ) and 10.000 A (that is is not correct).
Correct is 10 A.

image

image

@juhanjuku
Copy link

Is your energy sensor kWh updating correctly?
My BlitzWolf plug updates kWh sensor only once when restarted and is freezed after that.

@Celer21
Copy link

Celer21 commented Nov 5, 2021

It's updatete with no problem.
This is chart of my Washing Mashine cycle.
image

If there is small load, it change after every 1 or 10 W or so. The kWh shoud be divided by 1000 or 100 (I have no energymeter to test it)

image

@flabbamann
Copy link
Contributor

@Celer21 please try if reconfiguring your plug fixes total consumption 😃

@mbo18
Copy link
Contributor

mbo18 commented Nov 5, 2021

Works as expected since last HA update! Consumption (kWh) seems still not reliable

@juhanjuku
Copy link

I can confirm now BlitzWolf plug kWh is updating, but Shwaiger and Innr SP120 are still freezed.
image
For Innr SP120 reconfigure fails
image
logInnrSP120.txt

@flabbamann
Copy link
Contributor

#1131 adds the correct divisor for rms_current.
The devices likely need to be reconfigured to display the correct values.

@davet2001
Copy link
Contributor

davet2001 commented Nov 8, 2021

#1131 adds the correct divisor for rms_current. The devices likely need to be reconfigured to display the correct values.

Yes, for a different device I had to re-set up the zigbee device in HA to get the new scaling.

@Celer21
Copy link

Celer21 commented Nov 8, 2021

In which standard version of HA will it be distributed? I only have one instance of HA and cannot use dev or beta channel.
Thanks!

@Hedda
Copy link
Contributor

Hedda commented Nov 8, 2021

In which standard version of HA will it be distributed? I only have one instance of HA and cannot use dev or beta channel.

No one can tell until a new release and it has been bumped in HA so keep an eye on https://github.com/zigpy/zha-device-handlers/releases in combination with "Bump ZHA quirks version" in https://github.com/home-assistant/core/pulls?q=zha then wait for it to appear under "All changes" in https://rc.home-assistant.io/latest-release-notes/

@Celer21
Copy link

Celer21 commented Nov 8, 2021

@Hedda Thank you for links.

@pfriedrich84
Copy link

pfriedrich84 commented Jan 24, 2022

Hi everyone,
i think this is not fixed yet? The current is showing wrong values.

Here yu have an example:
image

So in fact the current requires a divider of appr. 1.000 - in this case 224V multiplied with 662A would mean 148,29kw - I am not charing an electric car here ;-)
With the correction it would be 148Watts so way more reasonable and especially the consumption would be better.

cheers

zhaquirks.tuya.ts0121_plug.Plug
{ "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)", "endpoints": { "1": { "profile_id": 260, "device_type": "0x0051", "in_clusters": [ "0x0000", "0x0004", "0x0005", "0x0006", "0x0702", "0x0b04" ], "out_clusters": [ "0x000a", "0x0019" ] } }, "manufacturer": "_TZ3000_g5xawfcq", "model": "TS0121", "class": "zhaquirks.tuya.ts0121_plug.Plug" }

Update: I fix it with a simple template right now but maybe someone wants to fix the zhaqurik:
image

@mallorca2288
Copy link
Contributor Author

mallorca2288 commented Jan 24, 2022

Hi everyone, i think this is not fixed yet? The current is showing wrong values.

Here yu have an example: image

So in fact the current requires a divider of appr. 1.000 - in this case 224V multiplied with 662A would mean 148,29kw - I am not charing an electric car here ;-) With the correction it would be 148Watts so way more reasonable and especially the consumption would be better.

cheers

zhaquirks.tuya.ts0121_plug.Plug { "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)", "endpoints": { "1": { "profile_id": 260, "device_type": "0x0051", "in_clusters": [ "0x0000", "0x0004", "0x0005", "0x0006", "0x0702", "0x0b04" ], "out_clusters": [ "0x000a", "0x0019" ] } }, "manufacturer": "_TZ3000_g5xawfcq", "model": "TS0121", "class": "zhaquirks.tuya.ts0121_plug.Plug" }

Update: I fix it with a simple template right now but maybe someone wants to fix the zhaqurik: image

Have you tried reconfiguring the switch in the device page? I did that with the switches that I had previously paired and it fixed all the wrong values.

@Celer21
Copy link

Celer21 commented Jan 25, 2022

My plug shows wrong current value too.
I am running HA 2021.12.10 so maybe the patch will be included in next release?
Is it enough to reconfiguring device? Or is it necessary to remove from ZHA and repair it again?

@pfriedrich84
Copy link

pfriedrich84 commented Jan 25, 2022

Have you tried reconfiguring the switch in the device page? I did that with the switches that I had previously paired and it fixed all the wrong values.

sure multiple times. its still showing crazy currents and wrong consumption - real consumption is about 0,33kwh ... ;-)
There is just my work laptop running on this switch
image

@mallorca2288
Copy link
Contributor Author

mallorca2288 commented Jan 25, 2022

Have you tried reconfiguring the switch in the device page? I did that with the switches that I had previously paired and it fixed all the wrong values.

sure multiple times. its still showing crazy currents and wrong consumption - real consumption is about 0,33kwh ... ;-) There is just my work laptop running on this switch

What values do you get for attributes ac_current_divider and ac_current_multiplier in the TuyaZBElectricalMeasurement cluster?

@MattWestb
Copy link
Contributor

I think repairing its needed or reading the "new" added (in the quirk) attribute then its null if not being populated and then ZHA is not using them.

@pfriedrich84
Copy link

Hi all,
the cluster attributes where Null so i selected the right divisor/multiplier and then it changed to a reasonable value:
image

Thanks a lot!

@rkruisselbrink
Copy link

In which standard version of HA will it be distributed? I only have one instance of HA and cannot use dev or beta channel.

No one can tell until a new release and it has been bumped in HA so keep an eye on https://github.com/zigpy/zha-device-handlers/releases in combination with "Bump ZHA quirks version" in https://github.com/home-assistant/core/pulls?q=zha then wait for it to appear under "All changes" in https://rc.home-assistant.io/latest-release-notes/

FYI: The new version of zha quirks (0.0.66) is included in the HA 2022.02 release :)

@rkruisselbrink
Copy link

rkruisselbrink commented Feb 4, 2022

My device total usage readings (metering_summation_delivered) still appear to be wrong in HA (after reconfigure). I don't know what steps to take to fix this?

Amperage, voltage and wattage readings all seem fine, but summation shows a lot of kWh's which should be Wh i think. So probably a wrong multiplier somewhere? But the TuyaZBElectricalMeasurement attributes seem fine. (ac_current_divider: 1000; ac_current_multiplier: 1)

metering_summation_delivered:
image

Energy dashboard - individual device:
image

@mallorca2288
Copy link
Contributor Author

mallorca2288 commented Feb 4, 2022

My device total usage readings (metering_summation_delivered) still appear to be wrong in HA (after reconfigure). I don't know what steps to take to fix this?

Try setting the values of the attributes divisor (0x0302) and multiplier (0x0301) in the TuyaZBMeteringCluster cluster. Divisor should be set to 100 and multiplier should be set to 1.

@rkruisselbrink
Copy link

My device total usage readings (metering_summation_delivered) still appear to be wrong in HA (after reconfigure). I don't know what steps to take to fix this?

Try setting the values of the attributes divisor (0x0302) and multiplier (0x0301) in the TuyaZBMeteringCluster cluster. Divisor should be set to 100 and multiplier should be set to 1.

Those are already set to 100 (divider) and 1 (multiplier), but I set them both anyway and now the values seem much more reasonable! Thanks! 😊

@ChefkeGremmen
Copy link

My device total usage readings (metering_summation_delivered) still appear to be wrong in HA (after reconfigure). I don't know what steps to take to fix this?

Try setting the values of the attributes divisor (0x0302) and multiplier (0x0301) in the TuyaZBMeteringCluster cluster. Divisor should be set to 100 and multiplier should be set to 1.

Those are already set to 100 (divider) and 1 (multiplier), but I set them both anyway and now the values seem much more reasonable! Thanks! 😊

I tried the same and it also fixed the issue for me completely!

@Atiunderscore
Copy link

I'm currently trying to get an Blitzwolf BW-SHP15 to work with ZHA (connected through ConbeeII). I can seem to receive the amp and volt, but not the watt and kWh. The history of the sensor shows me it's not updating. Anyone has a clue on how I can fix this? I want to know the watt to integrate it in to automations which need watt to determine if a machine is running or not.

Blitzwolf BW-SHP15

@radek-foltyn
Copy link

Hi, can I ask you. Is it possible to delete sum consumption (power)? I have Zigbee2mqtt.

@Hedda
Copy link
Contributor

Hedda commented May 10, 2022

Hi, can I ask you. Is it possible to delete sum consumption (power)? I have Zigbee2mqtt.

@radek-foltyn zha-device-handlers (zha-quirks) is for Home Assistant ZHA, not for Zigbee2MQTT. For Zigbee2MQTT see instead:

https://github.com/Koenkk/zigbee2mqtt/issues/

https://github.com/Koenkk/zigbee2mqtt/discussions

@github-actions
Copy link

github-actions bot commented Nov 6, 2022

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Issue is inactivate and might get closed soon label Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue is inactivate and might get closed soon
Projects
None yet
Development

No branches or pull requests