Skip to content

Commit

Permalink
Add frequency sensors for Pro 3EM (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
bieniu authored Jul 22, 2023
1 parent 87dedce commit a97ad48
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions python_scripts/shellies_discovery_gen2.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
DEVICE_CLASS_CONNECTIVITY = "connectivity"
DEVICE_CLASS_CURRENT = "current"
DEVICE_CLASS_ENERGY = "energy"
DEVICE_CLASS_FREQUENCY = "frequency"
DEVICE_CLASS_HUMIDITY = "humidity"
DEVICE_CLASS_POWER = "power"
DEVICE_CLASS_POWER_FACTOR = "power_factor"
Expand Down Expand Up @@ -165,6 +166,7 @@
SENSOR_ETH_IP = "eth_ip"
SENSOR_EXTERNAL_POWER = "external_power"
SENSOR_FIRMWARE = "firmware"
SENSOR_FREQUENCY = "frequency"
SENSOR_HUMIDITY = "humidity"
SENSOR_INPUT = "input"
SENSOR_LAST_RESTART = "last_restart"
Expand Down Expand Up @@ -241,6 +243,7 @@
TPL_EMETER_ACTIVE_POWER = "{{{{value_json.{phase}_act_power}}}}"
TPL_EMETER_APPARENT_POWER = "{{{{value_json.{phase}_aprt_power}}}}"
TPL_EMETER_CURRENT = "{{{{value_json.{phase}_current}}}}"
TPL_EMETER_FREQUENCY = "{{{{value_json.{phase}_freq}}}}"
TPL_EMETER_N_CURRENT = "{{value_json.n_current}}"
TPL_EMETER_PHASE_TOTAL_ACTIVE_ENERGY = "{{{{value_json.{phase}_total_act_energy}}}}"
TPL_EMETER_PHASE_TOTAL_ACTIVE_RETURNED_ENERGY = (
Expand All @@ -252,7 +255,7 @@
TPL_EMETER_TOTAL_ACTIVE_RETURNED_ENERGY = "{{value_json.total_act_ret}}"
TPL_EMETER_TOTAL_APPARENT_POWER = "{{value_json.total_aprt_power}}"
TPL_EMETER_TOTAL_CURRENT = "{{value_json.total_current}}"
TPL_EMETER_VOLTEAGE = "{{{{value_json.{phase}_voltage}}}}"
TPL_EMETER_VOLTAGE = "{{{{value_json.{phase}_voltage}}}}"
TPL_ENERGY = "{{value_json.aenergy.total}}"
TPL_ETH_IP = "{{value_json.eth.ip}}"
TPL_EXTERNAL_POWER = "{%if value_json.external.present%}ON{%else%}OFF{%endif%}"
Expand Down Expand Up @@ -302,6 +305,7 @@
UNIT_AMPERE = "A"
UNIT_CELSIUS = "°C"
UNIT_DBM = "dBm"
UNIT_HERTZ = "Hz"
UNIT_PERCENT = "%"
UNIT_VOLT = "V"
UNIT_VA = "VA"
Expand Down Expand Up @@ -654,6 +658,16 @@
KEY_UNIT: UNIT_VOLT,
KEY_VALUE_TEMPLATE: TPL_VOLTAGE,
}
DESCRIPTION_SENSOR_EMETER_FREQUENCY = {
KEY_DEVICE_CLASS: DEVICE_CLASS_FREQUENCY,
KEY_ENABLED_BY_DEFAULT: False,
KEY_NAME: "Phase {phase} frequency",
KEY_STATE_CLASS: STATE_CLASS_MEASUREMENT,
KEY_STATE_TOPIC: TOPIC_EMETER,
KEY_SUGGESTED_DISPLAY_PRECISION: 0,
KEY_UNIT: UNIT_HERTZ,
KEY_VALUE_TEMPLATE: TPL_EMETER_FREQUENCY,
}
DESCRIPTION_SENSOR_EMETER_VOLTAGE = {
KEY_DEVICE_CLASS: DEVICE_CLASS_VOLTAGE,
KEY_ENABLED_BY_DEFAULT: True,
Expand All @@ -662,7 +676,7 @@
KEY_STATE_TOPIC: TOPIC_EMETER,
KEY_SUGGESTED_DISPLAY_PRECISION: 1,
KEY_UNIT: UNIT_VOLT,
KEY_VALUE_TEMPLATE: TPL_EMETER_VOLTEAGE,
KEY_VALUE_TEMPLATE: TPL_EMETER_VOLTAGE,
}
DESCRIPTION_SENSOR_VOLTAGE_COVER = {
KEY_DEVICE_CLASS: DEVICE_CLASS_VOLTAGE,
Expand Down Expand Up @@ -1418,6 +1432,7 @@
SENSOR_TOTAL_ACTIVE_ENERGY: DESCRIPTION_SENSOR_EMETER_PHASE_TOTAL_ACTIVE_ENERGY,
SENSOR_TOTAT_ACTIVE_RETURNED_ENERGY: DESCRIPTION_SENSOR_EMETER_PHASE_TOTAL_ACTIVE_RETURNED_ENERGY,
SENSOR_VOLTAGE: DESCRIPTION_SENSOR_EMETER_VOLTAGE,
SENSOR_FREQUENCY: DESCRIPTION_SENSOR_EMETER_FREQUENCY,
},
ATTR_UPDATES: {
UPDATE_FIRMWARE: DESCRIPTION_UPDATE_FIRMWARE,
Expand Down

0 comments on commit a97ad48

Please sign in to comment.