Closed gromgsxr closed 2 months ago
so i managed to cobble together a quirk that seems too work values reported by the voltage, current and wattage seem feasible.
` import logging import zigpy.types as t
import copy
from typing import Dict from zigpy.profiles import zha from zigpy.quirks import CustomCluster, CustomDevice from zigpy.zcl.foundation import ZCLAttributeDef, ZCLCommandDef
from zhaquirks import Bus, LocalDataCluster
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
OnOff,
Ota,
Scenes,
Time,
AnalogInput,
)
from zigpy.zcl.clusters.lightlink import LightLink from zigpy.zcl.clusters.smartenergy import Metering from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zhaquirks.const import ( DEVICE_TYPE, ENDPOINTS, INPUT_CLUSTERS, MODELS_INFO, OUTPUT_CLUSTERS, PROFILE_ID, SKIP_CONFIGURATION, )
CURRENT_REPORTED = 0x7004 VOLTAGE_REPORTED = 0x7005 POWER_REPORTED = 0x7006
class ZBElectricalMeasurement(LocalDataCluster):
cluster_id = 0xFC11
name = "measure"
attributes = {
0x7004: ("CURRENT_REPORTED", t.CharacterString, True),
0x7005: ("VOLTAGE_REPORTED", t.CharacterString, True),
0x7006: ("POWER_REPORTED", t.CharacterString, True),
}
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == CURRENT_REPORTED:
self.endpoint.electrical_measurement.current_reported(value)
elif attrid == POWER_REPORTED:
self.endpoint.electrical_measurement.power_reported(value)
elif attrid == VOLTAGE_REPORTED:
self.endpoint.electrical_measurement.voltage_reported(value)
class ElectricalMeasurementCluster(LocalDataCluster, ElectricalMeasurement): """Custom class for power, voltage and current measurement."""
POWER_ID = 0x050B
VOLTAGE_ID = 0x0505
CURRENT_ID = 0x0508
AC_VOLTAGE_MULTIPLIER = 0x0600
AC_VOLTAGE_DIVISOR = 0x0601
AC_CURRENT_MULTIPLIER = 0x0602
AC_CURRENT_DIVISOR = 0x0603
AC_POWER_MULTIPLIER = 0x0604
AC_POWER_DIVISOR = 0x0605
_CONSTANT_ATTRIBUTES = {
AC_VOLTAGE_MULTIPLIER: 1,
AC_VOLTAGE_DIVISOR: 1000,
AC_CURRENT_MULTIPLIER: 1,
AC_CURRENT_DIVISOR: 1000,
AC_POWER_MULTIPLIER: 1,
AC_POWER_DIVISOR: 1000,
}
def voltage_reported(self, value):
"""Voltage reported."""
self._update_attribute(self.VOLTAGE_ID, value)
def power_reported(self, value):
"""Power reported."""
self._update_attribute(self.POWER_ID, value)
def current_reported(self, value):
"""Ampers reported."""
self._update_attribute(self.CURRENT_ID, value)
class PlugAC(CustomDevice): """test.""" signature = { MODELS_INFO: [("eWeLink" ,"CK-BL702-SWP-01(7020)",)], ENDPOINTS: {
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 4096, 64529, 64599]
# output_clusters=[10, 25, 2820]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.MAIN_POWER_OUTLET,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LightLink.cluster_id,
ZBElectricalMeasurement.cluster_id,
0xfc57,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, ElectricalMeasurement.cluster_id, Time.cluster_id],
},
242: {
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# input_clusters=[]
# output_clusters=[]
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LightLink.cluster_id,
ElectricalMeasurementCluster,
ZBElectricalMeasurement,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
242: {
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# input_clusters=[]
# output_clusters=[33]
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
`
Hi,
could you please add the "default behaviour after power Out" (Don't konw if this is called correct ...) Before using the quirk i could define this (On, Off, Last State), but had no power measurement- No, with the quirky i can't define this anymore, but because i have the ability for power measurement now this is much better WITH the quirk 😉👍
And because i'm relatively new to HA, I had a real hard time to get the quirk working because of the formatting problems above 😅
Regards & Kudos Alex
I will try and see what I can do. It's my first attempt at creating a quirk
That would really be great, i'd appreciate this ! 🤘
As is said, i'm a newbee, but i assume it could be THIS:
Hmm,
but i can't write an attribute "Last" or "LastState" here (just ON of OFF) ... maybe i'm completely wrong 😁 Before the quirk i had three options: On, Off, LastState
you can write the attribute with
start_up_on_off (id: 0x4003) 0 = StartUpOnOff.Off 1 = StartUpOnOff.On 2 = StartUpOnOff.Toggle 255 = StartUpOnOff.PreviousValue
i found if i write an attribute to the plug and restart h/a the switch then shows for me
Thanks, so i can at least manually set or check it 😉👍
Just wanted to say thanks very much for pulling together this quirk @gromgsxr - it's great to be able to get the power output from these switches now.
Not sure why github insists on messing up the formatting of the quirk, when pasted in here, but for future generations here's a version in a file, with the correct indentation, etc...
I've installed the quirk but all the sensors are reporting as "Unknown". Any ideas?
I've installed the quirk but all the sensors are reporting as "Unknown". Any ideas?
What version of ha? 2023.07.03 works for me earlier versions didn't.
I've installed the quirk but all the sensors are reporting as "Unknown". Any ideas?
What version of ha? 2023.07.03 works for me earlier versions didn't.
2024.01
I've installed the quirk but all the sensors are reporting as "Unknown". Any ideas?
What version of ha? 2023.07.03 works for me earlier versions didn't.
2024.01
Oh not tried after 2023.07.03. what happens if you read the attributes on active power, rms voltage and RMS current
Oh not tried after 2023.07.03. what happens if you read the attributes on active power, rms voltage and RMS current
Doing nothing it started reporting some values this morning, although the update frequency seems very slow. After plugging it a light it's still reading 0.0W
If I manually read the active_power attribute I still get 0.
The voltage reading changed once in the last 12 hours...
i will try and update at some point to try
AC_VOLTAGE_MULTIPLIER = 0x0600 AC_VOLTAGE_DIVISOR = 0x0601 AC_CURRENT_MULTIPLIER = 0x0602 AC_CURRENT_DIVISOR = 0x0603 AC_POWER_MULTIPLIER = 0x0604 AC_POWER_DIVISOR = 0x0605
if you try reading those attributes i wonder if its not pulling he multiply across
All the multipliers are 1 and all the divisors are 1000.
I left a light plugged in for a while and it eventually started reading 4W. It appears the problem is very slow updates (several hours).
I had a go on the latest and the updates almost instantly
Based on this comment about when ZHA sets the refresh times, I tried reconfiguring the device and it appears to be updating quickly now.
Many thanks for your help!
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.
Problem description
shows as manufacture eWeLink CK-BL702-SWP-01(7020) available from amazon ebay ect https://www.ebay.co.uk/itm/314855773062
appears to be working in z2mqtt see here for info on the clusters https://github.com/Koenkk/zigbee2mqtt/issues/19334#issuecomment-1784120749
Solution description
please add this device
Screenshots/Video
Screenshots/Video
[Paste/upload your media here]Device signature
Device signature
```json { "node_descriptor": "NodeDescriptor(logical_type=Diagnostic information
Diagnostic information
```json [Paste the diagnostic information here] ```Logs
Logs
```python [Paste the logs here] ```Custom quirk
Custom quirk
```python [Paste your custom quirk here] ```Additional information
https://github.com/Koenkk/zigbee2mqtt/issues/19334#issuecomment-1784120749