-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Deprecate min_max and migrate to group sensor #167718
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
Draft
gjohansson-ST
wants to merge
33
commits into
dev
Choose a base branch
from
gj-20260408-02
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
564280c
Deprecate min_max and migrate to group sensor
gjohansson-ST 5bbfe69
import
gjohansson-ST 7288d19
Mods
gjohansson-ST 6e92ba2
Mods
gjohansson-ST 26d8dfb
Mods
gjohansson-ST d4fca37
Mods
gjohansson-ST 49ce8ed
Mods
gjohansson-ST f821952
Test
gjohansson-ST d25f3c6
Delete
gjohansson-ST f006283
Mods
gjohansson-ST 44b0717
Mods
gjohansson-ST 7f1846b
comments
gjohansson-ST 6d4f5a4
Mods to repair flow
gjohansson-ST d037f33
Fix config flow
gjohansson-ST 983df39
Fixes
gjohansson-ST 787929f
Mods
gjohansson-ST 46a05e4
mod
gjohansson-ST 379c0b1
Fixes
gjohansson-ST 3f69014
strings
gjohansson-ST 00e8a6c
Fix string
gjohansson-ST 9fd0f99
Fix flow
gjohansson-ST e131b21
async_config_entry_title
gjohansson-ST 5079709
Mods
gjohansson-ST 80733a2
Handle missing entity
gjohansson-ST f4bccbb
fix yaml description
gjohansson-ST d8b23df
Mods
gjohansson-ST ee9326d
Somewhat stable id
gjohansson-ST 2e1c4e0
Remove from future
gjohansson-ST fbda661
Restore options flow test
gjohansson-ST 7c6ff3f
Fix review comments
gjohansson-ST 30176c6
Remove issue on config entry removal
gjohansson-ST 9634953
Fixes
gjohansson-ST aad7b6c
docstring
gjohansson-ST File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| { | ||
| "group": { | ||
| "created_at": "2026-04-10T14:33:19.033744+00:00", | ||
| "data": {}, | ||
| "disabled_by": null, | ||
| "discovery_keys": {}, | ||
| "domain": "group", | ||
| "entry_id": "01KNVWZHXSVPAZD4DGFF8TN94Z", | ||
| "minor_version": 1, | ||
| "modified_at": "2026-04-10T14:33:19.033750+00:00", | ||
| "options": { | ||
| "entities": ["sensor.carbon_dioxide", "sensor.carbon_monoxide"], | ||
| "group_type": "sensor", | ||
| "hide_members": false, | ||
| "ignore_non_numeric": false, | ||
| "name": "Olle", | ||
| "round_digits": 2.0, | ||
| "type": "min" | ||
| }, | ||
| "pref_disable_new_entities": false, | ||
| "pref_disable_polling": false, | ||
| "source": "import", | ||
| "subentries": [], | ||
| "title": "Olle", | ||
| "unique_id": null, | ||
| "version": 1 | ||
| }, | ||
| "min_max": { | ||
| "created_at": "2026-04-10T14:13:58.312444+00:00", | ||
| "data": {}, | ||
| "disabled_by": null, | ||
| "discovery_keys": {}, | ||
| "domain": "min_max", | ||
| "entry_id": "01KNVVW4D8NK8ARQF8GCH7CD5A", | ||
| "minor_version": 1, | ||
| "modified_at": "2026-04-10T14:33:19.073168+00:00", | ||
| "options": { | ||
| "entity_ids": ["sensor.carbon_dioxide", "sensor.carbon_monoxide"], | ||
| "name": "Olle", | ||
| "round_digits": 2.0, | ||
| "type": "min" | ||
| }, | ||
| "pref_disable_new_entities": false, | ||
| "pref_disable_polling": false, | ||
| "source": "user", | ||
| "subentries": [], | ||
| "title": "Olle", | ||
| "unique_id": null, | ||
| "version": 2 | ||
| } | ||
| } | ||
|
gjohansson-ST marked this conversation as resolved.
Outdated
gjohansson-ST marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,33 +9,33 @@ | |
|
|
||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.components.group import CONF_ENTITIES | ||
| from homeassistant.components.sensor import ( | ||
|
gjohansson-ST marked this conversation as resolved.
|
||
| PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA, | ||
| SensorDeviceClass, | ||
| SensorEntity, | ||
| SensorStateClass, | ||
| ) | ||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.const import ( | ||
| ATTR_ENTITY_ID, | ||
| ATTR_UNIT_OF_MEASUREMENT, | ||
| CONF_NAME, | ||
| CONF_PLATFORM, | ||
| CONF_TYPE, | ||
| CONF_UNIQUE_ID, | ||
| STATE_UNAVAILABLE, | ||
| STATE_UNKNOWN, | ||
| ) | ||
| from homeassistant.core import Event, EventStateChangedData, HomeAssistant, callback | ||
| from homeassistant.exceptions import HomeAssistantError | ||
| from homeassistant.helpers import config_validation as cv, entity_registry as er | ||
| from homeassistant.helpers import config_validation as cv | ||
| from homeassistant.helpers.entity import get_device_class | ||
| from homeassistant.helpers.entity_platform import ( | ||
| AddConfigEntryEntitiesCallback, | ||
| AddEntitiesCallback, | ||
| ) | ||
| from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||
| from homeassistant.helpers.event import async_track_state_change_event | ||
| from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue | ||
| from homeassistant.helpers.reload import async_setup_reload_service | ||
| from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType | ||
| from homeassistant.util import ulid as ulid_util, yaml as yaml_util | ||
|
|
||
| from . import PLATFORMS | ||
| from .const import CONF_ENTITY_IDS, CONF_ROUND_DIGITS, DOMAIN | ||
|
|
@@ -53,6 +53,7 @@ | |
| ATTR_RANGE = "range" | ||
| ATTR_SUM = "sum" | ||
|
|
||
|
|
||
| ICON = "mdi:calculator" | ||
|
|
||
| SENSOR_TYPES = { | ||
|
|
@@ -79,29 +80,27 @@ | |
| ) | ||
|
|
||
|
|
||
| async def async_setup_entry( | ||
| hass: HomeAssistant, | ||
| config_entry: ConfigEntry, | ||
| async_add_entities: AddConfigEntryEntitiesCallback, | ||
| ) -> None: | ||
| """Initialize min/max/mean config entry.""" | ||
| registry = er.async_get(hass) | ||
| entity_ids = er.async_validate_entity_ids( | ||
| registry, config_entry.options[CONF_ENTITY_IDS] | ||
| ) | ||
| sensor_type = config_entry.options[CONF_TYPE] | ||
| round_digits = int(config_entry.options[CONF_ROUND_DIGITS]) | ||
|
|
||
| async_add_entities( | ||
| [ | ||
| MinMaxSensor( | ||
| entity_ids, | ||
| config_entry.title, | ||
| sensor_type, | ||
| round_digits, | ||
| config_entry.entry_id, | ||
| ) | ||
| ] | ||
| async def yaml_deprecation_notice(hass: HomeAssistant, config: ConfigType) -> None: | ||
| """Raise repair issue for YAML configuration deprecation.""" | ||
| platform_config = config.copy() | ||
| platform_config[CONF_ENTITIES] = platform_config.pop(CONF_ENTITY_IDS) | ||
| platform_config.pop(CONF_ROUND_DIGITS) | ||
|
gjohansson-ST marked this conversation as resolved.
|
||
| platform_config.pop(CONF_PLATFORM) | ||
| if CONF_NAME not in platform_config: | ||
| platform_config[CONF_NAME] = f"{platform_config[CONF_TYPE]} sensor".capitalize() | ||
| yaml_config = yaml_util.dump(platform_config) | ||
| yaml_config = yaml_config.replace("\n", "\n ") | ||
| yaml_config = "```yaml\nsensor:\n - platform: group\n " + yaml_config + "\n```" | ||
|
Comment on lines
+117
to
+125
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above |
||
| async_create_issue( | ||
| hass, | ||
| DOMAIN, | ||
| ulid_util.ulid(), | ||
| breaks_in_ha_version="2026.12.0", | ||
|
gjohansson-ST marked this conversation as resolved.
|
||
| is_fixable=False, | ||
| severity=IssueSeverity.WARNING, | ||
| learn_more_url="https://www.home-assistant.io/integrations/group/", | ||
| translation_key="yaml_deprecated", | ||
| translation_placeholders={"yaml_config": yaml_config}, | ||
| ) | ||
|
gjohansson-ST marked this conversation as resolved.
gjohansson-ST marked this conversation as resolved.
gjohansson-ST marked this conversation as resolved.
gjohansson-ST marked this conversation as resolved.
|
||
|
|
||
|
|
||
|
|
@@ -119,6 +118,7 @@ async def async_setup_platform( | |
| unique_id = config.get(CONF_UNIQUE_ID) | ||
|
|
||
| await async_setup_reload_service(hass, DOMAIN, PLATFORMS) | ||
| await yaml_deprecation_notice(hass, config) | ||
|
|
||
| async_add_entities( | ||
| [MinMaxSensor(entity_ids, name, sensor_type, round_digits, unique_id)] | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.