Commit Graph
101 Commits
Author SHA1 Message Date
Erik MontnemeryandGitHub 120338d510 Handle changes to source entity in utility_meter (#146526) 2025-06-11 15:17:52 +02:00
Simone ChemelliandGitHub 484a547758 Fix pylance warning on SnapshotAssertion import (#145206) 2025-05-19 13:55:48 +02:00
epenetandGitHub a3605921c9 De-duplicate test helper function (#143437)
* De-duplicate test helper function

* One more
2025-04-22 12:04:12 +02:00
694c768666 Fix utility_meter wrong/old value on reset (#142951)
Co-authored-by: Erwin Douna <[email protected]>
Co-authored-by: Abílio Costa <[email protected]>
2025-04-21 12:45:57 +01:00
4b34d1bbb5 Merge config subentry feature branch to dev (#136121)
* Reapply "Add support for subentries to config entries" (#133470) (#136061)

* Reapply "Add support for subentries to config entries" (#133470)

This reverts commit ecb3bf79f3.

* Update test snapshot

* Add config subentry support to device registry (#128157)

* Add config subentry support to device registry

* Apply suggestions from code review

* Update syrupy serializer

* Update snapshots

* Address review comments

* Allow a device to be connected to no or a single subentry of a config entry

* Update snapshots

* Revert "Allow a device to be connected to no or a single subentry of a config entry"

This reverts commit ec6f613151cb4a806b7961033c004b71b76510c2.

* Update test snapshots

* Bump release version in comments

* Rename config_subentries to config_entries_subentries

* Add config subentry support to entity registry (#128155)

* Add config subentry support to entity registry

* Update syrupy serializer

* Update snapshots

* Update snapshots

* Accept suggested changes

* Clean registries when removing subentry (#136671)

* Clean up registries when removing subentry

* Update tests

* Clean up subentries from deleted devices when removing config entry (#136669)

* Clean up subentries from deleted devices when removing config entry

* Move

* Add config subentry support to entity platform (#128161)

* Add config subentry support to entity platform

* Rename subentry_id to config_subentry_id

* Store subentry type in subentry (#136687)

* Add reconfigure support to config subentries (#133353)

* Add reconfigure support to config subentries

* Update test

* Minor adjustment

* Rename supported_subentry_flows to supported_subentry_types

* Address review comments

* Add subentry support to kitchen sink (#136755)

* Add subentry support to kitchen sink

* Add subentry reconfigure support to kitchen_sink

* Update kitchen_sink tests with subentry type stored in config entry

* Update kitchen_sink

* Update kitchen_sink

* Adjust kitchen sink tests

* Fix hassfest

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <[email protected]>

* Improve docstrings and strings.json

---------

Co-authored-by: Martin Hjelmare <[email protected]>

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

---------

Co-authored-by: Martin Hjelmare <[email protected]>
2025-02-10 16:40:07 +01:00
epenetandGitHub d0a188b86d Standardize homeassistant imports in component tests (m-z) (#136807) 2025-01-29 08:57:57 +01:00
Erik MontnemeryandGitHub 235fda55fe Validate config entry when adding or updating entity registry entry (#135067) 2025-01-17 19:18:13 +01:00
Erik MontnemeryandGitHub ecb3bf79f3 Revert "Add support for subentries to config entries" (#133470)
Revert "Add support for subentries to config entries (#117355)"

This reverts commit ad15786115.
2024-12-18 13:51:05 +01:00
Erik MontnemeryandGitHub ad15786115 Add support for subentries to config entries (#117355)
* Add support for subentries to config entries

* Improve error handling and test coverage

* Include subentry_id in subentry containers

* Auto-generate subentry_id and add optional unique_id

* Tweak

* Update tests

* Fix stale docstring

* Address review comments

* Typing tweaks

* Add methods to ConfigEntries to add and remove subentry

* Improve ConfigSubentryData typed dict

* Update test snapshots

* Adjust tests

* Fix unique_id logic

* Allow multiple subentries with None unique_id

* Add number of subentries to config entry JSON representation

* Add subentry translation support

* Allow integrations to implement multiple subentry flows

* Update translations schema

* Adjust exception text

* Change subentry flow init step to user

* Prevent creating a subentry with colliding unique_id

* Update tests

* Address review comments

* Remove duplicaetd unique_id collision check

* Remove change from the future

* Improve test coverage

* Add default value for unique_id
2024-12-12 20:16:18 +01:00
345c1fe0b2 Have Utility Meter monitor Timezone changes in configuration (#131112)
* listen to config changes for possible DST changes

* Add test

* check tz actually changed

* Update tests/components/utility_meter/test_sensor.py

Co-authored-by: Abílio Costa <[email protected]>

* Update tests/components/utility_meter/test_sensor.py

Co-authored-by: Abílio Costa <[email protected]>

* Clean up comment

---------

Co-authored-by: Abílio Costa <[email protected]>
Co-authored-by: Martin Hjelmare <[email protected]>
2024-11-27 12:12:45 +01:00
epenetandGitHub aea8e8abac Fix missing translations in utility_meter (#130652) 2024-11-14 22:42:01 -05:00
9f7e6048f8 Code quality improvements on utility_meter (#129918)
* clean

* update snapshot

* move name, native_value and native_unit_of_measurement to _attr's

* Apply suggestions from code review

Co-authored-by: epenet <[email protected]>

---------

Co-authored-by: epenet <[email protected]>
2024-11-09 00:17:43 +01:00
e4aaaf10c3 Fix utility_meter on DST changes (#129862)
Co-authored-by: epenet <[email protected]>
2024-11-08 18:44:15 +01:00
Diogo GomesandGitHub 83a1b06b56 Set friendly name of utility meter select entity when configured through YAML (#128267)
* set select friendly name in YAML

* backward compatibility added

* clean

* cleaner backward compatibility approach

* don't introduce default unique_id

* split test according to review
2024-11-05 19:59:43 +01:00
epenetandGitHub 0bc572787a Add check for valid error code in translation checks in flows (#128445) 2024-10-16 19:03:24 +02:00
d82bff1bc2 Index config entry discovery_keys by discovery domain (#126563)
* Index config entry discovery_keys by discovery domain

* Add new signal

* Update tests

* Update homeassistant/config_entries.py

Co-authored-by: J. Nick Koston <[email protected]>

* Fix imports

---------

Co-authored-by: J. Nick Koston <[email protected]>
2024-09-23 21:48:11 +02:00
b2982c18bb Reinitialize zeroconf discovery flow on unignore (#125753)
* Reinitialize zeroconf discovery flow on unignore

* Adjust tests

* Improve comments

* Fix logic for updating discovery keys

* Add tests

* Use mock_config_flow helper in new config_entries test

* Add discovery_keys attribute to ConfigEntry

* Update zeroconf rediscovery

* Change type of ConfigEntry.discovery_keys

* Update tests

* Fix DiscoveryKey.from_json_dict and add tests

* Fix test

---------

Co-authored-by: J. Nick Koston <[email protected]>
2024-09-23 16:49:21 +02:00
Robert ReschandGitHub ad50136dbd Add created_at/modified_at to config entries (#122456) 2024-07-29 22:08:46 +02:00
dougiteixeiraandGitHub e9515b7584 Update test_device_cleaning in Utiltity Meter. (#120161) 2024-06-22 15:46:55 +02:00
dougiteixeiraandGitHub a8ba22f6bb Add device linking and stale device link clean up helpers (#119761) 2024-06-21 14:46:39 +02:00
8cf1890772 Moves diagnostic information from attributes to diagnostic in Utility Meter (#118637)
* move diag information from attributes to diagnostic

* remove constant attributes

---------

Co-authored-by: G Johansson <[email protected]>
2024-06-15 12:50:19 +02:00
dougiteixeiraandGitHub cd80b9b318 Remove obsolete device links in Utility Meter helper (#119328)
* Make sure we update the links between the devices and config entries when the changes source device
2024-06-13 23:44:13 +02:00
epenetandGitHub 3d1165519d Fix broad-exception-raised in component tests (#119467) 2024-06-12 17:53:42 +02:00
epenetandGitHub fb51163075 Move socket_enabled fixture to decorator (#118847) 2024-06-06 17:27:38 +02:00
epenetandGitHub 2545b7d3bb Use registry fixtures in tests (t-u) (#118297) 2024-05-28 14:23:01 +02:00
Marc MuellerandGitHub dc47792ff2 Update codespell to 2.3.0 (#118001) 2024-05-24 08:22:29 +02:00
J. Nick KostonandGitHub 5a609c34bb Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
Diogo GomesandGitHub 450c57969a Add diagnostic platform to utility_meter (#114967)
* Add diagnostic to identify next_reset

* Add test

* add next_reset attr

* Trigger CI

* set as _unrecorded_attributes
2024-05-14 15:20:59 +02:00
gibwarandGitHub e403b50ddc Only reset requested utility meter with no tariff (#115170) 2024-04-08 10:05:46 +02:00
J. Nick KostonandGitHub c4b5a7c027 Migrate start helper to use run_immediately (#115055) 2024-04-06 12:35:46 -10:00
Joost LekkerkerkerandGitHub 2ef0521d3d Use is in enum comparison in config flow tests U-Z (#114677)
* Use right enum expression U-Z

* Fix
2024-04-02 23:09:56 +02:00
Erik MontnemeryandGitHub 5b98a8458f Improve device class of utility meter (#114368) 2024-03-28 13:24:44 +01:00
Erik MontnemeryandGitHub aa9d58df67 Improve utility meter restore state tests (#114356) 2024-03-28 10:42:52 +01:00
00ec7f11f0 Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <[email protected]>
2024-03-19 09:01:07 +01:00
Marc MuellerandGitHub 87165c0d6e Add empty line after module docstring [tests t-z] (#112712) 2024-03-08 14:44:56 +01:00
gibwarandGitHub 52fe0a5e96 Fix utility meter reset without tarrifs (#102884)
* Fix utility meter reset without tarrifs

When using a utility_meter helper set up with a "Meter reset cycle" of
"No cycle" it is impossible to properly reset the meter to 0 and utilize
the "last reset" and "last period" attributes on the helper.

With these changes the service call can now directly reset a meter in
such a configuration and the UI selector has been updated to include
utility meters in the selection list.

Fixes #96920

* Undo UI target selection modes

As requested to not cause confusion by being able to reset individual
meters when using multiple tariffs.

* Adjust logic to only reset standalone sensors

The original logic would allow resetting meters with multiple tariffs
which was an unintended side effect.
2024-03-01 16:44:24 +01:00
J. Nick KostonandGitHub ab68a26000 Fix flakey utility meter test (#111400)
The test tooling would cancel setup at teardown because
it was still setting up

https://github.com/home-assistant/core/actions/runs/8039593463/job/21956908225?pr=111336
2024-02-25 20:21:09 +01:00
7713cf377d Add utility meter option for the sensor to always be available (#103481)
* Adds option for the sensor to always be available

* Remove logger debug

* Add migration config entry version

* Update homeassistant/components/utility_meter/config_flow.py

Co-authored-by: Robert Resch <[email protected]>

* Update homeassistant/components/utility_meter/sensor.py

Co-authored-by: Robert Resch <[email protected]>

* Remove migration config entry version

* Change CONF_SENSOR_ALWAYS_AVAILABLE optional in CONFIG_SCHEMA

* Remove CONF_SENSOR_ALWAYS_AVAILABLE in tests

* Remove CONF_SENSOR_ALWAYS_AVAILABLE in tests

* Remove CONF_SENSOR_ALWAYS_AVAILABLE in tests

* Add option in yaml

* Update homeassistant/components/utility_meter/strings.json

Co-authored-by: Robert Resch <[email protected]>

* Update homeassistant/components/utility_meter/strings.json

Co-authored-by: Robert Resch <[email protected]>

* Changes tests

* Add test_always_available

* Use freezegun

* Update homeassistant/components/utility_meter/strings.json

---------

Co-authored-by: Robert Resch <[email protected]>
Co-authored-by: Erik Montnemery <[email protected]>
2024-01-25 20:46:33 +01:00
J. Nick KostonandGitHub c399cab427 Small speed up to checking core state (#107845) 2024-01-18 08:41:32 -10:00
Jan-Philipp BeneckeandGitHub a16819e0e5 Use freezegun in utility_meter tests (#105123) 2023-12-06 14:43:26 +01:00
Diogo GomesandGitHub 7c94293cb4 Fix utility_meter reset when DST change occurs (#103012) 2023-10-30 09:46:20 +01:00
Diogo GomesandGitHub 553cdfbf99 Always update unit of measurement of the utility_meter on state change (#99102) 2023-09-10 08:29:38 -05:00
Erik MontnemeryandGitHub c1b47b88f2 Adjust utility_meter tests which create devices (#98212) 2023-08-10 18:24:47 +02:00
Franck NijhofandGitHub 30058297cf Migrate backported StrEnum to built-in StrEnum (#97101) 2023-07-23 23:19:24 +02:00
75bdb03363 Fix source device when source entity is changed for Utility Meter (#95636)
* Fix source device when source entity is changed

* Update loop

* Complement and add comments in the test_change_device_source test

* Only clean up dev reg when options change

---------

Co-authored-by: Paulus Schoutsen <[email protected]>
2023-07-02 22:46:21 -04:00
dougiteixeiraandGitHub f2f0c38fae Fix device source for Utility Meter (#95585)
* Fix Device Source

* Remove debug
2023-06-29 21:52:48 -04:00
39229ce098 Add the device of the source entity in the helper entities for Utility Meter (#94734)
Co-authored-by: Franck Nijhof <[email protected]>
2023-06-26 18:08:13 +02:00
Diogo GomesandGitHub 86fe0c9683 Track availability of source sensor in utility meter (#91035)
* track availability of source sensor

* address review comments
2023-04-10 12:37:45 -04:00
Diogo GomesandGitHub fe393c84e2 Delay utility_meter until HA has started (#91017)
* increase information for end user

* only warn after home assistant has started

* delay utility_meter until HA has startED
2023-04-08 10:36:34 -04:00
Wesley VosandGitHub 478a1d5e9a Add periodically resetting meter option to utility meter (#88446)
* Use last valid state if meter is not periodically resetting

* Fix unload of entry, used during options flow submit

* Adjustments based on code review

* Move DecimalException handling to validation method

* Add test for invalid new state in calculate_adjustment method
2023-03-28 17:09:20 +02:00