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

Fix various linting issues #426

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions custom_components/myenergi/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from homeassistant.components.select import SelectEntity
from homeassistant.helpers import entity_platform
from pymyenergi.eddi import EDDI_MODES
from pymyenergi.zappi import CHARGE_MODES
from pymyenergi.libbi import LIBBI_MODES
from pymyenergi.libbi import LIBBI_MODE_NAMES
from pymyenergi.libbi import MODE_STOPPED
from pymyenergi.libbi import LIBBI_MODES
from pymyenergi.libbi import MODE_NORMAL
from pymyenergi.libbi import MODE_STOPPED
from pymyenergi.zappi import CHARGE_MODES

from .const import DOMAIN
from .entity import MyenergiEntity
Expand Down
40 changes: 20 additions & 20 deletions custom_components/myenergi/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from homeassistant.components.sensor import SensorEntity
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT
from homeassistant.components.sensor import STATE_CLASS_TOTAL_INCREASING
from homeassistant.const import DEVICE_CLASS_BATTERY
from homeassistant.const import DEVICE_CLASS_ENERGY
from homeassistant.const import DEVICE_CLASS_POWER
from homeassistant.const import DEVICE_CLASS_TEMPERATURE
from homeassistant.const import DEVICE_CLASS_VOLTAGE
from homeassistant.const import DEVICE_CLASS_BATTERY
from homeassistant.const import ELECTRIC_POTENTIAL_VOLT
from homeassistant.const import ENERGY_KILO_WATT_HOUR
from homeassistant.const import FREQUENCY_HERTZ
Expand All @@ -20,8 +20,8 @@
from pymyenergi import CT_LOAD
from pymyenergi import EDDI
from pymyenergi import HARVI
from pymyenergi import ZAPPI
from pymyenergi import LIBBI
from pymyenergi import ZAPPI

from .const import DOMAIN
from .entity import MyenergiEntity
Expand Down Expand Up @@ -497,7 +497,7 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"SoC",
"SoC",
"state_of_charge",
DEVICE_CLASS_BATTERY,
PERCENTAGE,
Expand All @@ -510,7 +510,7 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Voltage",
"Voltage",
"supply_voltage",
DEVICE_CLASS_VOLTAGE,
ELECTRIC_POTENTIAL_VOLT,
Expand All @@ -526,7 +526,7 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Frequency",
"Frequency",
"supply_frequency",
None,
FREQUENCY_HERTZ,
Expand All @@ -542,7 +542,7 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Inverter size",
"Inverter size",
"inverter_size",
None,
ENERGY_KILO_WATT_HOUR,
Expand All @@ -557,13 +557,13 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Battery size",
"Battery size",
"battery_size",
None,
ENERGY_KILO_WATT_HOUR,
ENTITY_CATEGORY_DIAGNOSTIC,
ICON_POWER,
)
),
)
)
sensors.append(
Expand All @@ -572,13 +572,13 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Status",
"Status",
"status",
None,
None,
None,
ICON_HOME_BATTERY,
)
),
)
)
sensors.append(
Expand All @@ -587,14 +587,14 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Grid import today",
"Grid import today",
"grid_import",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
),
)
)
sensors.append(
Expand All @@ -603,14 +603,14 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Grid export today",
"Grid export today",
"grid_export",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
),
)
)
sensors.append(
Expand All @@ -619,14 +619,14 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Battery charge today",
"Battery charge today",
"battery_charge",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
),
)
)
sensors.append(
Expand All @@ -635,14 +635,14 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Battery discharge today",
"Battery discharge today",
"battery_discharge",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
),
)
)
sensors.append(
Expand All @@ -651,14 +651,14 @@ async def async_setup_entry(hass, entry, async_add_devices):
device,
entry,
create_meta(
f"Solar generation today",
"Solar generation today",
"generated",
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
None,
None,
STATE_CLASS_TOTAL_INCREASING,
)
),
)
)
async_add_devices(sensors)
Expand Down
8 changes: 2 additions & 6 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,12 @@ async def test_setup_unload_and_reload_entry(hass, bypass_get_data):
# call, no code from custom_components/myenergi/api.py actually runs.
assert await async_setup_entry(hass, config_entry)
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
assert (
type(hass.data[DOMAIN][config_entry.entry_id]) == MyenergiDataUpdateCoordinator
)
assert hass.data[DOMAIN][config_entry.entry_id] is MyenergiDataUpdateCoordinator

# Reload the entry and assert that the data from above is still there
assert await async_reload_entry(hass, config_entry) is None
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
assert (
type(hass.data[DOMAIN][config_entry.entry_id]) == MyenergiDataUpdateCoordinator
)
assert hass.data[DOMAIN][config_entry.entry_id] is MyenergiDataUpdateCoordinator

# Unload the entry and verify that the data has been removed
assert await async_unload_entry(hass, config_entry)
Expand Down
Loading