-
Notifications
You must be signed in to change notification settings - Fork 711
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
Add Owon PC321 support for custom attributes #2602
base: dev
Are you sure you want to change the base?
Conversation
Use black playground for fixing the most formatting problems the test is complaining of https://black.vercel.app/ |
Thanks, I made it but I still have errors. I will check that this evening. |
Most is fixed and the rest is isort and other.
Second is Isort:
Delete the lines wit
And its all and shall being easy fixed by "hand". |
Now all is fixed you can do then the Py 3.12 test is not OK and its waiting for the release of it. Great work done !!! |
That's great, thanks again ! Regarding py3.12, do I have to make some modifications? |
Its nothing you can do the maintainer must getting the last working test suit and fixing all not OK things. |
Super, thanks again for your help |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #2602 +/- ##
==========================================
+ Coverage 86.60% 86.62% +0.02%
==========================================
Files 278 280 +2
Lines 8540 8555 +15
==========================================
+ Hits 7396 7411 +15
Misses 1144 1144 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
First, the file name needs to be changed to not contain spaces. You can use underscores / look at other quirk file names.
Second, the owon
folder needs to have an __init__.py
file (with a line like """Owon quirks."""
and an empty line after that).
That's done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some more comments.
Only 2 small formatting:
First need one blank line after the device class block and the signature. Also then you is doing the edit move the comment Good work done !!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made all changes you submitted.
Thanks for your support !!!
There are already attributes in the "ElectricalMeasurement" class for most of these measurements. Would it not be better to use those instead of extending the attributes of the Metering class? Like this redundant code will need to be added to the ZHA integration. (I like the naming L1, L2, L3 you used more than the naming of the attributes in the ElectricalMeasurement class (a,b,c) but that is probably just a difference because of geolocation) |
Any update on this ? |
HI, guys here is my device info: endpoints": {
"1": {
"profile_id": "0x0104",
"device_type": "0x000d",
"input_clusters": [
"0x0000",
"0x0003",
"0x0702"
],
"output_clusters": [
"0x0003"
]
}
},
"manufacturer": "OWON Technology Inc.",
"model": "PC321",
"class": "zigpy.device.Device"
} PC321 logo while ZHA finding new device: New device 0x7f58 (3c:6a:2c:ff:fe:d0:db:75) joined the network
[0x7f58] Scheduling initialization
Tries remaining: 5
[0x7f58] Requesting 'Node Descriptor'
[0x7f58] Extending timeout for 0xbb request
Received a packet: ZigbeePacket(timestamp=datetime.datetime(2023, 12, 23, 12, 17, 10, 27521, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x7F58), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.Broadcast: 15>, address=<BroadcastAddress.ALL_ROUTERS_AND_COORDINATOR: 65532>), dst_ep=0, source_route=None, extended_timeout=False, tsn=105, profile_id=0, cluster_id=19, data=Serialized[b'\x85X\x7fu\xdb\xd0\xfe\xff,j<\x8e'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=192, rssi=-52)
Device 0x7f58 (3c:6a:2c:ff:fe:d0:db:75) joined the network
[0x7f58] Scheduling initialization
[0x7f58] Canceling old initialize call
Received frame on uninitialized device <Device model=None manuf=None nwk=0x7F58 ieee=3c:6a:2c:ff:fe:d0:db:75 is_initialized=False> from ep 0 to ep 0, cluster 19: Serialized[b'\x85X\x7fu\xdb\xd0\xfe\xff,j<\x8e']
[0x7f58:zdo] ZDO request ZDOCmd.Device_annce: [0x7F58, 3c:6a:2c:ff:fe:d0:db:75, 142]
Tries remaining: 5
[0x7f58] Requesting 'Node Descriptor'
[0x7f58] Extending timeout for 0xbd request
Received a packet: ZigbeePacket(timestamp=datetime.datetime(2023, 12, 23, 12, 17, 10, 235124, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x7F58), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=0, source_route=None, extended_timeout=False, tsn=106, profile_id=0, cluster_id=32770, data=Serialized[b'\xbd\x00X\x7f\x01@\x8e<\x11RR\x00\x00,R\x00\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=192, rssi=-52)
Received frame on uninitialized device <Device model=None manuf=None nwk=0x7F58 ieee=3c:6a:2c:ff:fe:d0:db:75 is_initialized=False> from ep 0 to ep 0, cluster 32770: Serialized[b'\xbd\x00X\x7f\x01@\x8e<\x11RR\x00\x00,R\x00\x00']
[0x7f58] Got 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=4412, 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)
[0x7f58] Discovering endpoints
Received a packet: ZigbeePacket(timestamp=datetime.datetime(2023, 12, 23, 12, 17, 10, 355171, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x7F58), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=0, source_route=None, extended_timeout=False, tsn=107, profile_id=0, cluster_id=32773, data=Serialized[b'\xbf\x00X\x7f\x01\x01'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=192, rssi=-52)
Received frame on uninitialized device <Device model=None manuf=None nwk=0x7F58 ieee=3c:6a:2c:ff:fe:d0:db:75 is_initialized=False> from ep 0 to ep 0, cluster 32773: Serialized[b'\xbf\x00X\x7f\x01\x01']
[0x7f58] Discovered endpoints: [1]
[0x7f58] Initializing endpoints [<Endpoint id=1 in=[] out=[] status=<Status.NEW: 0>>]
[0x7f58:1] Discovering endpoint information
[0xE4A6](TS0601): Device seen - marking the device available and resetting counter
[0xE4A6](TS0601): Update device availability - device available: True - new availability: True - changed: False
Received a packet: ZigbeePacket(timestamp=datetime.datetime(2023, 12, 23, 12, 17, 10, 517270, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x7F58), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=0, source_route=None, extended_timeout=False, tsn=108, profile_id=0, cluster_id=32772, data=Serialized[b'\xc1\x00X\x7f\x10\x01\x04\x01\r\x00\x01\x03\x00\x00\x03\x00\x02\x07\x01\x03\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=188, rssi=-53)
Received frame on uninitialized device <Device model=None manuf=None nwk=0x7F58 ieee=3c:6a:2c:ff:fe:d0:db:75 is_initialized=False> from ep 0 to ep 0, cluster 32772: Serialized[b'\xc1\x00X\x7f\x10\x01\x04\x01\r\x00\x01\x03\x00\x00\x03\x00\x02\x07\x01\x03\x00']
[0x7f58:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=13, device_version=1, input_clusters=[0, 3, 1794], output_clusters=[3])
[0x7F58:1:0x0000] Sending request header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=False, direction=<Direction.Server_to_Client: 0>, disable_default_response=0, reserved=0, *is_cluster=False, *is_general=True), tsn=195, command_id=<GeneralCommand.Read_Attributes: 0>, *direction=<Direction.Server_to_Client: 0>)
[0x7F58:1:0x0000] Sending request: Read_Attributes(attribute_ids=[4, 5])
Received a packet: ZigbeePacket(timestamp=datetime.datetime(2023, 12, 23, 12, 17, 10, 690909, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x7F58), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=109, profile_id=260, cluster_id=0, data=Serialized[b'\x18\xc3\x01\x04\x00\x00B\x14OWON Technology Inc.\x05\x00\x00B\x05PC321'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=192, rssi=-52)
[0x7F58:1:0x0000] Received ZCL frame: b'\x18\xc3\x01\x04\x00\x00B\x14OWON Technology Inc.\x05\x00\x00B\x05PC321'
[0x7F58:1:0x0000] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=1, reserved=0, *is_cluster=False, *is_general=True), tsn=195, command_id=1, *direction=<Direction.Client_to_Server: 1>)
[0x7F58:1:0x0000] Decoded ZCL frame: Basic:Read_Attributes_rsp(status_records=[ReadAttributeRecord(attrid=0x0004, status=<Status.SUCCESS: 0>, value=TypeValue(type=CharacterString, value='OWON Technology Inc.')), ReadAttributeRecord(attrid=0x0005, status=<Status.SUCCESS: 0>, value=TypeValue(type=CharacterString, value='PC321'))])
[0x7f58] Read model 'PC321' and manufacturer 'OWON Technology Inc.' from <Endpoint id=1 in=[basic:0x0000, identify:0x0003, smartenergy_metering:0x0702] out=[identify:0x0003] status=<Status.ZDO_INIT: 1>>
[0x7f58] Discovered basic device information for <Device model='PC321' manuf='OWON Technology Inc.' nwk=0x7F58 ieee=3c:6a:2c:ff:fe:d0:db:75 is_initialized=True>
Device is initialized <Device model='PC321' manuf='OWON Technology Inc.' nwk=0x7F58 ieee=3c:6a:2c:ff:fe:d0:db:75 is_initialized=True>
Checking quirks for OWON Technology Inc. PC321 (3c:6a:2c:ff:fe:d0:db:75)
Considering <class 'zhaquirks.xbee.xbee_io.XBeeSensor'>
Fail because endpoint list mismatch: {232, 230} {1}
Considering <class 'zhaquirks.xbee.xbee3_io.XBee3Sensor'>
Fail because endpoint list mismatch: {232, 230} {1}
Considering <class 'zhaquirks.tuya.ts0201.MoesTemperatureHumidtySensorWithScreen'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.smartthings.tag_v4.SmartThingsTagV4'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.smartthings.multi.SmartthingsMultiPurposeSensor'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.netvox.z308e3ed.Z308E3ED'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.gledopto.soposhgu10.SoposhGU10'>
Fail because endpoint list mismatch: {11, 13} {1}
Creating cluster handler for cluster id: 0 class: <class 'homeassistant.components.zha.core.cluster_handlers.general.BasicClusterHandler'>
Creating cluster handler for cluster id: 3 class: <class 'homeassistant.components.zha.core.cluster_handlers.general.Identify'>
Creating cluster handler for cluster id: 1794 class: <class 'homeassistant.components.zha.core.cluster_handlers.smartenergy.Metering'>
Discovering entities for endpoint: 3c:6a:2c:ff:fe:d0:db:75-1
'button' component -> 'ZHAIdentifyButton' using ['identify']
'sensor' component -> 'RSSISensor' using ['basic']
'sensor' component -> 'LQISensor' using ['basic']
'sensor' component -> 'SmartEnergyMetering' using ['smartenergy_metering']
'sensor' component -> 'SmartEnergySummation' using ['smartenergy_metering']
device - 0x7F58:3c:6a:2c:ff:fe:d0:db:75 entering async_device_initialized - is_new_join: True
device - 0x7F58:3c:6a:2c:ff:fe:d0:db:75 has joined the ZHA zigbee network
[0x7F58](PC321): started configuration
[0x7F58:ZDO](PC321): 'async_configure' stage succeeded
Error handling '_save_attribute' event with (3c:6a:2c:ff:fe:d0:db:75, 1, 0, 4, 'OWON Technology Inc.', datetime.datetime(2023, 12, 23, 12, 17, 10, 748796, tzinfo=datetime.timezone.utc)) params: FOREIGN KEY constraint failed
[0x7F58:1:0x0000]: Configuring cluster attribute reporting
[0x7F58:1:0x0000]: finished cluster handler configuration
[0x7F58:1:0x0003]: Configuring cluster attribute reporting
[0x7F58:1:0x0003]: finished cluster handler configuration
[0x7F58:1:0x0702]: Performing cluster binding
Error handling '_save_attribute' event with (3c:6a:2c:ff:fe:d0:db:75, 1, 0, 5, 'PC321', datetime.datetime(2023, 12, 23, 12, 17, 10, 748874, tzinfo=datetime.timezone.utc)) params: FOREIGN KEY constraint failed
Received a packet: ZigbeePacket(timestamp=datetime.datetime(2023, 12, 23, 12, 17, 10, 926120, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x7F58), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=0, source_route=None, extended_timeout=False, tsn=110, profile_id=0, cluster_id=32801, data=Serialized[b'\xc5\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=192, rssi=-52)
[0x7F58:1:0x0702]: bound 'smartenergy_metering' cluster: Status.SUCCESS
[0x7F58:1:0x0702]: Configuring cluster attribute reporting
[0x7F58:1:0x0702] Sending request header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=False, direction=<Direction.Server_to_Client: 0>, disable_default_response=0, reserved=0, *is_cluster=False, *is_general=True), tsn=199, command_id=<GeneralCommand.Configure_Reporting: 6>, *direction=<Direction.Server_to_Client: 0>)
[0x7F58:1:0x0702] Sending request: Configure_Reporting(config_records=[AttributeReportingConfig(direction=0, attrid=0x0400, datatype=42, min_interval=5, max_interval=900, reportable_change=1), AttributeReportingConfig(direction=0, attrid=0x0000, datatype=37, min_interval=30, max_interval=900, reportable_change=1), AttributeReportingConfig(direction=0, attrid=0x0100, datatype=37, min_interval=30, max_interval=900, reportable_change=1)])
Received a packet: ZigbeePacket(timestamp=datetime.datetime(2023, 12, 23, 12, 17, 11, 72200, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x7F58), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=111, profile_id=260, cluster_id=1794, data=Serialized[b'\x08\xc7\x0b\x06\x82'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=192, rssi=-52)
[0x7F58:1:0x0702] Received ZCL frame: b'\x08\xc7\x0b\x06\x82'
[0x7F58:1:0x0702] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=0, reserved=0, *is_cluster=False, *is_general=True), tsn=199, command_id=11, *direction=<Direction.Client_to_Server: 1>)
[0x7F58:1:0x0702] Decoded ZCL frame: Metering:Default_Response(command_id=6, status=<Status.UNSUP_GENERAL_COMMAND: 130>)
[0x7F58:1:0x0000]: 'async_configure' stage succeeded
[0x7F58:1:0x0003]: 'async_configure' stage succeeded
[0x7F58:1:0x0702]: 'async_configure' stage failed: 'uint8_t' object is not subscriptable
[0x7F58](PC321): completed configuration |
class Owon_PC321_Z_Simple_Metering(CustomCluster, Metering): | ||
"""Owon PC321 CustomCluster""" | ||
|
||
ep_attribute: str = "smartenergy_metering" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this isn't needed, because the ep_attribute
is already set in Metering
(which we're inheriting here)?
Hello Thx |
Hey guys @exelsis423 @TheJulianJES How can I help to get this finally resolved ? Thx |
Hi there, same waiting for fix integration... Thank you! |
Hi, Now, I completely changed everything. I'm using proxmox, with HA core on a LXC. And for all other stuffs, I have for each one a dedicated LXC. And I installed z2mqtt. It was working fine, but if there is some improvement to do, somebody who have this equipment could have a look on it. |
hello, any update ? |
Hello, I'm here because I don't have all the attributes with my pliers. Is it ready soon? because I see it's approved? |
Salut, Vu que ça bloque au niveau de ZHA. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions. |
Proposed change
Creating a new quirk
Relevant ZHA PR: home-assistant/core#100735
Additional information
This quirk was created to fix the work of Owon PC321. At the beginning, zha discovered only current summation and instantaneous demand. With this quirk, all manufacturer datas are available, to work properly zha/sensors needs to be updated too (another PR). Modifications done according to manfucaturer doc which is available there : https://github.com/froggyfly/pc321-zigbee/blob/main/PC321zigbee.docx "Fixes #1657 #977".
Checklist
pre-commit
checks pass / the code has been formatted using Black