Commit Graph

59 Commits

Author SHA1 Message Date
Yuxin Wang
a494d3ec69 Sort the resources for deterministic sensor addition order in APCUPSD (#152467) 2025-09-17 10:41:19 +02:00
Yuxin Wang
82b57568a0 Set diagnostic entity category for "mode" in APCUPSD (#152246) 2025-09-13 18:38:47 +02:00
Yuxin Wang
2b7bd923d6 Add a base entity to APCUPSD integration (#150828) 2025-08-18 07:18:08 +02:00
Yuxin Wang
85aa7bef1e Add sensor categorizations for APCUPSD (#146863)
* Add sensor categorizations

* Fix snapshot problem

* Fix snapshot problem
2025-06-16 08:43:31 +02:00
Yuxin Wang
844515787b Fallback to config entry ID as unique ID when serialno is not available for APCUPSD (#130852) 2025-04-10 16:45:46 +02:00
Erik Montnemery
f83c8de8d3 Update signature of platforms' async_setup_entry (#138201) 2025-02-10 21:08:03 +01:00
Michael
fd1213b70d Explicitly pass in the config_entry in apcupsd coordinator init (#137709)
explicitly pass in the config_entry in apcupsd coordinator init
2025-02-07 23:55:41 +01:00
epenet
4d804649fc Migrate apcupsd to use runtime_data (#125539) 2024-09-08 22:07:19 +02:00
Yuxin Wang
74a12bb802 Replace LASTSTEST with LAST_S_TEST (#124668) 2024-08-27 06:50:15 +02:00
Yuxin Wang
bb6f9ec844 Set native value to be None instead of STATE_UNKNOWN for APCUPSD integration (#124609) 2024-08-25 19:09:37 -10:00
Yuxin Wang
bf3a2cf393 Add graceful handling for LASTSTEST sensor in APCUPSD (#113125)
* Add handling for LASTSTEST sensor

* Set the state to unknown instead of unavailable

* Use LASTSTEST constant and revise the logic to add it to the entity list

* Use LASTSTEST constant
2024-07-31 13:01:48 +02:00
Yuxin Wang
81ee5fb46b Refine sensor descriptions for APCUPSD (#114137)
* Refine sensor descriptions for APCUPSD

* Add device class for cumonbatt

* Add UoM to STESTI and TIMELEFT

* Remove device class for STESTI
2024-06-07 12:28:59 +02:00
Yuxin Wang
071c3abb69 Define PARALLEL_UPDATES for APCUPSD (#114134) 2024-03-28 10:17:12 +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
ff3a801936 Add empty line after module docstring [a-d] (#112697) 2024-03-08 14:51:32 +01:00
Yuxin Wang
2c5510df30 Avoid using coordinator in config flow of APCUPSD (#112121)
* Separate data class out of coordinator

* Further fix the imports

* Update homeassistant/components/apcupsd/coordinator.py

Co-authored-by: J. Nick Koston <nick@koston.org>

* Use `or` to make it a bit cleaner when trying to find the UPS model

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>

* Use or to make it a bit cleaner when trying to find the UPS model

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>

* Use plain dict instead of `OrderedDict`

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
2024-03-04 09:40:59 +01:00
Joost Lekkerkerker
859c28fdb7 Add icon translations to apcupsd (#111342)
* Add icon translations to apcupsd

* Add icon translations to apcupsd
2024-02-25 10:42:04 +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
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
a547181984 Fix unit inference for ITEMP field for APCUPSD integration (#93724) 2023-05-29 20:40:36 +02:00
ondras12345
cef1809536 Fix apcupsd spamming logs when host is unavailable (#85920)
fixes undefined
2023-01-15 14:45:05 +01:00
Ville Skyttä
ae302bbec0 Make use of str.removeprefix and .removesuffix (#85584) 2023-01-13 12:19:38 +01:00
Yuxin Wang
06095b1fec Enable strict typing for apcupsd (#84861) 2022-12-30 21:48:29 +01:00
Yuxin Wang
7a7f986444 Add state_class to the sensor entity descriptions for apcupsd integration (#84829) 2022-12-30 17:53:54 +00:00
Yuxin Wang
677f0dc335 Remove deprecated apcupsd YAML config (#83801) 2022-12-13 08:52:05 +01:00
epenet
2b647bcd5b Use device classes in apcupsd (#83807) 2022-12-12 11:44:37 +01:00
epenet
248d5ff541 Use ApparentPower unit and device class in integrations (#83577) 2022-12-08 20:55:18 +01:00
definitio
644b00ca2d Add apcupsd laststest sensor (#80773) 2022-10-25 08:44:54 +02: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
epenet
65eb1584f7 Improve entity type hints [a] (#76986) 2022-08-18 15:56:52 +02:00
Marc Mueller
911b159281 Cleanup after pylint update (#68657) 2022-03-26 00:34:12 +01:00
Franck Nijhof
276fd4f42c Add Python 3.10 to CI (#59729) 2022-02-17 14:58:24 +01:00
epenet
4363852178 Add sensor setup type hints [a-b] (#63319)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-03 19:18:00 +01:00
epenet
880a2b69b6 Use new SensorDeviceClass in apcupsd (#61271)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-08 21:55:44 +01:00
Michael
0edb0c9bc9 Correct name of end apc sensor (#59200) 2021-11-08 16:08:07 +01:00
Marc Mueller
a4e4ffef0a Use EntityDescription - apcupsd (#55790) 2021-09-06 10:19:31 +02:00
Erik Montnemery
4e07ab1b32 Move temperature conversions to sensor base class (1/8) (#48261)
* Move temperature conversions to entity base class (1/8)

* Update integrations a-c

* Leave old temperature conversion until all integrations are migrated

* tweak

* Use contextlib.suppress

* Remove the MeasurableUnitEntity mixin

* Address comments, add tests

* Fix f-string

* Drop deprecation warning from base entity class

* Update with _attr-shorthand

* Fix rebase mistakes

* Fix additional rebase mistakes

* Only report temperature conversion once

* Fix additional rebase mistakes

* Format homeassistant/components/bbox/sensor.py

* Fix check for overidden _attr_state

* Remove test workarounds from implementation

* Remove useless None-check

* Tweaks

* Migrate new sensors a-c

* Update climacell

* Push deprecation of temperature conversion forward

* Override __repr__ in SensorEntity

* Include native_value in SensorEntity attributes

* Pylint

* Black

* Black

* Fix rebase mistakes

* black

* Fix rebase mistakes

* Revert changes in august/sensor.py

* Revert handling of unit converted restored state

* Apply code review suggestion

* Fix arlo test
2021-08-11 10:45:05 +02:00
Michael
f7fb4ad782 Fix attr_unit_of_measurement in update of apcupsd entity (#53947) 2021-08-04 21:24:19 +02:00
Marc Mueller
074d762664 Rename and reorganize electric unit constants (#53243) 2021-07-20 20:06:23 +02:00
Erik Montnemery
9b8a776001 Set device_class on temperature sensors A-E (#49524)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-07-12 22:45:29 +02:00
Robert Hillis
1c11b247e4 Use entity class attributes for apcupsd (#52662) 2021-07-08 11:55:26 +02:00
Erik Montnemery
e0cd7072d6 Migrate integrations a-c to extend SensorEntity (#48210) 2021-03-22 12:37:16 +01:00
springstan
d2b1918e9c Drop UNIT_ prefix for percentage constant (#39383) 2020-09-05 21:09:14 +02:00
Bram Kragten
9ecaa10e51 Adjust icons for MDI bump (#37730) 2020-07-14 22:17:14 +02:00
springstan
b42a197293 Add and use ELECTRICAL_CURRENT_AMPERE, ELECTRICAL_VOLTAGE_AMPERE constants (#33990)
* Add and use ELECTRICAL_CURRENT_AMPERE constant

* Add and use ELECTRICAL_VOLTAGE_AMPERE constant

* Rename ELECTRICAL_VOLTAGE_AMPERE to ELECTRICAL_VOLT_AMPERE

* Fix imports
2020-05-17 15:58:31 +02:00
springstan
ef9d9b17bd Drop UNIT_ prefix for constants (#34164)
* Drop UNIT_ prefix for VOLT

* Drop UNIT_ prefix for DEGREE

* Drop UNIT_ prefix for CONDUCTIVITY

* Drop UNIT_ prefix for UV_INDEX

* Run isort
2020-04-21 19:45:53 +02:00
springstan
19dd797dfe Add and use frequency constants (#34113) 2020-04-12 22:44:31 +02:00
springstan
04c4501455 Add and use UNIT_VOLT constant (#33994)
* Add and use UNIT_VOLT constant

* Run isort
2020-04-11 02:04:58 +02:00