zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
719 stars 663 forks source link

[Device Support Request] OWON Technology Inc. PC321,need more information to be display #1657

Closed adi90x closed 6 months ago

adi90x commented 2 years ago

Hello,

Reoppening #977 At the moment zha will only report one consumption while 3 are available.

Is it possible to do something ? Signature of the device is available in #977 And manfucaturer doc is available there : https://github.com/froggyfly/pc321-zigbee/blob/main/PC321zigbee.docx

@froggyfly : Did you find another solution ?

Regards

fergalish commented 2 years ago

Hi, I'm trying to install one of these OWON 3-phase/triple single phase power meters. It's adds to ZHA with no problem, but the only sensors I'm seeing are instantaneous power and total energy consumed, each a sum of the three physical input sensors.

I'm still learning HA & ZHA, so I have no idea how to edit a device signature etc.

Curious to know if there's a way to proceed.

Thanks.

dliouville commented 1 year ago

Also bought the owon PC321, mistake ... I didn't check HA device support ... This power meter is very common and have many rebranding. Is there any hope to see it supported in HA ?

udivankin commented 1 year ago

Seems to be implemented in z2m

BUT

there's two different PC321 zigbee clamp meters - PC321-Z and PC321-Z-TY (Tuya), which are according to @Koenkk two completely different devices.

Here's the long thread PC321-Z https://github.com/Koenkk/zigbee2mqtt/issues/9525

And here is for PC321-Z-TY (Tuya) https://github.com/Koenkk/zigbee2mqtt/issues/14790

For me what is missing is current reporting for each phase

exelsis423 commented 1 year ago

Hello, I reopen this request. I have this equipment too the OWON PC321 Z.

After having searched a lot, I tried to write a quirk. The first way I tried was following the documentation with using the metering cluster. This the quirk:

import zigpy.types as t

from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.foundation import ZCLAttributeDef, ZCLCommandDef
from zigpy.zcl.clusters.general import (
    Basic,
    Identify,
    )
from zigpy.zcl.clusters.smartenergy import (
    Metering, 
    )
from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
    SKIP_CONFIGURATION,
    )

from zhaquirks import LocalDataCluster

class OwonSimpleMetering(CustomCluster):
    cluster_id = 0x0702
    name = "Owon Simple Metering dbl"
    ep_attribute = "electrical_measurement" 

    attributes: dict[int, ZCLAttributeDef] = {
        0x0000: ZCLAttributeDef("current_summ_delivered", type=t.uint48_t, access="r", mandatory=True),
        0x0017: ZCLAttributeDef("Inlet_temperature", type=t.uint24_t, access="r", mandatory=True),
        0x0200: ZCLAttributeDef("Status", type=t.bitmap8, access="r", mandatory=True),
        0x0300: ZCLAttributeDef("unit_of_measure", type=t.enum8, access="r", mandatory=True),
        0x0301: ZCLAttributeDef("multiplier", type=t.uint24_t, access="r", mandatory=True),
        0x0302: ZCLAttributeDef("divisor", type=t.uint24_t, access="r", mandatory=True),
        0x0303: ZCLAttributeDef("summation_formatting", type=t.bitmap8, access="r", mandatory=True),
        0x0304: ZCLAttributeDef("demand_formatting", type=t.bitmap8, access="r", mandatory=True),
        0x0306: ZCLAttributeDef("metering_device_type", type=t.bitmap8, access="r", mandatory=True),
        0x0400: ZCLAttributeDef("Instantaneous_Demand", type=t.uint24_t, access="rw", mandatory=True),
        0x1000: ZCLAttributeDef("report_map", type=t.bitmap8, access="rw", mandatory=True, is_manufacturer_specific=True),
        0x2000: ZCLAttributeDef("L1_phase_power", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x2001: ZCLAttributeDef("L2_phase_power", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x2002: ZCLAttributeDef("L3_phase_power", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x2100: ZCLAttributeDef("L1_phase_reactive_power", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x2101: ZCLAttributeDef("L2_phase_reactive_power", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x2102: ZCLAttributeDef("L3_phase_reactive_power", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x2103: ZCLAttributeDef("reactive_power_summation_of_the_3_phases", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x3000: ZCLAttributeDef("L1_phase_voltage", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x3001: ZCLAttributeDef("L2_phase_voltage", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x3002: ZCLAttributeDef("L3_phase_voltage", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x3100: ZCLAttributeDef("L1_phase_current", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x3101: ZCLAttributeDef("L2_phase_current", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x3102: ZCLAttributeDef("L3_phase_current", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x3103: ZCLAttributeDef("current_summation_of_the_3_phases", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x3104: ZCLAttributeDef("leakage_current", type=t.uint24_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x4000: ZCLAttributeDef("L1_phase_energy_consumption", type=t.uint48_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x4001: ZCLAttributeDef("L2_phase_energy_consumption", type=t.uint48_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x4002: ZCLAttributeDef("L3_phase_energy_consumption", type=t.uint48_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x4100: ZCLAttributeDef("L1_phase_reactive_energy_consumption", type=t.uint48_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x4101: ZCLAttributeDef("L2_phase_reactive_energy_consumption", type=t.uint48_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x4102: ZCLAttributeDef("L3_phase_reactive_energy_consumption", type=t.uint48_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x4103: ZCLAttributeDef("reactive_energy_summation_of_the_3_phases", type=t.uint48_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x5000: ZCLAttributeDef("the_latest_historical_record_time", type=t.uint32_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x5001: ZCLAttributeDef("the_oldest_historical_recorded_time", type=t.uint32_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x5002: ZCLAttributeDef("set_minimum_cycle_for_report", type=t.uint32_t, access="rw", mandatory=True, is_manufacturer_specific=True),
        0x5003: ZCLAttributeDef("set_maximum_cycle_for_report", type=t.uint32_t, access="rw", mandatory=True, is_manufacturer_specific=True),
        0x5004: ZCLAttributeDef("sent_historical_record_state", type=t.uint8_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x5005: ZCLAttributeDef("frequency", type=t.uint8_t, access="r", mandatory=True, is_manufacturer_specific=True),
        0x5006: ZCLAttributeDef("the_accumulative_threshold_of_energy", type=t.uint8_t, access="rw", mandatory=True, is_manufacturer_specific=True),
        0x5007: ZCLAttributeDef("report_mode", type=t.uint8_t, access="rw", mandatory=True, is_manufacturer_specific=True),
        0x5008: ZCLAttributeDef("Set_Z_percent_change_in_power", type=t.uint8_t, access="rw", mandatory=True, is_manufacturer_specific=True),
    } 

    server_commands: dict[int, ZCLCommandDef] = {
        0x20: ZCLCommandDef("get_history_record", {}, is_manufacturer_specific=True),
        0x21: ZCLCommandDef("stop_sending_historical_record", {}, is_manufacturer_specific=True),
    }

    client_commands: dict[int, ZCLCommandDef] = {
        0x20: ZCLCommandDef("sent_historical_record", {}, is_manufacturer_specific=True),
    }

class OwonClearMetering(CustomCluster):
    cluster_id = 0xFFE0
    ep_attribute = "clear_metering"

    attributes: dict[int, ZCLAttributeDef] = {}

    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("clear_measurement_data", {}, is_manufacturer_specific=True),
    }
    client_commands: dict[int, ZCLCommandDef] = {}

class Owon(CustomDevice):

    signature = {
        #MODELS_INFO: [("Owon", "PC321")],
        ENDPOINTS: {
            # <SimpleDescriptor endpoint=1 profile=260 device_type=13
            # device_version=1
            # input_clusters=[0, 3, 1794]
            # output_clusters=[3]>
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.CONSUMPTION_AWARENESS_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Metering.cluster_id,
                    ],
                OUTPUT_CLUSTERS: [Identify.cluster_id],
            },
        },
        "manufacturer": "OWON Technology Inc.",
    }
    replacement = {
        #SKIP_CONFIGURATION: True,
        ENDPOINTS: {
            # <SimpleDescriptor endpoint=1 profile=260 device_type=0x0053
            # device_version=1
            # input_clusters=[0, 3, 1794, 83]
            # output_clusters=[3]>
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.METER_INTERFACE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    OwonPowerMeasurement,
                    OwonClearMetering,
                ],
                OUTPUT_CLUSTERS: [Identify.cluster_id],
            },
        },
    }

This quirk works, but when the device is discovered by ZHA, there's no entity.

I ask for help on a french forum, and I get adviced to try to pass the replacement trough ElectricalMeasurement. I wrote a new quirk (simplier for the moment, there're not all attributes but it's for testing). Regarding the documentation, it's possible to have different measurement types:

    """Cluster handler that polls active power level."""

    CLUSTER_HANDLER_NAME = CLUSTER_HANDLER_ELECTRICAL_MEASUREMENT

    class MeasurementType(enum.IntFlag):
        """Measurement types."""

        ACTIVE_MEASUREMENT = 1
        REACTIVE_MEASUREMENT = 2
        APPARENT_MEASUREMENT = 4
        PHASE_A_MEASUREMENT = 8
        PHASE_B_MEASUREMENT = 16
        PHASE_C_MEASUREMENT = 32
        DC_MEASUREMENT = 64
        HARMONICS_MEASUREMENT = 128
        POWER_QUALITY_MEASUREMENT = 256

I wrote this quirk:


from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.foundation import ZCLAttributeDef, ZCLCommandDef
from zigpy.zcl.clusters.general import (
    Basic,
    Identify,
    )
from zigpy.zcl.clusters.smartenergy import (
    Metering, 
    )
from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
    SKIP_CONFIGURATION,
    )

from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zhaquirks import LocalDataCluster

class OwonPowerMeasurement(LocalDataCluster, ElectricalMeasurement):
    """Custom class for power, voltage and current measurement."""

    cluster_id = 0x0702

    POWER_ONE_ID = 0x2000
    POWER_TWO_ID = 0x2001
    POWER_THREE_ID = 0x2002

    MULTIPLIER = 0x0301
    DIVISOR = 0x0302
    _CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000}

    ep_attribute = "electrical_measurement"
    attributes = {
        0x0000: ("current_summ_delivered", t.uint48_t, True),
        0x2000: ("L1_phase_power", t.uint24_t, True),
        0x2001: ("L2_phase_power", t.uint24_t, True),
        0x2002: ("L3_phase_power", t.uint24_t, True),
        0x0400: ("Instantaneous_Demand", t.uint24_t, True),
    }

    server_commands: dict[int, ZCLCommandDef] = {
        0x20: ZCLCommandDef("get_history_record", {}, is_manufacturer_specific=True),
        0x21: ZCLCommandDef("stop_sending_historical_record", {}, is_manufacturer_specific=True),
    }

    client_commands: dict[int, ZCLCommandDef] = {
        0x20: ZCLCommandDef("sent_historical_record", {}, is_manufacturer_specific=True),
    }

class OwonClearMetering(CustomCluster):
    cluster_id = 0xFFE0
    ep_attribute = "clear_metering"

    attributes: dict[int, ZCLAttributeDef] = {}

    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("clear_measurement_data", {}, is_manufacturer_specific=True),
    }
    client_commands: dict[int, ZCLCommandDef] = {}

""" New Device Owon PC321 """

class Owon(CustomDevice):

    signature = {
        #MODELS_INFO: [("Owon", "PC321")],
        ENDPOINTS: {
            # <SimpleDescriptor endpoint=1 profile=260 device_type=13
            # device_version=1
            # input_clusters=[0, 3, 1794]
            # output_clusters=[3]>
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.CONSUMPTION_AWARENESS_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Metering.cluster_id,
                    ],
                OUTPUT_CLUSTERS: [Identify.cluster_id],
            },
        },
        "manufacturer": "OWON Technology Inc.",
    }
    replacement = {
        #SKIP_CONFIGURATION: True,
        ENDPOINTS: {
            # <SimpleDescriptor endpoint=1 profile=260 device_type=83
            # device_version=1
            # input_clusters=[0, 3, 1794, 65504]
            # output_clusters=[3]>
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.METER_INTERFACE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    OwonPowerMeasurement,
                    OwonClearMetering,
                ],
                OUTPUT_CLUSTERS: [Identify.cluster_id],
            },
        },
    }

With this new quirk, I can read attributes as the first one, but I still don't have any entity. I block on this point, I cannot pass the good parameter to have for example PHASE_A_MEASUREMENT. If someone could help on this point to try to finalize the quirk, I could share it.

Thanks

exelsis423 commented 1 year ago

Hi, I found a way to write a quirk, but it's doesn't descover entitier. So it's needed to create sensors, and an automation to have these sensors updated (mine is every minute).

Here is the code, code for sensors and automation is in comments at the end

""" QUIRK FOR OWON PC321 Z                                                                    """
""" THIS QUIRK DOESN'T CREATE ENTITES WHEN THE DEVICE IS DISCOVERED                           """
""" TO MAKE IT RUNNING, YOU NEED TO CREATE SENSORS AND AN AUTOMATION. SEE CODE AT THE END     """

import logging
import zigpy.types as t

from typing import Dict
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.foundation import ZCLAttributeDef, ZCLCommandDef
from zigpy.zcl.clusters.general import (
    Basic,
    Identify,
    )
from zigpy.zcl.clusters.smartenergy import Metering
from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
    SKIP_CONFIGURATION,
    )

_LOGGER = logging.getLogger(__name__)

class Owon_PC321_Simple_Metering(CustomCluster, Metering):
    """ Owon PC321 CustomCluster """

    """ Import attributes but doesn't create entities """
    """ Needs to use ZHA Toolkit to be usefull """

    cluster_id = 0x0702
    ep_attribute: str = "smartenergy_metering"

    attributes = Metering.attributes.copy()
    attributes.update(
        {
        0x2000: ("phase_A_power", t.uint24_t, True),
        0x2001: ("phase_B_power", t.uint24_t, True),
        0x2002: ("phase_C_power", t.uint24_t, True),
        0x2100: ("phase_A_reactive_power", t.uint24_t, True),
        0x2101: ("phase_B_reactive_power", t.uint24_t, True),
        0x2102: ("phase_C_reactive_power", t.uint24_t, True),
        0x2103: ("reactive_power_summation_of_the_3_phases", t.uint24_t, True),
        0x3000: ("phase_A_voltage", t.uint24_t, True),
        0x3001: ("phase_B_voltage", t.uint24_t, True),
        0x3002: ("phase_C_voltage", t.uint24_t, True),
        0x3100: ("phase_A_current", t.uint24_t, True),
        0x3101: ("phase_B_current", t.uint24_t, True),
        0x3102: ("phase_C_current", t.uint24_t, True),
        0x3103: ("current_summation_of_the_3_phases", t.uint24_t, True),
        0x3104: ("leakage_current", t.uint24_t, True),
        0x4000: ("phase_A_energy_consumption", t.uint48_t, True),
        0x4001: ("phase_B_energy_consumption", t.uint48_t, True),
        0x4002: ("phase_C_energy_consumption", t.uint48_t, True),
        0x4100: ("phase_A_reactive_energy_consumption", t.uint48_t, True),
        0x4101: ("phase_B_reactive_energy_consumption", t.uint48_t, True),
        0x4102: ("phase_C_reactive_energy_consumption", t.uint48_t, True),
        0x4103: ("reactive_energy_summation_of_the_3_phases", t.uint48_t, True),
        }
    )

    server_commands: dict[int, ZCLCommandDef] = {
        0x20: ZCLCommandDef("get_history_record", {}, False, is_manufacturer_specific=True),
        0x21: ZCLCommandDef("stop_sending_historical_record", {}, False, is_manufacturer_specific=True),
    }

    client_commands: dict[int, ZCLCommandDef] = {
        0x20: ZCLCommandDef("sent_historical_record", {}, True, is_manufacturer_specific=True),
    }

class Owon_OC321_Clear_Metering(CustomCluster):
    cluster_id = 0xFFE0
    ep_attribute = "clear_metering"

    attributes: dict[int, ZCLAttributeDef] = {}

    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("clear_measurement_data", {}, is_manufacturer_specific=True),
    }
    client_commands: dict[int, ZCLCommandDef] = {}

""" New Device Owon PC321 Z """

class Owon_PC321(CustomDevice):

    signature = {
        #MODELS_INFO: [("Owon", "PC321")],
        ENDPOINTS: {
            # <SimpleDescriptor endpoint=1 profile=260 device_type=13
            # device_version=1
            # input_clusters=[0, 3, 1794]
            # output_clusters=[3]>
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.CONSUMPTION_AWARENESS_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Metering.cluster_id,
                    ],
                OUTPUT_CLUSTERS: [Identify.cluster_id],
            },
        },
        "manufacturer": "OWON Technology Inc.",
    }
    replacement = {
        #SKIP_CONFIGURATION: True,
        ENDPOINTS: {
            # <SimpleDescriptor endpoint=1 profile=260 device_type=83
            # device_version=1
            # input_clusters=[0, 3, 1794, 65504]
            # output_clusters=[3]>
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.CONSUMPTION_AWARENESS_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Owon_PC321_Simple_Metering,
                    Owon_OC321_Clear_Metering,
                ],
                OUTPUT_CLUSTERS: [Identify.cluster_id],
            },
        },
    }

""" REPORTING                                                                            """
""" TO HAVE ENTIIES REPORTING IT IS NEEDED TO CREATE SENSORS                             """
""" COPY THE FOLLOWING. DATAS ARE COPIE 'AS IS'. TO HAVE WELL FORMATTED DATAS, SEE BELOW """

"""
template:
    - sensor:
        - name: owon_power_phase_A
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_power_phase_B
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_power_phase_C
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_reactive_power_phase_A
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_reactive_power_phase_B
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_reactive_power_phase_C
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_reactive_power_summation_of_the_3_phases
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_voltage_phase_A_brut
          unit_of_measurement: "dV"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_voltage_phase_B_brut
          unit_of_measurement: "dV"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_voltage_phase_C_brut
          unit_of_measurement: "dV"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_current_phase_A_brut
          unit_of_measurement: "mA"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_current_phase_B_brut
          unit_of_measurement: "mA"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_current_phase_C_brut
          unit_of_measurement: "mA"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_current_summation_of_the_3_phases_brut
          unit_of_measurement: "mA"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_leakage_current
          unit_of_measurement: "A"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_energy_consumption_phase_A
          unit_of_measurement: "kWh"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_energy_consumption_phase_B
          unit_of_measurement: "kWh"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_energy_consumption_phase_C
          unit_of_measurement: "kWh"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_reactive_energy_consumption_phase_A
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_reactive_energy_consumption_phase_B
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_reactive_energy_consumption_phase_C
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
        - name: owon_reactive_energy_summation_of_the_3_phases
          unit_of_measurement: "W"
          device_class: energy
          state_class: total_increasing
          state: 0
"""
""" TO HAVE ENTIIES WELL FOMATTED, IT IS NEEDED TO CREATE FOLLOWING SENSORS """
"""
  - platform: template
    sensors:
      owon_voltage_phase_a:
        unit_of_measurement: 'V'
        value_template: "{{ (states('sensor.owon_voltage_phase_a_brut') | int / 10 | round(1)) }}"
        device_class: energy
      owon_voltage_phase_b:
        unit_of_measurement: 'V'
        value_template: "{{ (states('sensor.owon_voltage_phase_b_brut') | int / 10 | round(1)) }}"
        device_class: energy
      owon_voltage_phase_c:
        unit_of_measurement: 'V'
        value_template: "{{ (states('sensor.owon_voltage_phase_c_brut') | int / 10 | round(1)) }}"
        device_class: energy
      owon_current_phase_a:
        unit_of_measurement: 'A'
        value_template: "{{ (states('sensor.owon_current_phase_a_brut') | int / 1000 | round(1)) }}"
        device_class: energy
      owon_current_phase_b:
        unit_of_measurement: A
        value_template: "{{ (states('sensor.owon_current_phase_b_brut') | int / 1000 | round(1)) }}"
        device_class: energy
      owon_current_phase_c:
        unit_of_measurement: 'A'
        value_template: "{{ (states('sensor.owon_current_phase_c_brut') | int / 1000 | round(1)) }}"
        device_class: energy
"""

""" TO UPDATE THESE SENSORS AUTOMATICALLY                                  """
""" CREATE A NEW AUTOMATION AND COPY THE FOLLOWING. UPDATE IS EVERY MINUTE """

"""
alias: Owon PC321
description: Lecture Owon PC321 every minute
trigger:
  - platform: time_pattern
    hours: "*"
    minutes: /1
    seconds: "0"
condition: []
action:
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      state_id: sensor.owon_power_phase_A
      allow_create: false
      attribute: 8192
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 8193
      state_id: sensor.owon_power_phase_B
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 8194
      state_id: sensor.owon_power_phase_C
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 8448
      state_id: sensor.owon_reactive_power_phase_A
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 8449
      state_id: sensor.owon_reactive_power_phase_B
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 8450
      state_id: sensor.owon_reactive_power_phase_C
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 8451
      state_id: sensor.owon_reactive_power_summation_of_the_3_phases
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 12288
      state_id: sensor.owon_voltage_phase_A_brut
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 12289
      state_id: sensor.owon_voltage_phase_B_brut
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 12290
      state_id: sensor.owon_voltage_phase_C_brut
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 12544
      state_id: sensor.owon_current_phase_A_brut
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 12545
      state_id: sensor.owon_current_phase_B_brut
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 12546
      state_id: sensor.owon_current_phase_C_brut
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 12547
      state_id: sensor.owon_current_summation_of_the_3_phases_brut
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 12549
      state_id: sensor.owon_leakage_current
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 16384
      state_id: sensor.owon_energy_consumption_phase_A
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 16385
      state_id: sensor.owon_energy_consumption_phase_B
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 16386
      state_id: sensor.owon_energy_consumption_phase_C
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 16640
      state_id: sensor.owon_reactive_energy_consumption_phase_A
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 16641
      state_id: sensor.owon_reactive_energy_consumption_phase_B
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 16642
      state_id: sensor.owon_reactive_energy_consumption_phase_C
      allow_create: false
  - service: zha_toolkit.execute
    data:
      command: attr_read
      ieee: 3c:6a:2c:ff:fe:d2:ef:73
      cluster: 1794
      attribute: 16643
      state_id: sensor.owon_reactive_energy_summation_of_the_3_phases
      allow_create: false
mode: single

"""
udivankin commented 1 year ago

any idea when it makes its way to hass update? and what are the steps to make it work in case it was already configured with only 3 entities?

fergalish commented 1 year ago

Hi, I found a way to write a quirk, but it's doesn't descover entitier. So it's needed to create sensors, and an automation to have these sensors updated (mine is every minute).

Here is the code, code for sensors and automation is in comments at the end

Thanks for this. I implemented these, removed the PC321, restarted HA, and it is working as described.

github-actions[bot] commented 6 months ago

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.

KPI33 commented 3 months ago

Never integrated?