Open rrozema opened 12 months ago
This might really be a ZHA issue. If the measurement type is kWh (0), we do not use the summation_formatting
attribute for some reason. We only use the multiplier and divider attributes in that case: zha/sensor.py#L522-L531
@Adminiuga If you're around, do you have any idea why you added that check in the original PR? I'm guessing that it's unexpected the formatter is still needed for kWh? Or did some devices perhaps provide something wrong?
This can be worked around with a quirk. I'm not sure if that's a good idea though, as the plug seems to provide summation_formatting
correctly: 00101010
=> 2 digits to right of decimal point, 5 digits to left of decimal point.
Changing the ZHA code could break some other devices though. Especially the ones we have quirks for which set the multiplier / dividers right now.
.. but apparently we already use quirks for other Innr plugs though: https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/innr/innr_sp120_plug.py I guess I'll get one ready for this plug too for now.
@rrozema Please test this file as a custom quirk. The comment above is still relevant for the isuse though.
I think the US version of this plug the 234 may have the same issue. I have my LumenPNP on one and it's like a 3d printer without heaters and some small vacuum pumps when running. I don't think it's put out 50 kWh during it's lifetime.
Looks like the current quirk is just changing the voltage divisor: https://github.com/zigpy/zha-device-handlers/blob/d30dac2f3ffe99cc303690afb91513cb8836acc4/zhaquirks/innr/innr_sp234_plug.py#L34 I
If I query the Summation_Formatting attribute I get 4 (0x2A) as well.
I can try and add the fix you added for the 240 in the quirk for the 234 to see if the work around works as well.
{
"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.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4454, 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": "0x0104",
"device_type": "0x010a",
"input_clusters": [
"0x0000",
"0x0003",
"0x0004",
"0x0005",
"0x0006",
"0x0702",
"0x0b04",
"0x0b05",
"0x1000",
"0xfc57",
"0xfc82"
],
"output_clusters": [
"0x0003",
"0x000a",
"0x0019"
]
},
"242": {
"profile_id": "0xa1e0",
"device_type": "0x0061",
"input_clusters": [],
"output_clusters": [
"0x0021"
]
}
},
"manufacturer": "innr",
"model": "SP 234",
"class": "zhaquirks.innr.innr_sp234_plug.SP234"
}
@tube0013 I've pushed some changes to:
To install the SP234 quirk easily as a custom quirk, use this:
Let me know if all your plug measurements are correct then.
Thanks got it running now.. and reset the summation delivered to get a fresh summation with the updated quirk.
Z2M also adds it for your plug (code here). They are doing some other things we're not doing too. Can you check if the current also needs to be divided by 1000 for your plug, @tube0013?
Actually, can you upload a diagnostics file for your plug? I'm interested in what ac_current_divisor
returns on your plug.
Amperage seems okay to me:
ac_current_divisor is 1000:
zha-e29ceebf7c284fe6a18d61622537f595-innr SP 234-bd4503f7c2ae9e99b0befd345d61ad65.json.txt
I confirm the quirk fixes my kWh sensor.
Good to see the issue is resolved. Just for info: the SP 234 US plug had an issue in the first firmware with an incorrect divider that was fixed in a firmware update. That update also fixes a number of other issues and is available on https://github.com/Koenkk/zigbee-OTA/tree/master/images/Innr.
SP 234 quirk changes have been working well.
Interesting I missed that fact that innr had fw updates posted. so I guess the quick need to be adjusted for that... I'm pulling it down and will update. @TheJulianJES should we move the SP 234 to a new issue sorry fop combining it with the SP 240!
Ah, the info with the older firmware versions is interesting. It explains why Z2M still sets those dividers manually.
https://github.com/zigpy/zha-device-handlers/pull/2782 will be included in 2023.12.0b0 and should fix the issue even for older firmware versions of the SP 234, as it always sets the EM current and EM power divisors for the SP 234 now.
The total sum delivered (Metering) fix is also included for all Innr plugs (setting divisor, as ZHA ignores summation_formatting
at the moment).
So, the behavior should be fixed in all upcoming 2023.12.x versions. If there any remaining issues in 2023.12.x (beta should be out in about one to two hours or so), please open a new issue for other plugs and tag me.
My SP 234 was already on latest fw, so everything seems working with the modified one as I have been testing over last day or so.
This is also an issue for the SP 242
This is also an issue for the SP 242
I too am having the same issue with SP 242, FW 1.4.3.
I can't seem to even find this device on Innr's website anymore despite only recently purchasing them, but am exhibiting the same issue with the summation being much higher than it should be, assuming it is the same problem.
The new plugs SP 240, SP 242, and SP 244 all use the same firmware code base so the same quirk can be applied. Just for completeness: it is not a bug of the smart plugs; the plugs correctly provide the SummationFormatting attribute 0x0303 with value 0x2A (meaning 2 digits to the right 5 to the left of the decimal point), which is the only mandatory attribute for formatting the CurrentSummationDelivered attribute. The Multiplier and Divisor attributes 0x0301 and 0x0302 are optional.
The new plugs SP 240, SP 242, and SP 244 all use the same firmware code base so the same quirk can be applied. Just for completeness: it is not a bug of the smart plugs; the plugs correctly provide the SummationFormatting attribute 0x0303 with value 0x2A (meaning 2 digits to the right 5 to the left of the decimal point), which is the only mandatory attribute for formatting the CurrentSummationDelivered attribute. The Multiplier and Divisor attributes 0x0301 and 0x0302 are optional.
Hrm we should look at the HA side of this to make sure we are doing things correctly then…
Hrm we should look at the HA side of this to make sure we are doing things correctly then…
Yeah, I think there's an issue with ZHA at the moment, see this comment: https://github.com/zigpy/zha-device-handlers/issues/2781#issuecomment-1830832448 (formatter isn't used for kWh) Even if we fix ZHA code, we risk breaking multiple devices with existing quirks. Some devices report it correctly and others not, so we don't know which quirks should stay and which should be removed (without knowing the attributes reported by the device).
Sorry to add to an old bug but it seems the newer innr 242 has the same bug summation is 100x expected
Firmware reported by zha is 0x14033682
Please let me know if this should it's own ticket
EXA
Sorry to add to an old bug but it seems the newer innr 242 has the same bug summation is 100x expected Firmware reported by zha is 0x14033682 Please let me know if this should it's own ticket EXA
As described before in this thread, this is not a bug of the SP 242, it is a bug of ZHA not using the SummationFormatting attribute of the Metering cluster to determine the right scale of the CurrentSummationDelivered attribute.
Loading the SP 240 .py for my SP 242 worked perfectly. Thanks for providing this.
Having this on SP 244. Can we get the quirk to match those newer models too? I assume it's just not matching because the model is different
Bug description
Upon inclusion of the INNR SP 240 in ZHA, among others a "Summation delivered" sensor gets created. The value returned for this sensor is however 100x larger than expected: I ran a filament dryer for 5 hours of the SP 240 and the device measured 17kWh instead of the expected 0,17 kWh as measured using a Fibaro wall plug V2.
When I requested help from INNR support they responded that ZHA probably has incorrectly interpreted the configuration their device returned. My translation of their response: "An attribute "SummationFormatting" on the Metering cluster has the value 0x2A, which designates: 2 digits to the right of the decimal point, 5 digits to the left of the decimal point, don't suppress leading zeroes". Looks like his system (red: my ZHA integration in HA)) doesn't interpret or incorrectly interprets the value of the "SummationFormatting" attribute."
The full mail text I got from INNR support (in Dutch, sorry):
@TheJulianJES requested me to tag him in here.
Steps to reproduce
Include the INNR SP 240 into the network using ZHA, plug in a filament dryer of 145W, Run the dryer for 5 hours, Watt history graph shows a peak at the beginning, then dropping to roughly 30 Watt. Multiply the measured Watt value with the number of hours: 5 * roughly 30 Watt = roughly 170 Wh, or 0,17 kWh. See how the actual sensor in ZHA however shows 17kWh.
Expected behavior
The summation delivered sensor should have shown a usage of 0,170 kWh
Screenshots/Video
Screenshots/Video
![image](https://github.com/zigpy/zha-device-handlers/assets/1747982/bdca1488-df6e-4c55-91be-b64dbf4e8422) ![image](https://github.com/zigpy/zha-device-handlers/assets/1747982/93985e4a-2c74-4af4-825a-562a472833da) ![image](https://github.com/zigpy/zha-device-handlers/assets/1747982/02eda6be-7639-49e8-9c98-b55792fab7ef)Device signature
Device signature
```json { "node_descriptor": "NodeDescriptor(logical_type=Diagnostic information
Diagnostic information
```json { "home_assistant": { "installation_type": "Home Assistant OS", "version": "2023.11.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.11.6", "docker": true, "arch": "x86_64", "timezone": "Europe/Amsterdam", "os_name": "Linux", "os_version": "6.1.59", "supervisor": "2023.11.3", "host_os": "Home Assistant OS 11.1", "docker_version": "24.0.6", "chassis": "embedded", "run_as_root": true }, "custom_components": { "battery_consumption": { "version": "1.0.4", "requirements": [] }, "spook": { "version": "1.3.2", "requirements": [] }, "chime_tts": { "version": "v0.8.0", "requirements": [ "pydub" ] }, "battery_sim": { "version": "1.0", "requirements": [] }, "google_fit": { "version": "v2.1.2", "requirements": [ "oauth2client==4.1.3", "google-api-python-client==2.82.0" ] }, "hacs": { "version": "1.33.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "energy_meter": { "version": "1.0.1", "requirements": [] }, "adaptive_lighting": { "version": "1.19.0", "requirements": [ "ulid-transform" ] }, "smart_irrigation": { "version": "0.0.81", "requirements": [] }, "hass_agent": { "version": "2022.11.9", "requirements": [] }, "var": { "version": "0.15.0", "requirements": [] }, "presence_simulation": { "version": "3.2", "requirements": [] }, "grad_vol": { "version": "1.0.0", "requirements": [] }, "better_thermostat": { "version": "1.4.0", "requirements": [] }, "xiaomi_cloud_map_extractor": { "version": "v2.2.0", "requirements": [ "pillow", "pybase64", "python-miio", "requests", "pycryptodome" ] }, "powercalc": { "version": "v1.9.7", "requirements": [ "numpy>=1.21.1" ] }, "spook_inverse": { "version": "1.3.2", "requirements": [] } }, "integration_manifest": { "domain": "zha", "name": "Zigbee Home Automation", "after_dependencies": [ "onboarding", "usb" ], "codeowners": [ "@dmulcahey", "@adminiuga", "@puddly" ], "config_flow": true, "dependencies": [ "file_upload" ], "documentation": "https://www.home-assistant.io/integrations/zha", "iot_class": "local_polling", "loggers": [ "aiosqlite", "bellows", "crccheck", "pure_pcapy3", "zhaquirks", "zigpy", "zigpy_deconz", "zigpy_xbee", "zigpy_zigate", "zigpy_znp", "universal_silabs_flasher" ], "requirements": [ "bellows==0.36.8", "pyserial==3.5", "pyserial-asyncio==0.6", "zha-quirks==0.0.106", "zigpy-deconz==0.21.1", "zigpy==0.59.0", "zigpy-xbee==0.19.0", "zigpy-zigate==0.11.0", "zigpy-znp==0.11.6", "universal-silabs-flasher==0.0.14", "pyserial-asyncio-fast==0.11" ], "usb": [ { "vid": "10C4", "pid": "EA60", "description": "*2652*", "known_devices": [ "slae.sh cc2652rb stick" ] }, { "vid": "1A86", "pid": "55D4", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus v2" ] }, { "vid": "10C4", "pid": "EA60", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus" ] }, { "vid": "10C4", "pid": "EA60", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*zigstar*", "known_devices": [ "ZigStar Coordinators" ] }, { "vid": "1CF1", "pid": "0030", "description": "*conbee*", "known_devices": [ "Conbee II" ] }, { "vid": "10C4", "pid": "8A2A", "description": "*zigbee*", "known_devices": [ "Nortek HUSBZB-1" ] }, { "vid": "0403", "pid": "6015", "description": "*zigate*", "known_devices": [ "ZiGate+" ] }, { "vid": "10C4", "pid": "EA60", "description": "*zigate*", "known_devices": [ "ZiGate" ] }, { "vid": "10C4", "pid": "8B34", "description": "*bv 2010/10*", "known_devices": [ "Bitron Video AV2010/10" ] } ], "zeroconf": [ { "type": "_esphomelib._tcp.local.", "name": "tube*" }, { "type": "_zigate-zigbee-gateway._tcp.local.", "name": "*zigate*" }, { "type": "_zigstar_gw._tcp.local.", "name": "*zigstar*" }, { "type": "_uzg-01._tcp.local.", "name": "uzg-01*" }, { "type": "_slzb-06._tcp.local.", "name": "slzb-06*" } ], "is_built_in": true }, "data": { "ieee": "**REDACTED**", "nwk": 12957, "manufacturer": "innr", "model": "SP 240", "name": "innr SP 240", "quirk_applied": false, "quirk_class": "zigpy.device.Device", "quirk_id": null, "manufacturer_code": 4454, "power_source": "Mains", "lqi": 123, "rssi": null, "last_seen": "2023-11-26T21:32:06", "available": true, "device_type": "Router", "signature": { "node_descriptor": "NodeDescriptor(logical_type=Logs
Logs
```python [Paste the logs here] ```Additional information
No response