diff --git a/custom_components/myenergi/manifest.json b/custom_components/myenergi/manifest.json index eab50d8..74473df 100644 --- a/custom_components/myenergi/manifest.json +++ b/custom_components/myenergi/manifest.json @@ -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"] } diff --git a/custom_components/myenergi/sensor.py b/custom_components/myenergi/sensor.py index 1190e19..71a735f 100644 --- a/custom_components/myenergi/sensor.py +++ b/custom_components/myenergi/sensor.py @@ -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 @@ -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 ): @@ -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,