eb3nezer
(Eb3nezer)
August 24, 2021, 11:31pm
1
My Xiaomi smart plugs are discovered fine by zigbee2mqtt, and appear fine in HA, but the energy (total kWh consumed) always shows “Unknown”.
It is a mystery, because the device configuration in HA looks correct (the topics/template for the energy sensor look correct) and I see the MQTT messages have the correct attributes.
Any ideas?
The MQTT messages have 2 attributes describing this, “consumption” and “energy”.
The configuration (from discovery) for this sensor has:
availability:
- topic: zigbee2mqtt/bridge/state
device:
identifiers:
- zigbee2mqtt_0x00158d000216768a
manufacturer: Xiaomi
model: Mi power plug ZigBee (ZNCZ02LM)
name: '0x00158d000216768a'
sw_version: Zigbee2MQTT 1.21.0
device_class: energy
json_attributes_topic: zigbee2mqtt/0x00158d000216768a
last_reset_topic: zigbee2mqtt/0x00158d000216768a
last_reset_value_template: '1970-01-01T00:00:00+00:00'
name: 0x00158d000216768a energy
state_class: measurement
state_topic: zigbee2mqtt/0x00158d000216768a
unique_id: 0x00158d000216768a_energy_zigbee2mqtt
unit_of_measurement: kWh
value_template: '{{ value_json.energy }}'
platform: mqtt
The incoming MQTT message looks like:
Message 11 received on zigbee2mqtt/0x00158d000216768a at 8:53 AM:
{
"consumption": 2.58,
"energy": 2.58,
"linkquality": 57,
"power": 156.28,
"power_outage_memory": true,
"state": "ON",
"temperature": 24
}
eb3nezer
(Eb3nezer)
August 25, 2021, 3:37am
2
OK I think this is related to the handling of last_reset_topic and last_reset_value_template in some way. MQTT Sensor : how to define last_reset_value_template
It doesn’t report energy usage as far as I know.
I’m using it with ZHA and I get only on/off switch and current power. Don’t know if there’s any workaround to calculate consumption…
francisp
(Francis)
September 2, 2021, 8:07am
4
use the rieman integration with the left method.
Wow. That was pretty simple
It seems to be working. Thank you very much.
For everyone else who would like to calculate energy consumption based on current power usage, this is all it takes:
- platform: integration
source: sensor.load_power_lumi_158d000268dd8d
name: energy_spent
unit_prefix: k
round: 2
method: left
eb3nezer
(Eb3nezer)
September 2, 2021, 10:57pm
6
This model does report it. You can see the value in the MQTT message (the “power” and “consumption” fields), and in the attributes for the sensor, but the actual sensor value is undefined.
Actually I’m using it through Xiaomi Gateway integration, and it’s not reporting it that way…
Hedda
(Hedda)
September 8, 2021, 1:15pm
8
ZHA and Zigbee2MQTT doesn’t work the same when it comes to reading sensors and handling device quirks, so if a device works in Zigbee2MQTT but not in ZHA or vice versa does not really say that much.
FYI, when specifially talking about the ZHA integration component for Home Assistant there are loads of related discussions/explainations here about this and the current ZHA limitation of 1 sensor per cluster:
opened 03:25PM - 26 Dec 20 UTC
closed 12:10PM - 05 Oct 21 UTC
integration: zha
<!-- READ THIS FIRST:
- If you need additional help with this template, pleas… e refer to https://www.home-assistant.io/help/reporting_issues/
- Make sure you are running the latest version of Home Assistant before reporting an issue: https://github.com/home-assistant/core/releases
- Do not report issues for integrations if you are using custom components or integrations.
- Provide as many details as possible. Paste logs, configuration samples and code into the backticks.
DO NOT DELETE ANY TEXT from this template! Otherwise, your issue may be closed without comment.
-->
## The problem
In ZHA smart plugs are not showing value for used energy counter. I have tested 4 different types of plugs and all of them show:
smartenergy_metering - 'unknown'
When I use Manage Clusters I can see that all those plugs report used energy value in cluster 0x702, attrid 0 as current_summ_delivered
So it seems that instead of smartenergy_metering ( I don't know from which cluster it comes in existing integration)
should be used cluster: **Metering (Endpoint id: 1, Id: 0x0702, Type: in)**, attribute: **current_summ_delivered (id: 0x0000)**
I have checked with:
BlitzWolf BW-SHP13, Innr SP 120, Schwaiger ZHS15, Lonsonho 16A Energy Monitoring Plug and all of them report used energy counter in cluster:0x702, attrid:0
Same problem reported also by other users:
(https://github.com/home-assistant/core/issues/34090#issuecomment-745948613)
## Environment
<!--
Provide details about the versions you are using, which helps us to reproduce
and find the issue quicker. Version information is found in the
Home Assistant frontend: Configuration -> Info.
-->
- Home Assistant Core release with the issue: 2020.12.1
- Last working Home Assistant Core release (if known): N/A
- Operating environment (OS/Container/Supervised/Core): Home Assistant OS 5.9 on RPi4
- Integration causing this issue: ZHA
- Link to integration documentation on our website: [ZHA](https://www.home-assistant.io/integrations/zha/)
## Problem-relevant `configuration.yaml`
N/A
```yaml
```
## Traceback/Error logs
N/A
```txt
```
## Additional information
![Lovlace](https://user-images.githubusercontent.com/12792066/103154061-d68e0000-479d-11eb-945b-b6568c10496e.png)
BlitzWolf
![BlitzWolf](https://user-images.githubusercontent.com/12792066/103154111-1ce35f00-479e-11eb-819f-5f5f1a49c60e.png)
Innr120
![Innr120](https://user-images.githubusercontent.com/12792066/103154140-53b97500-479e-11eb-88ac-ca2564ce2e75.png)
and here
opened 12:12PM - 12 Apr 20 UTC
closed 02:42AM - 20 Jul 20 UTC
integration: zha
stale
<!-- READ THIS FIRST:
- If you need additional help with this template, pleas… e refer to https://www.home-assistant.io/help/reporting_issues/
- Make sure you are running the latest version of Home Assistant before reporting an issue: https://github.com/home-assistant/core/releases
- Do not report issues for integrations if you are using custom components or integrations.
- Provide as many details as possible. Paste logs, configuration samples and code into the backticks.
DO NOT DELETE ANY TEXT from this template! Otherwise, your issue may be closed without comment.
-->
## I have Innr smart plug SP120 which can measure power consumption in kwh, but in HA integration only electrical_measurement and on_off are working. Smartenergy_metering shows 'unknown'
<!--
-->
## Home Assistant release with the issue:
0.108.3
Last working Home Assistant release (if known):
n/a
Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io (32bit)
Raspberry PI 4 (4 GB version)
Aeotec stick Zigbee adapter
Integration:
https://www.home-assistant.io/integrations/zha/-->
<!--
## Problem-relevant `configuration.yaml`
<!--
n/a
-->
```yaml
```
## Traceback/Error logs
<!--
If you come across any trace or error logs, please provide them.
-->
```txt
```
## Additional information
I have also Schwaiger ZHS15 plug with same behavior - no power consumption reading
![screen](https://user-images.githubusercontent.com/12792066/79068457-a239e880-7ccf-11ea-983e-7350ee8fea0d.png)
There is also an issue posted to the HA core about ZHA energy consumption sensors not showing up:
opened 03:43AM - 15 Aug 21 UTC
closed 04:35PM - 29 Sep 21 UTC
integration: zha
energy
### The problem
I've got some Sercomm ESW01 switches / power meters, and they a… ren't appearing in the sensor list in the new energy consumption tab.
The smartenergy_metering entity captures a nice graph of the power usage, so it seems like that side of the integration is working for this switch.
Any pointers on how to hook them up would be appreciated.
### What is version of Home Assistant Core has the issue?
core-2021.8.6
### What was the last working version of Home Assistant Core?
_No response_
### What type of installation are you running?
Home Assistant Supervised
### Integration causing the issue
ZHA
### Link to integration documentation on our website
_No response_
### Example YAML snippet
_No response_
### Anything in the logs that might be useful for us?
_No response_
### Additional information
_No response_
All those applies to most Zigbee power plugs or other Zigbee devices with integrated energy meters:
Tuya TS0121 → [Device Support Request] BlitzWolf BW-SHP13 smart plug (aka Tuya TS0121) · Issue #605 · zigpy/zha-device-handlers · GitHub
BlitzWolf BW-SHP13 (OEM version of Tuya TS0121) → [Device Support Request] BlitzWolf BW-SHP13 smart plug (aka Tuya TS0121) · Issue #605 · zigpy/zha-device-handlers · GitHub
Develco Norwegian HAN Adapter (Develco EMIZB-132) → Add support for Develco Products A/S EMIZB-132 Norwegian HAN adapter · Issue #267 · zigpy/zha-device-handlers · GitHub
Develco Prosumer Meter (Develco SMMZB-310101)
Develco Smart Plug Mini (Develco Frient SPLZB-131) → [Device Support Request] Develco Frient SPLZB-131 Smart Plug Mini · Issue #857 · zigpy/zha-device-handlers · GitHub
Immax Plug-230V-ZB3.0 Smart Plug
Innr SP 120 (a.k.a. Innr SP120) → No power consumption readings from Innr smart plug SP120? · Issue #34090 · home-assistant/core · GitHub
Lonsonho 16A Energy Monitoring Plug (OEM version of Tuya TS0121) → [Device Support Request] BlitzWolf BW-SHP13 smart plug (aka Tuya TS0121) · Issue #605 · zigpy/zha-device-handlers · GitHub
SmartThings Smart Plug (UK)
Schwaiger ZHS15 → ZHA plugs - smartenergy_metering > wrong cluster · Issue #44539 · home-assistant/core · GitHub
Rehentele 16A Energy Monitoring Plug (OEM version of Tuya TS0121) → [Device Support Request] BlitzWolf BW-SHP13 smart plug (aka Tuya TS0121) · Issue #605 · zigpy/zha-device-handlers · GitHub
Aqara LUMI lumi.plug → ZHA plugs - smartenergy_metering > wrong cluster #44539
and a possible workaround being working on here
home-assistant:dev
← stattin42:use-current_summ_delivered
opened 05:24PM - 11 May 21 UTC
Use the 'current_summ_delivered' attrib (id: 0x0000) on the 'smartenergy_meterin… g' cluster (id: 0x0702); don't use the 'instantaneous_demand' attr (id: 0x0400).
<!--
You are amazing! Thanks for contributing to our project!
Please, DO NOT DELETE ANY TEXT from this template! (unless instructed).
-->
## Breaking change
ZHA Smart energy channel no longer reports attribute 'instantaneous_demand', but
attribute 'current_summ_delivered'.
## Proposed change
As reported in issue #44539 "ZHA plugs - smartenergy_metering > wrong cluster"
many (most?) energy metering capable devices support reporting energy
consumption with attribute 'current_summ_delivered'; not with attribute
'instantaneous_demand'.
Furthermore, Page 215/16 of the zigbee smart energy profile says that cluster
0x702 attribute 0x0 is "CurrentSummationDelivered represents the most recent
summed value of Energy, Gas, or Water delivered and consumed in the premises.
CurrentSummationDelivered is mandatory and must be provided as part of the
minimum data set to be provided by the metering device"
## Type of change
<!--
What type of change does your PR introduce to Home Assistant?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [ ] New feature (which adds functionality to an existing integration)
- [x] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: fixes #44539
- This PR is related to issue: #44539
- Link to documentation pull request:
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [x] The code change is tested and works locally.
- [ ] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] The code has been formatted using Black (`black --fast homeassistant tests`)
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.
Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.
Updated by running `python3 -m script.gen_requirements_all`.
- [ ] Untested files have been added to `.coveragerc`.
The integration reached or maintains the following [Integration Quality Scale][quality-scale]:
<!--
The Integration Quality Scale scores an integration on the code quality
and user experience. Each level of the quality scale consists of a list
of requirements. We highly recommend getting your integration scored!
-->
- [ ] No score or internal
- [ ] 🥈 Silver
- [ ] 🥇 Gold
- [ ] 🏆 Platinum
<!--
This project is very active and we have a high turnover of pull requests.
Unfortunately, the number of incoming pull requests is higher than what our
reviewers can review and merge so there is a long backlog of pull requests
waiting for review. You can help here!
By reviewing another pull request, you will help raise the code quality of
that pull request and the final review will be faster. This way the general
pace of pull request reviews will go up and your wait time will go down.
When picking a pull request to review, try to choose one that hasn't yet
been reviewed.
Thanks for helping out!
-->
To help with the load of incoming pull requests:
- [ ] I have reviewed two other [open pull requests][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone
<!--
Thank you for contributing <3
Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/en/development_checklist.html
[manifest-docs]: https://developers.home-assistant.io/docs/en/creating_integration_manifest.html
[quality-scale]: https://developers.home-assistant.io/docs/en/next/integration_quality_scale_index.html
[docs-repository]: https://github.com/home-assistant/home-assistant.io
eb3nezer
(Eb3nezer)
September 13, 2021, 4:14am
9
This discussion is specifically about these devices with zigbee2mqtt. The issue is that the energy usage is listed in the MQTT message correctly, but it doesn’t show in the UI.
eb3nezer
(Eb3nezer)
September 13, 2021, 4:16am
10
Ah I just upgraded Home Assistant to 2021.9.6 and the energy usage is being reported correctly now.