Commit Graph

50 Commits (b07e9df308a2fec26d76ee0ae046c5699d0546d1)

Author SHA1 Message Date
Joost Lekkerkerker ac53b78a0c
Deduplicate constants A-D (#105638) 2023-12-13 14:21:44 +01:00
Aarni Koskela 706add4a57
Switch formatting from black to ruff-format (#102893)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-11-27 14:38:59 +01:00
Jan-Philipp Benecke 9326ea09a5
Update m* tests to use entity & device registry fixtures (#103980) 2023-11-15 10:33:11 +01:00
Martin Hjelmare 52067dbfe5
Fix mysensors battery level attribute (#101868) 2023-10-12 13:01:08 +02:00
Daniel Trnka 09729e8c46
Add Mysensors battery sensor (#100749)
* Move child related stuff to MySensorsChildEntity

* Dispatch signal for newly discovered MySensors node

* Create battery entity for each MySensors node

* Removed ATTR_BATTERY_LEVEL attribute from each node sensor

Attribute is redundant with newly introduced battery sensor entity

* Apply suggestions from code review

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-09-24 22:50:13 +02:00
Martin Hjelmare 29645d5820
Remove mysensors ir switch (#90403) 2023-03-28 13:39:32 +02:00
Martin Hjelmare e6c94d7854
Remove mysensors notify (#90402) 2023-03-28 13:05:09 +02:00
epenet 71dc98a39c
Improve hass_ws_client type hint in tests (#89703) 2023-03-14 16:31:40 +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
G Johansson 896dd1a36b
Change name to entity_id Text platform error messages (#87963) 2023-02-13 12:51:38 +01:00
Martin Hjelmare 9c76cd1b6a
Add mysensors remote platform (#86376) 2023-01-22 21:04:42 +01:00
Michael 104f74054b
Replace the usage of unit constants by enumerations in Tests [m-n] (#85935)
* replace unit conts by enums m-n

* fix mqtt
2023-01-15 15:45:00 +01:00
Martin Hjelmare df2d0cd3e3
Refactor mysensors device tracker (#84747) 2022-12-30 13:15:00 +01:00
Martin Hjelmare 5d4216d648
Add mysensors text platform (#84667)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-12-30 00:01:03 +01:00
Martin Hjelmare d441fb2ec5
Use debouncer in mysensors (#84638)
* Use debouncer in mysensors

* Clean cover tests

* Fix debouncer mocking

* Follow typing
2022-12-27 21:37:10 +01:00
Martin Hjelmare eae8154753
Add mysensors cover tests (#84626) 2022-12-27 20:04:22 +01:00
Martin Hjelmare d1489fe76f
Add mysensors climate tests (#84619) 2022-12-27 17:40:59 +01:00
Martin Hjelmare 633c82d9fe
Clean mysensors test fixture loading (#84618) 2022-12-27 17:17:01 +01:00
Martin Hjelmare dea513cdbd
Add mysensors light tests (#84606) 2022-12-27 15:25:22 +01:00
Martin Hjelmare 941d175087
Add mysensors device tracker tests (#84589) 2022-12-26 12:58:13 -10:00
Martin Hjelmare 08586868f5
Add mysensors switch tests (#84585) 2022-12-26 09:44:10 -10:00
Martin Hjelmare 101118a60e
Add mysensors binary sensor tests (#84580) 2022-12-26 20:19:15 +01:00
Martin Hjelmare 4461e0f262
Clean mysensors test type errors (#84178) 2022-12-19 12:45:17 +01:00
epenet 061cef1a5e
Use SoundPressure unit and device class in integrations (#83585)
* Use SoundPressure unit and device class in integrations

* Adjust tests
2022-12-09 07:56:09 +01:00
epenet e84e5f134e
Use US_CUSTOMARY_SYSTEM in tests (#80658)
* Use US_CUSTOMARY_SYSTEM in tests

* Don't update test_unit_system
2022-10-20 15:42:23 +02:00
epenet fb7079c62c
Adjust icons with new device classes (#79348)
* Adjust icons with new device classes

* Fix mysensors tests

* Fix mysensors tests
2022-09-30 10:41:18 +02:00
Martin Hjelmare e864b82c03
Improve mysensors config flow (#75122)
* Improve mysensors config flow

* Improve form input order

* Update flow tests
2022-08-07 01:22:50 +02:00
Martin Hjelmare 8140ed724c
Remove mysensors yaml (#72761) 2022-05-31 15:22:31 +02:00
epenet 053c4428a9
Prettify json (component test fixtures) (#68892) 2022-03-30 11:37:17 +02:00
Martin Hjelmare f91a809350
Add mysensors notify tests (#67634) 2022-03-04 14:47:27 +01:00
Martin Hjelmare e9496869da
Rework mysensors test fixtures (#67331)
* Reworks mysensors test fixtures

* Fix missing autospecced methods
2022-03-02 07:23:36 +01:00
Martin Hjelmare 2dd14f8e94
Add mysensors remove device support (#67128) 2022-02-23 10:59:12 -08:00
Marc Mueller d057850971
Update typing - collections.abc (3) (#63947) 2022-01-12 08:04:17 +01:00
Dave T 03054bc430
Use new enums in mysensors tests (#62521) 2021-12-21 21:57:55 +01:00
Paulus Schoutsen 31153ac155
Move fixtures part 1 (#58902) 2021-11-01 20:47:05 -07:00
Paulus Schoutsen a4d9019ffc
Refactor persistent notification to no longer route all data via a service (#57157)
* Convert persistent notification tests to async

* Create/dismiss persistent notifications in exposed functions, not service calls

* Fix notify persistent_notification

* Remove setting up persistent_notification

* Drop more setups

* Empty methods

* Undeprecate sync methods because too big task

* Fix setup clearing notifications

* Fix a bunch of tests

* Fix more tests

* Uno mas

* Test persistent notification events

* Clean up stale comment

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-10-07 12:58:00 +02:00
Erik Montnemery c74f9a8313
Remove stale references to last_reset (#54838)
* Remove stale references to last_reset

* Update tests
2021-08-18 21:47:57 +02:00
Erik Montnemery e98d50f6d1
Remove `last_reset` attribute and set state class to `total_increasing` for mysensors energy sensors (#54827) 2021-08-18 16:58:13 +02:00
Martin Hjelmare 028a3d3e53
Complete mysensors sensor coverage (#54471) 2021-08-11 17:19:02 +02:00
Martin Hjelmare a133eae88e
Add more mysensors sensor attributes (#53566) 2021-07-27 19:48:37 +02:00
Martin Hjelmare 120fd633b2
Add mysensors sensor platform test foundation (#51548) 2021-06-27 20:33:20 +02:00
Martin Hjelmare 2eb6f16a94
Fix mysensors awesomeversion strategy usage (#51627)
* Update awesomeversion strategy use in mysensors

* Remove default version
2021-06-08 20:24:54 +02:00
Martin Hjelmare 6de604a326
Fix mysensors tests typing (#51621) 2021-06-08 14:28:36 +02:00
Martin Hjelmare 0c288bcabb
Fix mysensors default persistence file on import (#48410) 2021-05-07 13:37:38 +02:00
Ville Skyttä 631ab367e2
Fix typing.Any spelling (#49673) 2021-04-25 09:36:21 -10:00
jan iversen d76993034e
Replace HomeAssistantType with HomeAssistant for integrations m* - n* (#49566)
* Integration neato: rename HomeAssistantType to HomeAssistant.

* Integration mysensors: rename HomeAssistantType to HomeAssistant.

* Integration mobile_app: rename HomeAssistantType to HomeAssistant.

* Integration minecraft_server: rename HomeAssistantType to HomeAssistant.

* Clean up

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-04-22 22:23:36 +02:00
Martin Hjelmare 410f0e3604
Fix mysensors mqtt integration setup guard (#49423) 2021-04-20 09:21:38 -07:00
Marc Mueller 54d1e9985f
Update typing 15 (#48079) 2021-03-18 15:13:22 +01:00
Martin Hjelmare 1c7c6163dd
Save mysensors gateway type in config entry (#46981) 2021-02-24 11:31:31 +01:00
functionpointer c01e01f797
MySensors config flow (#45421)
* MySensors: Add type annotations

Adds a bunch of type annotations that were created
while understanding the code.

* MySensors: Change GatewayId to string

In preparation for config flow.
The GatewayId used to be id(gateway).

With config flows, every gateway will have its own
ConfigEntry. Every ConfigEntry has a unique id.
Thus we would have two separate but one-to-one related ID systems.

This commit removes this unneeded duplication by using the id of the ConfigEntry
as GatewayId.

* MySensors: Add unique_id to all entities

This allows entities to work well with the frontend.

* MySensors: Add device_info to all entities

Entities belonging to the same node_id will now by grouped as a device.

* MySensors: clean up device.py a bit

* MySensors: Add config flow support

With this change the MySensors can be fully configured from the GUI.

Legacy configuration.yaml configs will be migrated by reading them once.
Note that custom node names are not migrated. Users will have to re-enter
the names in the front-end.
Since there is no straight-forward way to configure global settings,
all previously global settings are now per-gateway. These settings include:
- MQTT retain
- optimistic
- persistence enable
- MySensors version

When a MySensors integration is loaded, it works as follows:
1. __init__.async_setup_entry is called
2. for every platform, async_forward_entry_setup is called
3. the platform's async_setup_entry is called
4. __init__.setup_mysensors_platform is called
5. the entity's constructor (e.g. MySensorsCover) is called
6. the created entity is stored in a dict in the hass object

* MySensors: Fix linter errors

* MySensors: Remove unused import

* MySensors: Feedback from @MartinHjelmare

* MySensors: Multi-step config flow

* MySensors: More feedback

* MySensors: Move all storage in hass object under DOMAIN

The integration now stores everything under hass.data["mysensors"]
instead of using several top level keys.

* MySensors: await shutdown of gateway instead of creating a task

* MySensors: Rename Ethernet to TCP

* MySensors: Absolute imports and cosmetic changes

* MySensors: fix gw_stop

* MySensors: Allow user to specify persistence file

* MySensors: Nicer log message

* MySensors: Add lots of unit tests

* MySensors: Fix legacy import of persistence file name

Turns out tests help to find bugs :D

* MySensors: Improve test coverage

* MySensors: Use json persistence files by default

* MySensors: Code style improvements

* MySensors: Stop adding attributes to existing objects

This commit removes the extra attributes that were being
added to the gateway objects from pymysensors.

Most attributes were easy to remove, except for the gateway id.
The MySensorsDevice class needs the gateway id as it is part of its DevId
as well as the unique_id and device_info.
Most MySensorsDevices actually end up being Entities.
Entities have access to their ConfigEntry via self.platform.config_entry.

However, the device_tracker platform does not become an Entity.
For this reason, the gateway id is not fetched from self.plaform but
given as an argument.

Additionally, MySensorsDevices expose the address of the gateway
(CONF_DEVICE). Entities can easily fetch this information via self.platform,
but the device_tracker cannot. This commit chooses to remove the gateway
address from device_tracker. While this could in theory break some automations,
the simplicity of this solution was deemed worth it.
The alternative of adding the entire ConfigEntry as an argument to MySensorsDevices
is not viable, because device_tracker is initialized by the async_setup_scanner function
that isn't supplied a ConfigEntry. It only gets discovery_info.
Adding the entire ConfigEntry doesn't seem appropriate for this edge case.

* MySensors: Fix gw_stop and the translations

* MySensors: Fix incorrect function calls

* MySensors: Fewer comments in const.py

* MySensors: Remove union from _get_gateway and remove id from try_connect

* MySensors: Deprecate nodes option in configuration.yaml

* MySensors: Use version parser from packaging

* MySensors: Remove prefix from unique_id and change some private property names

* MySensors: Change _get_gateway function signature

* MySensors: add packaging==20.8 for the version parser

* MySensors: Rename some stuff

* MySensors: use pytest.mark.parametrize

* MySensors: Clean up test cases

* MySensors: Remove unneeded parameter from devices

* Revert "MySensors: add packaging==20.8 for the version parser"

This reverts commit 6b200ee01a.

* MySensors: Use core interface for testing configuration.yaml import

* MySensors: Fix test_init

* MySensors: Rename a few variables

* MySensors: cosmetic changes

* MySensors: Update strings.json

* MySensors: Still more feedback from @MartinHjelmare

* MySensors: Remove unused strings

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* MySensors: Fix typo and remove another unused string

* MySensors: More strings.json

* MySensors: Fix gateway ready handler

* MySensors: Add duplicate detection to config flows

* MySensors: Deal with non-existing topics and ports.

Includes unit tests for these cases.

* MySensors: Use awesomeversion instead of packaging

* Add string already_configured

* MySensors: Abort config flow when config is found to be invalid while importing

* MySensors: Copy all error messages to also be abort messages

All error strings may now also be used as an abort reason,
so the strings should be defined

* Use string references

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-02-05 22:13:57 +01:00