Skip to content

Commit

Permalink
add utility meter tariff selection to daily energy sensor (#2099)
Browse files Browse the repository at this point in the history
* add utility meter tariff selection to daily energy sensor

* fix ruff
  • Loading branch information
bramstroker committed Mar 3, 2024
1 parent 7f9a6b6 commit cab08c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion custom_components/powercalc/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Platform,
UnitOfEnergy,
UnitOfPower,
UnitOfTime,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.data_entry_flow import FlowResult
Expand Down Expand Up @@ -123,14 +124,17 @@
): selector.NumberSelector(
selector.NumberSelectorConfig(
min=10,
unit_of_measurement="sec",
unit_of_measurement=UnitOfTime.SECONDS,
mode=selector.NumberSelectorMode.BOX,
),
),
vol.Optional(
CONF_CREATE_UTILITY_METERS,
default=False,
): selector.BooleanSelector(),
vol.Optional(CONF_UTILITY_METER_TARIFFS, default=[]): selector.SelectSelector(
selector.SelectSelectorConfig(options=[], custom_value=True, multiple=True),
),
},
)
SCHEMA_DAILY_ENERGY = vol.Schema(
Expand Down
6 changes: 4 additions & 2 deletions custom_components/powercalc/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"unit_of_measurement": "Unit of measurement",
"update_frequency": "Update frequency",
"value": "Value",
"value_template": "Value template"
"value_template": "Value template",
"utility_meter_tariffs": "Utility meter tariffs"
},
"data_description": {
"on_time": "When left empty defaults to 1 day. always on",
Expand Down Expand Up @@ -72,7 +73,8 @@
"group_member_sensors": "Powercalc sensors to include in the group",
"group_power_entities": "Additional power sensors (W) from your HA installation to include",
"sub_groups": "All containing sensors from the selected subgroups will be added to this group as well",
"include_non_powercalc_sensors": "Control whether to include non powercalc sensors when using the area option"
"include_non_powercalc_sensors": "Control whether to include non powercalc sensors when using the area option",
"utility_meter_tariffs": "A list of supported tariffs, leave empty if only a single tariff is needed."
},
"title": "Create a group sensor"
},
Expand Down
2 changes: 2 additions & 0 deletions tests/config_flow/test_daily_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CONF_ON_TIME,
CONF_SENSOR_TYPE,
CONF_UPDATE_FREQUENCY,
CONF_UTILITY_METER_TARIFFS,
CONF_VALUE,
)
from tests.config_flow.common import (
Expand Down Expand Up @@ -60,6 +61,7 @@ async def test_create_daily_energy_entry(hass: HomeAssistant) -> None:
CONF_UPDATE_FREQUENCY: 1800,
CONF_VALUE: 0.5,
CONF_UNIT_OF_MEASUREMENT: UnitOfPower.WATT,
CONF_UTILITY_METER_TARIFFS: [],
},
CONF_CREATE_UTILITY_METERS: False,
CONF_UNIQUE_ID: DEFAULT_UNIQUE_ID,
Expand Down

0 comments on commit cab08c9

Please sign in to comment.