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

Refactored to use new Revenue function from EIB/PyCheckwatt #53

Merged
merged 9 commits into from
Jan 27, 2024
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
261 changes: 111 additions & 150 deletions custom_components/checkwatt/__init__.py

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions custom_components/checkwatt/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Config flow for CheckWatt integration."""

from __future__ import annotations

import logging
Expand All @@ -15,8 +16,8 @@

from .const import (
CONF_CM10_SENSOR,
CONF_DETAILED_ATTRIBUTES,
CONF_DETAILED_SENSORS,
CONF_CWR_NAME,
CONF_POWER_SENSORS,
CONF_PUSH_CW_TO_RANK,
DOMAIN,
)
Expand Down Expand Up @@ -76,10 +77,10 @@ async def async_step_user(
title=CONF_TITLE,
data=self.data,
options={
CONF_DETAILED_SENSORS: False,
CONF_DETAILED_ATTRIBUTES: False,
CONF_POWER_SENSORS: False,
CONF_PUSH_CW_TO_RANK: False,
CONF_CM10_SENSOR: False,
CONF_CM10_SENSOR: True,
CONF_CWR_NAME: "",
},
)

Expand Down Expand Up @@ -115,12 +116,8 @@ async def async_step_init(
data_schema=vol.Schema(
{
vol.Required(
CONF_DETAILED_SENSORS,
default=self.config_entry.options.get(CONF_DETAILED_SENSORS),
): bool,
vol.Required(
CONF_DETAILED_ATTRIBUTES,
default=self.config_entry.options.get(CONF_DETAILED_ATTRIBUTES),
CONF_POWER_SENSORS,
default=self.config_entry.options.get(CONF_POWER_SENSORS),
): bool,
vol.Required(
CONF_PUSH_CW_TO_RANK,
Expand All @@ -130,6 +127,10 @@ async def async_step_init(
CONF_CM10_SENSOR,
default=self.config_entry.options.get(CONF_CM10_SENSOR),
): bool,
vol.Optional(
CONF_CWR_NAME,
default=self.config_entry.options.get(CONF_CWR_NAME),
): str,
}
),
)
Expand Down
26 changes: 8 additions & 18 deletions custom_components/checkwatt/const.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"""Constants for the CheckWatt integration."""

from typing import Final

DOMAIN = "checkwatt"
INTEGRATION_NAME = "ha-checkwatt"

# Update interval for regular sensors is once every minute
# For FCR-D since it is slow and resource consuming, is set to once per 15 minute
CONF_UPDATE_INTERVAL = 1
CONF_UPDATE_INTERVAL_FCRD = 15
CONF_UPDATE_INTERVAL_ALL = 1
CONF_UPDATE_INTERVAL_MONETARY = 15
ATTRIBUTION = "Data provided by CheckWatt EnergyInBalance"
MANUFACTURER = "CheckWatt"
CHECKWATT_MODEL = "CheckWatt"

CONF_DETAILED_SENSORS: Final = "show_details"
CONF_DETAILED_ATTRIBUTES: Final = "show_detailed_attributes"
CONF_POWER_SENSORS: Final = "show_details"
CONF_PUSH_CW_TO_RANK: Final = "push_to_cw_rank"
CONF_CM10_SENSOR = "cm10_sensor"
CONF_CM10_SENSOR: Final = "cm10_sensor"
CONF_CWR_NAME: Final = "cwr_name"

# Misc
P_UNKNOWN = "Unknown"
Expand All @@ -27,30 +27,21 @@
# NOTE Keep these names aligned with strings.json
#
C_ADR = "street_address"
C_ANNUAL_FEES = "annual_fees"
C_ANNUAL_FEE_RATE = "annual_fee_rate"
C_ANNUAL_GROSS = "annual_gross_income"
C_BATTERY_POWER = "battery_power"
C_CHARGE_PEAK = "charge_peak"
C_CITY = "city"
C_CM10_VERSION = "cm10_version"
C_DISCHARGE_PEAK = "discharge_peak"
C_DAILY_AVERAGE = "daily_average"
C_DISPLAY_NAME = "display_name"
C_DSO = "dso"
C_GRID_POWER = "grid_power"
C_ENERGY_PROVIDER = "energy_provider"
C_FCRD_DATE = "fcr_d_date"
C_FCRD_INFO = "fcr_d_info"
C_FCRD_STATUS = "fcr_d_status"
C_MONTH_ESITIMATE = "month_estimate"
C_NEXT_UPDATE_TIME = "next_update"
C_PRICE_ZONE = "price_zone"
C_SOLAR_POWER = "solar_power"
C_TODAY_FEES = "today_fees"
C_TODAY_FEE_RATE = "today_fees_rate"
C_TODAY_GROSS = "today_gross_income"
C_TOMORROW_FEES = "tomorrow_fees"
C_TOMORROW_FEE_RATE = "tomorrow_fee_rate"
C_TOMORROW_GROSS = "tomorrow_gross_income"
C_TOMORROW_NET = "tomorrow_net_income"
C_UPDATE_TIME = "last_update"
C_VAT = "vat"
Expand All @@ -60,6 +51,5 @@
C_DISCHARGE_PEAK_AC = "discharge_peak_ac"
C_DISCHARGE_PEAK_DC = "discharge_peak_dc"


# CheckWatt Event Signals
EVENT_SIGNAL_FCRD = "fcrd"
3 changes: 2 additions & 1 deletion custom_components/checkwatt/event.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Events for Withings."""
"""Events for CheckWatt."""

from __future__ import annotations

import logging
Expand Down
4 changes: 2 additions & 2 deletions custom_components/checkwatt/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"homekit": {},
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/faanskit/ha-checkwatt/issues",
"requirements": ["pycheckwatt>=0.1.10", "aiohttp>=3.9.1"],
"requirements": ["pycheckwatt>=0.2.0", "aiohttp>=3.9.1"],
"ssdp": [],
"version": "0.1.7",
"version": "0.2.0",
"zeroconf": []
}
Loading
Loading