Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #51 from DCSBL/feature/gas-dashboard
Browse files Browse the repository at this point in the history
Add support for 'Gas' in Energy Dashboard
  • Loading branch information
DCSBL authored Sep 1, 2021
2 parents a4e747a + def53d1 commit 1403fae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions custom_components/homewizard_energy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"zeroconf"
],
"requirements": [
"aiohwenergy==0.2.3"
"aiohwenergy==0.3.2"
],
"zeroconf": [
"_hwenergy._tcp.local."
],
"config_flow": true,
"iot_class": "local_polling"
}
}
37 changes: 18 additions & 19 deletions custom_components/homewizard_energy/sensor.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
"""Creates Homewizard Energy sensor entities."""
from __future__ import annotations

import asyncio
import logging
from typing import Any, Final

import aiohwenergy
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.const import (
CONF_ID,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_GAS,
DEVICE_CLASS_POWER,
DEVICE_CLASS_SIGNAL_STRENGTH,
DEVICE_CLASS_TIMESTAMP,
Expand All @@ -24,7 +25,6 @@
)
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util.dt import utc_from_timestamp

from .const import (
ATTR_ACTIVE_POWER_L1_W,
Expand Down Expand Up @@ -66,86 +66,86 @@
key=ATTR_WIFI_SSID,
name="Wifi SSID",
icon="mdi:wifi",
unit_of_measurement="",
),
SensorEntityDescription(
key=ATTR_WIFI_STRENGTH,
name="Wifi Strength",
icon="mdi:wifi",
unit_of_measurement=PERCENTAGE,
native_unit_of_measurement=PERCENTAGE,
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=ATTR_TOTAL_POWER_IMPORT_T1_KWH,
name="Total power import T1",
icon="mdi:home-import-outline",
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_MEASUREMENT,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key=ATTR_TOTAL_POWER_IMPORT_T2_KWH,
name="Total power import T2",
icon="mdi:home-import-outline",
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_MEASUREMENT,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key=ATTR_TOTAL_POWER_EXPORT_T1_KWH,
name="Total power export T1",
icon="mdi:home-export-outline",
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_MEASUREMENT,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key=ATTR_TOTAL_POWER_EXPORT_T2_KWH,
name="Total power export T2",
icon="mdi:home-export-outline",
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_MEASUREMENT,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key=ATTR_ACTIVE_POWER_W,
name="Active power",
icon="mdi:transmission-tower",
unit_of_measurement=POWER_WATT,
native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=ATTR_ACTIVE_POWER_L1_W,
name="Active power L1",
icon="mdi:transmission-tower",
unit_of_measurement=POWER_WATT,
native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=ATTR_ACTIVE_POWER_L2_W,
name="Active power L2",
icon="mdi:transmission-tower",
unit_of_measurement=POWER_WATT,
native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=ATTR_ACTIVE_POWER_L3_W,
name="Active power L3",
icon="mdi:transmission-tower",
unit_of_measurement=POWER_WATT,
native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=ATTR_TOTAL_GAS_M3,
name="Total gas",
icon="mdi:fire",
unit_of_measurement=VOLUME_CUBIC_METERS,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=VOLUME_CUBIC_METERS,
device_class=DEVICE_CLASS_GAS,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key=ATTR_GAS_TIMESTAMP,
Expand Down Expand Up @@ -197,7 +197,6 @@ def __init__(self, coordinator, entry_data, description):
self.name = "%s %s" % (entry_data["custom_name"], description.name)
self.data_type = description.key
self.unique_id = "%s_%s" % (entry_data["unique_id"], description.key)
self._attr_last_reset = utc_from_timestamp(0)

# Some values are given, but set to NULL (eg. gas_timestamp when no gas meter is connected)
if self.data[CONF_DATA][self.data_type] is None:
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "HomeWizard Energy",
"render_readme": true,
"domains": ["sensor", "switch"],
"homeassistant": "2021.8.0",
"homeassistant": "2021.9.0b7",
"iot_class": "local_polling",
"zip_release": true,
"filename": "homewizard_energy.zip"
Expand Down

0 comments on commit 1403fae

Please sign in to comment.