Commit Graph

23 Commits (d0b4210de5db623fd916d3dd2f1f090842cc6541)

Author SHA1 Message Date
Sid 00ec7f11f0
Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
Sid fe9cc6705c
Add ruff rule PIE804 (#113620)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-16 12:45:18 -10:00
Yuxin Wang 405bf076b2
Remove a redundant check in APCUPSD's config flow (#113032)
Remove a redundant check that is impossible to happen in practice
2024-03-11 08:38:44 +01:00
Yuxin Wang db31afe019
Migrate APCUPSD to has entity name (#112997)
* Properly set entity names for APCUPSD

* Add test cases to prevent future regressions

* Fix tests due to the updated entity IDs

* Prettify code

* Remove redundant translation key
2024-03-10 23:56:25 +01:00
Marc Mueller aa16a9d707
Add empty line after module docstring (3) (#112750) 2024-03-08 20:38:34 +01:00
Marc Mueller 32f3f46542
Add empty line after module docstring (2) [tests.components] (#112737) 2024-03-08 19:16:21 +01:00
Marc Mueller 38adfbf1a3
Add empty line after module docstring [tests a-e] (#112708) 2024-03-08 08:50:25 -05:00
Yuxin Wang 88ddc25129
Replace apcaccess dependency with aioapcaccess in apcupsd (#104571)
* Replace apcaccess dependency with async version aioapcaccess

* Upgrade the dependency to the latest version (v0.4.2)

* Handle asyncio.IncompleteReadError
2023-12-08 12:40:09 +01:00
Joost Lekkerkerker e3599bc26f
Move APCUPSd coordinator to separate file (#104540) 2023-11-26 13:04:52 +01:00
Yuxin Wang 33c5d1855d
Rewrite APCUPSD sensors using DataUpdateCoordinator (#88467)
* Add test sensor.

* Fix sensor test file name.

* Add binary sensor test.

* Fix comments and styling.

* Remove apcupsd from omissions in coveragerc.

* Revert "Remove apcupsd from omissions in coveragerc."

This reverts commit 66b05fcb8829619a771a650a3d70174089e15d91.

* Implement the data coordinator for apcupsd.

* Add tests for sensor updates and throttles.

* Reorder the statement for better code clarity.

* Update docstring.

* Add more tests for checking if the coordinator works ok.

* Implement a custom debouncer with 5 second cooldown for the coordinator.

* Add more tests for checking if our integration is able to properly mark entity's availability.

* Make apcupsd a silver integration.

* Try to fix non-deterministic test behaviors

* Fix JSON format

* Use new `with` format in python 3.10 for better readability

* Update tests.

* Rebase and simplify code.

* Add an ups prefix to the property methods of the coordinator

* Replace init_integration with async_init_integration

* Lint fixes

* Fix imports

* Update BinarySensor implementation to add initial update of attributes

* Fix test failures due to rebases

* Reorder the statements for better code clarity

* Fix incorrect references to the ups_name property

* Simplify BinarySensor value getter code

* No need to update when adding coordinator-controlled sensors
2023-11-21 22:40:05 +01:00
Franck Nijhof 04e0e2bd75
Update a* tests to use device & entity registry fixtures (#103711) 2023-11-09 20:46:20 +01:00
Yuxin Wang 36ad24ce01
Add name and default name to device info of APCUPSD sensors (#94415) 2023-07-24 18:42:08 +02:00
Yuxin Wang b1bdd92383
Add unit inference for Amps and VA in APCUPSD integration (#94431)
* Add unit inference for Amps and VA

* Rename `init_integration` to `async_init_integration` for better consistency with HA naming style
2023-06-13 16:38:56 +02:00
Yuxin Wang 676b6ab706
Add support for "days" unit for STESTI sensor in APCUPSD integration (#93844)
Add a test case for self test interval
2023-05-31 14:25:46 +02:00
Yuxin Wang 0653aed49f
Directly check string representation of sensor states in APCUPSD tests (#93783)
* Directly check the string representation of sensor states

* Fix expected state value for sensor.ups_nominal_output_power
2023-05-30 20:01:05 -04:00
Yuxin Wang a547181984
Fix unit inference for ITEMP field for APCUPSD integration (#93724) 2023-05-29 20:40:36 +02:00
epenet 7b3a932cd9
Remove incorrect constant usage in test (#91198) 2023-04-11 10:00:17 +02:00
Yuxin Wang 490a0908d4
Avoiding testing implementation details in apcupsd tests (#88772)
Fix apcupsd tests.
2023-02-26 07:57:31 +01:00
epenet a102883eff
Add type hints to integration tests (part 2) (#88493) 2023-02-21 09:25:05 +01:00
Yuxin Wang ba2e80f741
Add more tests for APC UPS Daemon integration (#85967)
* Add tests for init.

* Add more test init.

* Fix test init side_effect.

* Add test sensor.

* Fix sensor test file name.

* Fix sensor test.

* Add binary sensor test.

* Fix comments and styling.

* Remove apcupsd from omissions in coveragerc.

* Add a test case for binary sensor when STATFLAG is not available.

* Complete type annotations for test files.

* Revert "Remove apcupsd from omissions in coveragerc."

This reverts commit 66b05fcb8829619a771a650a3d70174089e15d91.
2023-02-20 09:51:01 +01:00
Franck Nijhof ed79265843
Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
Yuxin Wang 677f0dc335
Remove deprecated apcupsd YAML config (#83801) 2022-12-13 08:52:05 +01:00
Yuxin Wang 52307708c8
Refactor apcupsd to use config flow (#64809)
* Add Config Flow to APCUPSd integration and remove YAML support.

* Hide the binary sensor if user does not select STATFLAG resource.

* Add tests for config flows.

* Simplify config flow code.

* Spell fix.

* Fix pylint warnings.

* Simplify the code for config flow.

* First attempt to implement import flows to suppport legacy YAML configurations.

* Remove unnecessary log calls.

* Wrap synchronous update call with `hass.async_add_executor_job`.

* Import the YAML configurations when sensor platform is set up.

* Move the logger call since the variables are not properly set up.

* Add codeowner.

* Fix name field of manifest.json.

* Fix linting issue.

* Fix incorrect dependency due to incorrect rebase.

* Update codeowner and config flows via hassfest.

* Postpone the deprecation warning to 2022.7.

* Import future annotations for init file.

* Add an newline at the end to make prettier happy.

* Update github id.

* Add type hints for return types of steps in config flow.

* Move the deprecation date for YAML config to 2022.12.

* Update according to reviews.

* Use async_forward_entry_setups.

* Add helper properties to `APCUPSdData` class.

* Add device_info for binary sensor.

* Simplify config flow.

* Remove options flow strings.

* update the tests according to the changes.

* Add `entity_registry_enabled_default` to entities and use imported CONF_RESOURCES to disable entities instead of skipping them.

* Update according to reviews.

* Do not use model of the UPS as the title for the integration.

Instead, simply use "APCUPSd" as the integration title and let the device info serve as title for each device instead.

* Change schema to be a global variable.

* Add more comments.

* Rewrite the tests for config flows.

* Fix enabled_by_default.

* Show friendly titles in the integration.

* Add import check in `async_setup_platform` to avoid importing in sensor platform setup.

* Add import check in `async_setup_platform` to avoid importing in sensor platform setup.

* Update comments in test files.

* Use parametrize instead of manually iterating different test cases.

* Swap the order of the platform constants.

* Avoid using broad exceptions.

* Set up device info via `_attr_device_info`.

* Remove unrelated test in `test_config_flow`.

* Use `DeviceInfo` instead of dict to assign to `_attr_device_info`.

* Add english translation.

* Add `async_create_issue` for deprecated YAML configuration.

* Enable UPS status by default since it could show "online, charging, on battery etc" which is meaningful for all users.

* Apply suggestions from code review

* Apply suggestion

* Apply suggestion

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-09-28 09:14:04 +02:00