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

Additional config for electricity meters #819

Closed
klew opened this issue Apr 23, 2024 · 4 comments
Closed

Additional config for electricity meters #819

klew opened this issue Apr 23, 2024 · 4 comments

Comments

@klew
Copy link
Member

klew commented Apr 23, 2024

In channel config json for electricity meter channel there will be new parameters based on this structure:

typedef struct {
  // Selected CT type
  unsigned _supla_int64_t UsedCTType;  // EM_CT_TYPE_
  // Selected phase LED type
  unsigned _supla_int64_t UsedPhaseLedType;  // EM_PHASE_LED_TYPE_*

  // Phase LED params (actual meaning depends on phase LED type)
  _supla_int_t PhaseLedParam1;
  _supla_int_t PhaseLedParam2;

  // readonly, device capabilities
  unsigned _supla_int64_t AvailableCTTypes;
  unsigned _supla_int64_t AvailablePhaseLedTypes;

  unsigned char Reserved[32];
} TChannelConfig_ElectricityMeter;  // v. >= 23

UsedCTType (used current transformer type) - drop-down select with values based on AvailableCTTypes bitmap.
UsedPhaseLedType - drop-down select with values based on AvailablePhaseLedTypes.
When Available* field is zero, then corresponsing drop-down shouldn't be visible.

Values for CT Type:

#define EM_CT_TYPE_100A_33mA  (1ULL << 0)
#define EM_CT_TYPE_200A_66mA  (1ULL << 1)
#define EM_CT_TYPE_400A_133mA (1ULL << 2)

Corresponding labels: "100A/33.3mA", "200A/66.6mA", "400A/133.3mA".
CT types may be extended in future. So provide fallback for labels in form "Unknown CT type 4", etc.

Values for Phase LED Types with PhaseLedParam1/2 usage description:

#define EM_PHASE_LED_TYPE_OFF                       (1ULL << 0)
#define EM_PHASE_LED_TYPE_VOLTAGE_PRESENCE          (1ULL << 1)
#define EM_PHASE_LED_TYPE_VOLTAGE_PRESENCE_INVERTED (1ULL << 2)
// Voltage level:
//  - PhaseLedParam1 - "low threshold", units 0.01 V.
//    When voltage < low threshold -> blue LED
//  - PhaseLedParam2 - "high threshold", units 0.01 V.
//    When voltage > high threshold -> red LED
//  - Voltage between low and high threshold -> green LED
#define EM_PHASE_LED_TYPE_VOLTAGE_LEVEL             (1ULL << 3)
// Active power direction:
//  - PhaseLedParam1 - "low threshold", units 0.01 W.
//    When power < low threshold -> green LED.
//  - PhaseLedParam2 - "high threshold", units 0.01 W.
//    When power > high threshold -> red LED
#define EM_PHASE_LED_TYPE_POWER_ACTIVE_DIRECTION    (1ULL << 4)
@przemyslawzygmunt
Copy link
Member

przemyslawzygmunt commented Jul 4, 2024

Sample JSON below.
PhaseLedParam1, PhaseLedParam2 should be divided by 100

userConfig:

{
"usedCTType":"200A_66mA",
"usedPhaseLedType":"VOLTAGE_PRESENCE",
"phaseLedParam1":15,
"phaseLedParam2":46,
}

properties:
{
"availableCTTypes":[
"100A_33mA",
"200A_66mA",
"400A_133mA"
],
"availablePhaseLedTypes":[
"OFF",
"VOLTAGE_PRESENCE",
"VOLTAGE_PRESENCE_INVERTED",
"VOLTAGE_LEVEL",
"POWER_ACTIVE_DIRECTION"
]
}

@fracz
Copy link
Member

fracz commented Jul 10, 2024

Czym są phaseLedParam1 i phaseLedParam2? Jakie mogą przyjmować wartości?

@fracz
Copy link
Member

fracz commented Jul 11, 2024

Dodałem ustawienia dla phaseLedTypes oraz CTTypes. Param1 i Param2 zostawiam do wyjaśnienia.

fracz added a commit that referenced this issue Jul 12, 2024
@fracz fracz closed this as completed Jul 12, 2024
@fracz
Copy link
Member

fracz commented Jul 12, 2024

image

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

3 participants