Skip to content

Commit

Permalink
⬆️ Update Powercalc integration to v1.9.14
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasnicolaas committed Jan 2, 2024
1 parent d91edd0 commit 6decaa3
Show file tree
Hide file tree
Showing 31 changed files with 537 additions and 247 deletions.
9 changes: 8 additions & 1 deletion custom_components/powercalc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
DATA_CALCULATOR_FACTORY,
DATA_CONFIGURED_ENTITIES,
DATA_DISCOVERED_ENTITIES,
DATA_DISCOVERY_MANAGER,
DATA_DOMAIN_ENTITIES,
DATA_STANDBY_POWER_SENSORS,
DATA_USED_UNIQUE_IDS,
Expand All @@ -80,6 +81,7 @@
from .discovery import DiscoveryManager
from .sensor import SENSOR_CONFIG
from .sensors.group import (
get_entries_having_subgroup,
remove_group_from_power_sensor_entry,
remove_power_sensor_from_associated_groups,
)
Expand Down Expand Up @@ -209,8 +211,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
CONF_UTILITY_METER_TYPES: DEFAULT_UTILITY_METER_TYPES,
}

discovery_manager = DiscoveryManager(hass, config)
hass.data[DOMAIN] = {
DATA_CALCULATOR_FACTORY: PowerCalculatorStrategyFactory(hass),
DATA_DISCOVERY_MANAGER: DiscoveryManager(hass, config),
DOMAIN_CONFIG: domain_config,
DATA_CONFIGURED_ENTITIES: {},
DATA_DOMAIN_ENTITIES: {},
Expand All @@ -222,7 +226,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
await hass.async_add_executor_job(register_services, hass)

if domain_config.get(CONF_ENABLE_AUTODISCOVERY):
discovery_manager = DiscoveryManager(hass, config)
await discovery_manager.start_discovery()

await setup_yaml_sensors(hass, config, domain_config)
Expand Down Expand Up @@ -335,6 +338,10 @@ async def async_update_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Update a given config entry."""
await hass.config_entries.async_reload(entry.entry_id)

# Also reload all "parent" groups referring this group as a subgroup
for related_entry in await get_entries_having_subgroup(hass, entry):
await hass.config_entries.async_reload(related_entry.entry_id)


async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Unload a config entry."""
Expand Down
3 changes: 3 additions & 0 deletions custom_components/powercalc/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from homeassistant.config_entries import ConfigEntry, OptionsFlow
from homeassistant.const import (
CONF_ATTRIBUTE,
CONF_DEVICE,
CONF_ENTITY_ID,
CONF_NAME,
CONF_UNIQUE_ID,
Expand Down Expand Up @@ -262,6 +263,7 @@
{
vol.Required(CONF_NAME): str,
vol.Optional(CONF_UNIQUE_ID): selector.TextSelector(),
vol.Optional(CONF_DEVICE): selector.DeviceSelector(),
},
)

Expand Down Expand Up @@ -1026,6 +1028,7 @@ def _create_group_options_schema(
multiple=True,
),
vol.Optional(CONF_AREA): selector.AreaSelector(),
vol.Optional(CONF_DEVICE): selector.DeviceSelector(),
vol.Optional(
CONF_CREATE_UTILITY_METERS,
default=False,
Expand Down
6 changes: 5 additions & 1 deletion custom_components/powercalc/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
STATE_UNAVAILABLE,
)

MIN_HA_VERSION = "2022.11"
MIN_HA_VERSION = "2023.1"

DOMAIN = "powercalc"
DOMAIN_CONFIG = "config"

DATA_CALCULATOR_FACTORY = "calculator_factory"
DATA_CONFIGURED_ENTITIES = "configured_entities"
DATA_DISCOVERY_MANAGER = "discovery_manager"
DATA_DISCOVERED_ENTITIES = "discovered_entities"
DATA_DOMAIN_ENTITIES = "domain_entities"
DATA_USED_UNIQUE_IDS = "used_unique_ids"
Expand Down Expand Up @@ -100,6 +101,7 @@
CONF_VALUE_TEMPLATE = "value_template"
CONF_VOLTAGE = "voltage"
CONF_WLED = "wled"
CONF_WILDCARD = "wildcard"
CONF_STATES_POWER = "states_power"
CONF_START_TIME = "start_time"
CONF_STANDBY_POWER = "standby_power"
Expand All @@ -111,6 +113,8 @@
CONF_UTILITY_METER_OFFSET = "utility_meter_offset"
CONF_UTILITY_METER_TYPES = "utility_meter_types"
CONF_UTILITY_METER_TARIFFS = "utility_meter_tariffs"
CONF_OR = "or"
CONF_AND = "and"

# Redefine constants from integration component.
# Has been refactored in HA 2022.4, we need to support older HA versions as well.
Expand Down
14 changes: 14 additions & 0 deletions custom_components/powercalc/data/aqara/lumi.plug.maeu01/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"measure_description": "Manually measured. Pictures in the Pull Request comments.",
"measure_method": "manual",
"measure_device": "Zhurui PR10",
"name": "Aqara Smart Plug",
"standby_power": 0.17,
"standby_power_on": 0.46,
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
},
"device_type": "smart_switch",
"calculation_strategy": "fixed"
}
16 changes: 16 additions & 0 deletions custom_components/powercalc/data/avm/FRITZ!DECT 210/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"measure_description": "Manually measured.",
"measure_method": "manual",
"measure_device": "Shelly Plus Plug S / AVM FRITZ!DECT 200",
"name": "AVM Fritz!DECT 210",
"standby_power": 0.35,
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
},
"device_type": "smart_switch",
"calculation_strategy": "fixed",
"fixed_config": {
"power": 1.10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"measure_description": "Manually measured",
"measure_method": "manual",
"measure_device": "Shelly Plus Plug S / AVM FRITZ!DECT 200",
"name": "FRITZ!Repeater 1750E",
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
},
"device_type": "network",
"calculation_strategy": "fixed",
"fixed_config": {
"power": 3.15
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"measure_description": "Manually measured",
"measure_method": "manual",
"measure_device": "Shelly Plus Plug S",
"name": "FRITZ!Repeater 2400",
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
},
"device_type": "network",
"calculation_strategy": "fixed",
"fixed_config": {
"power": 3.15
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions custom_components/powercalc/data/govee/H6076/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"calculation_strategy": "lut",
"measure_description": "Measured with utils/measure script",
"measure_device": "TP-Link, P110",
"measure_method": "script",
"measure_settings": {
"SAMPLE_COUNT": 2,
"SLEEP_TIME": 30,
"VERSION": "v1.9.8:docker"
},
"name": "Govee RGBICW Smart Corner Floor Lamp",
"standby_power": 2.14
}
Binary file not shown.
13 changes: 13 additions & 0 deletions custom_components/powercalc/data/ikea/LED2201G8/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"calculation_strategy": "lut",
"measure_description": "Measured with utils/measure script",
"measure_device": "TP-Link HS110",
"measure_method": "script",
"measure_settings": {
"SAMPLE_COUNT": 2,
"SLEEP_TIME": 6,
"VERSION": "v1.9.11:docker"
},
"name": "TR\u00c5DFRI LED bulb E27 1055 lumen, smart wireless dimmable/white spectrum globe",
"standby_power": 0.19
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"measure_description": "Manually measured. Transcribed from https://github.com/bramstroker/homeassistant-powercalc/discussions/207#discussioncomment-1484985",
"measure_method": "manual",
"measure_device": "Shelly Plug S",
"measure_device": "Zhurui PR10",
"name": "TRADFRI control outlet",
"standby_power": 0.4,
"standby_power_on": 0.8,
"standby_power": 0.23,
"standby_power_on": 0.98,
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
Expand Down
Binary file not shown.
13 changes: 13 additions & 0 deletions custom_components/powercalc/data/innr/RB 266/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"calculation_strategy": "lut",
"measure_description": "Measured with utils/measure script",
"measure_device": "Shelly, PlusPlugS",
"measure_method": "script",
"measure_settings": {
"SAMPLE_COUNT": 4,
"SLEEP_TIME": 3,
"VERSION": "v1.9.10:docker"
},
"name": "RB 266 Smart Bulb White E27 780lm (2700K)",
"standby_power": 0.31
}
19 changes: 19 additions & 0 deletions custom_components/powercalc/data/innr/SP 220/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"measure_description": "Manually measured",
"measure_method": "manual",
"measure_device": "Shelly Plus Plug S / AVM FRITZ!DECT 200",
"name": "Innr Zigbee Smart Plug SP220",
"standby_power": 0.50,
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
},
"device_type": "smart_switch",
"calculation_strategy": "fixed",
"fixed_config": {
"power": 1.25
},
"aliases": [
"On/Off plug (SP 220)"
]
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"neo-coolcam": ["smart_switch"], "zemismart": ["light"], "zengge": ["light"], "qubino": ["smart_switch"], "elgato": ["light"], "3a smarthome": ["light"], "sonoff": ["smart_switch", "light"], "rye": ["light"], "signify": ["light", "smart_switch"], "apple": ["smart_speaker"], "everspring": ["smart_switch"], "greenwave": ["smart_switch"], "ge": ["light"], "mueller-licht": ["light"], "oz smart things": ["light"], "aqara": ["light"], "ledvance": ["light"], "denon": ["smart_speaker"], "govee": ["light"], "lenovo": ["smart_speaker"], "genio": ["light"], "meross": ["light"], "ikea": ["light", "smart_switch"], "athom": ["light"], "melitec": ["light"], "sonos": ["smart_speaker"], "ajax online": ["light"], "yeelight": ["light"], "paulmann licht": ["light"], "arlec": ["smart_switch", "light"], "lidl": ["light"], "zipato": ["light"], "trust": ["light"], "fibaro": ["smart_switch"], "tp-link": ["light", "smart_switch"], "lifx": ["light"], "harman kardon": ["smart_speaker"], "blitzwolf": ["smart_switch"], "lexman": ["light"], "belkin": ["light"], "ynoa": ["light"], "google": ["smart_speaker"], "teckin": ["light"], "anko": ["light"], "linkind": ["light"], "bosch": ["smart_switch"], "innr": ["light", "smart_switch"], "amazon": ["smart_speaker"], "nous": ["smart_switch"], "cree": ["light"], "tuya": ["light", "smart_switch"], "wiz": ["light"], "osram": ["light", "smart_switch"], "avm": ["smart_switch", "light", "network"], "gledopto": ["light"], "shelly": ["smart_switch"], "nodon": ["smart_switch"], "eufy": ["camera"], "malmbergs": ["light"], "bose": ["smart_speaker"]}
{"paulmann licht": ["light"], "greenwave": ["smart_switch"], "cree": ["light"], "neo-coolcam": ["smart_switch"], "zipato": ["light"], "lexman": ["light"], "teckin": ["light"], "ynoa": ["light"], "melitec": ["light"], "elgato": ["light"], "tp-link": ["light", "smart_switch"], "fibaro": ["smart_switch"], "wiz": ["light"], "osram": ["light", "smart_switch"], "meross": ["light"], "athom": ["light"], "aqara": ["smart_switch", "light"], "denon": ["smart_speaker"], "rye": ["light"], "malmbergs": ["light"], "bosch": ["smart_switch"], "ge": ["light"], "blitzwolf": ["smart_switch"], "apple": ["smart_speaker"], "bose": ["smart_speaker"], "zemismart": ["light"], "ledvance": ["light"], "belkin": ["light"], "arlec": ["smart_switch", "light"], "amazon": ["smart_speaker"], "lenovo": ["smart_speaker"], "gledopto": ["light"], "ajax online": ["light"], "tuya": ["light", "smart_switch"], "trust": ["light"], "nodon": ["smart_switch"], "anko": ["light"], "shelly": ["smart_switch"], "signify": ["light", "smart_switch"], "avm": ["network", "smart_switch", "light"], "lidl": ["light"], "nous": ["smart_switch"], "everspring": ["smart_switch"], "zengge": ["light"], "eufy": ["camera"], "linkind": ["light"], "lifx": ["light"], "3a smarthome": ["light"], "innr": ["light", "smart_switch"], "sonos": ["smart_speaker"], "harman kardon": ["smart_speaker"], "oz smart things": ["light"], "qubino": ["smart_switch"], "genio": ["light"], "ikea": ["light", "smart_switch"], "govee": ["light"], "google": ["smart_speaker"], "yeelight": ["light"], "mueller-licht": ["light"], "tasmota": ["smart_switch"], "sonoff": ["smart_switch", "light"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"measure_description": "Manually measured.",
"measure_method": "manual",
"measure_device": "AVM FRITZ!DECT 200",
"name": "Shelly Plus Plug S",
"standby_power": 0.8,
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
},
"device_type": "smart_switch",
"calculation_strategy": "fixed",
"fixed_config": {
"power": 1.1
}
}
16 changes: 16 additions & 0 deletions custom_components/powercalc/data/tasmota/shelly plug s/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"measure_description": "Manually measured. Copy from Shelly Plug S",
"measure_method": "manual",
"measure_device": "Zhurui PR10-D",
"name": "Shelly Plug S",
"standby_power": 0.52,
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
},
"device_type": "smart_switch",
"calculation_strategy": "fixed",
"fixed_config": {
"power": 0.82
}
}
Loading

0 comments on commit 6decaa3

Please sign in to comment.