Skip to content
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

PJ-1103 clamp power meter (Improvement) #604

Closed
tomassanjuann opened this issue Apr 10, 2023 · 3 comments
Closed

PJ-1103 clamp power meter (Improvement) #604

tomassanjuann opened this issue Apr 10, 2023 · 3 comments

Comments

@tomassanjuann
Copy link
Contributor

tomassanjuann commented Apr 10, 2023

Information

Hello, first thanks for creating this integration, it works very reliable. This is my first issue created on GitHub and I don't know exactly if it will be better to do a pull request or other thing. I appreciate any advice. I've modified the device PJ-1103 to better understand and set the device functions.

Furthermore, I've modified the following parameters:

  • Set the Voltage and Current as sensors and not diagnostic.
  • Current as Amps vs mA. The energy clamp reads up to 3 decimals.
  • Option to set the max effective and reactive power. In the Smart Life app, these values count in the percentage of maximum load it shows. Done the min/max range and scaling/step
  • Minor name and icon changes.

DPS from tinytuya

Status: {'17': 100, '18': 2436, '19': 4347, '20': 2341, '51': 58, '52': 50000}

Product ID

djfep9s6s3b2qk89 / Model Number: PJ-MGW1103 / Protocol 3.4

Information about DPS mappings

{
  "result": {
    "category": "aqcz",
    "functions": [
      {
        "code": "power_reactive",
        "dp_id": 51,
        "type": "Integer",
        "values": "{\"unit\":\"W\",\"min\":10,\"max\":100,\"scale\":1,\"step\":1}"
      },
      {
        "code": "power_effective",
        "dp_id": 52,
        "type": "Integer",
        "values": "{\"unit\":\"W\",\"min\":10,\"max\":200000,\"scale\":1,\"step\":1}"
      }
    ],
    "status": [
      {
        "code": "add_ele",
        "dp_id": 17,
        "type": "Integer",
        "values": "{\"unit\":\"kW·h\",\"min\":0,\"max\":50000,\"scale\":3,\"step\":100}"
      },
      {
        "code": "cur_current",
        "dp_id": 18,
        "type": "Integer",
        "values": "{\"unit\":\"mA\",\"min\":0,\"max\":100000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "cur_power",
        "dp_id": 19,
        "type": "Integer",
        "values": "{\"unit\":\"W\",\"min\":0,\"max\":800000,\"scale\":1,\"step\":1}"
      },
      {
        "code": "cur_voltage",
        "dp_id": 20,
        "type": "Integer",
        "values": "{\"unit\":\"V\",\"min\":0,\"max\":5000,\"scale\":1,\"step\":1}"
      },
      {
        "code": "test_bit",
        "dp_id": 21,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":5,\"scale\":0,\"step\":1}"
      },
      {
        "code": "voltage_coe",
        "dp_id": 22,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":1000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "electric_coe",
        "dp_id": 23,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":1000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "power_coe",
        "dp_id": 24,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":1000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "electricity_coe",
        "dp_id": 25,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":1000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "fault",
        "dp_id": 26,
        "type": "Bitmap",
        "values": "{\"label\":[\"ov_cr\",\"ov_vol\",\"ov_pwr\",\"ls_cr\",\"ls_vol\",\"ls_pow\"],\"maxlen\":6}"
      },
      {
        "code": "power_reactive",
        "dp_id": 51,
        "type": "Integer",
        "values": "{\"unit\":\"W\",\"min\":10,\"max\":100,\"scale\":1,\"step\":1}"
      },
      {
        "code": "power_effective",
        "dp_id": 52,
        "type": "Integer",
        "values": "{\"unit\":\"W\",\"min\":10,\"max\":200000,\"scale\":1,\"step\":1}"
      }
    ]
  },

Modified YAML file

name: PJ-1103 clamp power meter
product:
  - id: djfep9s6s3b2qk89
    name: PJ-1103
primary_entity:
  entity: sensor
  name: Power
  class: power
  dps:
    - id: 19
      name: sensor
      type: integer
      unit: W
      class: measurement
      force: true
      mapping:
        - scale: 10
    - id: 21
      type: bitfield
      name: Test Bit
      optional: true
    - id: 24
      name: calibration
      type: integer
      optional: true
    - id: 26
      type: bitfield
      name: fault_code
      optional: true
secondary_entities:
  - entity: sensor
    name: Current
    class: current
    dps:
      - id: 18
        type: integer
        name: sensor
        unit: A
        force: true
        class: measurement
        mapping:
        - scale: 1000
      - id: 23
        type: integer
        name: calibration
        optional: true
  - entity: sensor
    name: Voltage
    class: voltage
    dps:
      - id: 20
        type: integer
        name: sensor
        unit: V
        force: true
        class: measurement
        mapping:
          - scale: 10
      - id: 22
        type: integer
        name: calibration
        optional: true
  - entity: sensor
    name: Energy
    category: diagnostic
    icon: mdi:chart-histogram
    dps:
      - id: 17
        type: integer
        name: sensor
        optional: true
        unit: kWh
        mapping:
          - scale: 100
      - id: 25
        type: integer
        name: calibration
        optional: true
  - entity: binary_sensor
    name: Fault
    class: problem
    category: diagnostic
    dps:
      - id: 26
        type: bitfield
        name: sensor
        optional: true
        persist: false
        mapping:
          - dps_val: null
            value: false
          - dps_val: 0
            value: false
          - value: true
  - entity: number
    name: Reactive Power
    category: config
    icon: mdi:flash-alert
    mode: box
    dps:
      - id: 51
        type: integer
        name: value
        unit: W
        optional: true
        mapping:
          - scale: 1
        range:
          min: 10
          max: 100
  - entity: number
    name: Effective Power
    category: config
    icon: mdi:flash-alert
    mode: box
    dps:
      - id: 52
        type: integer
        name: value
        unit: W
        optional: true
        mapping:
          - scale: 10
            step: 100
        range:
          min: 0
          max: 150000
@tomassanjuann tomassanjuann added the new device Unsupported device label Apr 10, 2023
@tomassanjuann
Copy link
Contributor Author

First thread is #336. Also, the DP 17 which in theory measures kWh is broken, it resets every hour or so, it's like a counter. Currently using the Integration / Utility meter helpers and it works successfully.

@make-all make-all added device improvement Improvement to an existing device config config provided Config included by reporter and removed new device Unsupported device labels Apr 10, 2023
@make-all
Copy link
Owner

  • Set the Voltage and Current as sensors and not diagnostic.
    This seems like an unnecessary change. These values are effectively diagnostic values, as they are not really of primary interest for everyday use like the power reading is. Being marked as diagnostic does not make them inaccessible if you really want to use them, it just affects the default auto-generated UI.

  • Current as Amps vs mA. The energy clamp reads up to 3 decimals.
    Again, this seems like an unnecessary change, especially now that HA supports unit conversion in the UI.

  • Option to set the max effective and reactive power. In the Smart Life app, these values count in the percentage of maximum load it shows. Done the min/max range and scaling/step
    Thank you. It is also useful to get a definition of what the difference between these two is, as I think in the original info the names were in Chinese and both just translated to "max power".

  • Minor name and icon changes.
    It is difficult to see what these are without more info

make-all added a commit that referenced this issue Apr 14, 2023
Originally the second max power setting was not understood, so left as
a read-only attribute.  Based on #604, we now know that both are settings,
one is a power factor (Max reactive power), the other is a power setting
(Max effective power).
@make-all make-all added awaiting confirmation Wating for confirmation the issue is solved unreleased Will be in next release and removed config provided Config included by reporter labels Apr 14, 2023
@tomassanjuann
Copy link
Contributor Author

Okay, I didn't know about the unnecessary UI changes, my first issue sorry :) I think the commit is okay.

The minor name and icon changes were on the new items. I've named them Reactive Power and Effective Power, and assigned the mdi:flash-alert icon. That's also minor UI changes, so it's my personal taste.

The Effective Power is what the Tuya app shows as maximum allowed power, as a bar (see image attached). I really didn't discover what Reactive Power really do.

@make-all make-all removed awaiting confirmation Wating for confirmation the issue is solved unreleased Will be in next release device improvement Improvement to an existing device config labels Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants