Skip to content

Commit

Permalink
Added voltage_grid and frequency_grid sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
CJNE committed Sep 13, 2021
1 parent 60ce57e commit 449fc75
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/myenergi/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"domain": "myenergi",
"name": "myenergi",
"version": "0.0.11",
"version": "0.0.12",
"documentation": "https://github.com/cjne/ha-myenergi",
"issue_tracker": "https://github.com/cjne/ha-myenergi/issues",
"dependencies": [],
"config_flow": true,
"codeowners": ["@cjne"],
"iot_class": "cloud_polling",
"requirements": ["pymyenergi==0.0.14"]
"requirements": ["pymyenergi==0.0.15"]
}
35 changes: 35 additions & 0 deletions custom_components/myenergi/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
from homeassistant.components.sensor import STATE_CLASS_TOTAL_INCREASING
from homeassistant.const import DEVICE_CLASS_ENERGY
from homeassistant.const import DEVICE_CLASS_POWER
from homeassistant.const import DEVICE_CLASS_VOLTAGE
from homeassistant.const import ELECTRIC_POTENTIAL_VOLT
from homeassistant.const import ENERGY_KILO_WATT_HOUR
from homeassistant.const import FREQUENCY_HERTZ
from homeassistant.const import POWER_WATT
from pymyenergi import CT_BATTERY
from pymyenergi import CT_LOAD
Expand All @@ -16,6 +19,10 @@
from .entity import MyenergiHub


ICON_VOLT = "mdi:lightning-bolt"
ICON_FREQ = "mdi:sine-wave"


def create_meta(
name, prop_name, device_class=None, unit=None, icon=None, state_class=None
):
Expand Down Expand Up @@ -71,6 +78,34 @@ async def async_setup_entry(hass, entry, async_add_devices):
),
)
)
sensors.append(
MyenergiHubSensor(
coordinator,
entry,
create_meta(
"Voltage grid",
"voltage_grid",
DEVICE_CLASS_VOLTAGE,
ELECTRIC_POTENTIAL_VOLT,
ICON_VOLT,
STATE_CLASS_MEASUREMENT,
),
)
)
sensors.append(
MyenergiHubSensor(
coordinator,
entry,
create_meta(
"Frequency grid",
"frequency_grid",
None,
FREQUENCY_HERTZ,
ICON_FREQ,
STATE_CLASS_MEASUREMENT,
),
)
)
sensors.append(
MyenergiHubSensor(
coordinator,
Expand Down

0 comments on commit 449fc75

Please sign in to comment.