Commit Graph

37 Commits (a9381d259040d4a02881cc9e203bc8e3946b2146)

Author SHA1 Message Date
Erik Montnemery 524e20536d
Improve dlna_dmr tests (#102905) 2023-10-28 14:53:34 +02:00
Meow a4b2ded503
Refactor deprecated RESULT_TYPE_* (#97367) 2023-07-30 19:27:30 +02:00
J. Nick Koston d4cdb0453f
Guard expensive debug formatting with calls with isEnabledFor (#97073) 2023-07-23 10:54:25 +02:00
Erik Montnemery 8440f14a08
Correct dlna_dmr device info (#96480) 2023-07-13 12:15:46 -04:00
J. Nick Koston 3d1556a4a2
Switch back to using call_later for the slow entity update warning (#91067)
* Switch back to using call_later for the slow entity update warning

I had originally changed this to create a task and wait
in #41184 but that does not make sense anymore with newer
cpython as the profile now shows the original method is cheaper
(or I did it wrong the first time)

* fix missing block till done since there is no longer a task being created which would run the event loop once
2023-04-08 22:22:56 -04:00
epenet 853bd52a22
Adjust entity registry access in tests (1) (#88950) 2023-03-01 09:11:14 +01:00
epenet 728f62b1ec
Add type hints to integration tests (part 5) (#87850) 2023-02-12 19:39:48 +01:00
Franck Nijhof 5e81d28116
Update black to 23.1.0 (#87188) 2023-02-02 18:35:24 +01:00
Franck Nijhof 24fdd588fd
Code styling tweaks to the tests - Part 1 (#86192) 2023-01-20 13:52:46 +01:00
Michael Chisholm fbab7413a5
Match config entries for dlna_dmr based on device MAC, in addition to UDN (#74619)
* Factor out _is_dmr_device function

* Use DMR device's MAC to match existing config entries

Some DMR devices change their every time they boot, against the DMR specs.
Try to match such devices to existing config entries by using their MAC
addresses.

* Add DMR device's MAC as a device_registry connection

* Use doc-only IPs (RFC5737) for dlna_dmr tests
2022-12-11 13:40:35 -05:00
Steven Looman 731f618028
Make home assistant discoverable via UPnP/SSDP (#79820) 2022-10-15 14:00:46 -04:00
epenet 8b3ce8c58c
Use new constants in dlna_dmr media player (#78045) 2022-09-09 09:03:59 +02:00
Franck Nijhof 7cd68381f1
Search/replace RESULT_TYPE_* by FlowResultType enum (#74642) 2022-07-07 19:57:36 +03:00
Michael Chisholm eebf3acb93
Relax dlna_dmr filtering when browsing media (#69576)
* Fix incorrect types of test data structures

* Loosen MIME-type filtering for async_browse_media

* Add option to not filter results when browsing media

Some devices do not report all that they support, and in this case
filtering will hide media that's actually playable. Most devices are OK,
though, and it's better to hide what they can't play. Add an option, off by
default, to show all media.

* Fix linting issues
2022-05-04 22:22:15 -07:00
Michael Chisholm 4e57b1b118
Fix config_flow error from dlna_dmr for UPnP discovery info containing a single service (#69977) 2022-04-13 19:04:03 +02:00
Steven Looman f006cffac6
Bump async-upnp-client to 0.27.0 (#68310) 2022-03-17 12:32:46 -10:00
Paulus Schoutsen d68ada74cc
Restore children media class (#67409) 2022-03-01 15:14:14 -08:00
Steven Looman dbbb5655e5
Bump async-upnp-client to 0.25.0 (#66414)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-02-27 08:29:29 -10:00
Paulus Schoutsen 459e6c273b
Track hidden items in media source (#67096) 2022-02-23 09:51:01 +01:00
Michael Chisholm 3d5790aaad
Avoid accessing hass.data in test_play_media_didl_metadata (#66939) 2022-02-20 14:14:53 +01:00
Michael Chisholm 3c15fe8587
Add media browser support to dlna_dmr (#66425) 2022-02-19 21:07:38 -08:00
Michael Chisholm c9e495607e
Ignore further ssdp:alive message if connection fails in dlna_dmr (#59891) 2022-01-20 11:23:23 -10:00
Robert Hillis e689afc0b3
Remove deprecated yaml config from dlna_dmr (#62344) 2021-12-20 13:56:45 +01:00
Diego Elio Pettenò 6ce99bfc80
Bump async-upnp-client to 0.23.0 (#62223) 2021-12-17 16:57:02 -06:00
epenet e95914cf60
Use dataclass properties in dlna_dmr discovery (#60693)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-01 08:59:12 -10:00
epenet f292691b7b
Use SsdpServiceInfo for ssdp tests (part 3) (#60334)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-25 11:46:20 -06:00
Michael Chisholm 9fa6daf47a
dlna_dmr: Ignore philips tv (#60204) 2021-11-23 23:22:34 +01:00
Michael Chisholm ce27fb87c6
dlna_dmr: less eager discovery (#58780) 2021-10-31 16:11:20 +01:00
Michael Chisholm 6cdc372dcb
Add more dlna_dmr media_player services and attributes (#57827) 2021-10-28 16:44:41 -05:00
Michael Chisholm 2ea537e1a6
dlna_dmr will gracefully handle device's rejection of subscription attempt (#58451) 2021-10-26 20:19:18 +02:00
Michael Chisholm 44aa1fdc66
dlna_dmr won't support devices that don't provide all DMR services (#58374) 2021-10-25 19:54:58 -05:00
Michael Chisholm ee087c7a05
Discovery ignores DLNA DMR devices when they are better supported by another integration (#57363) 2021-10-22 10:26:33 -10:00
Paulus Schoutsen b0f24b65d6
Drop more persistent notification patches (#57295) 2021-10-08 16:45:05 +02:00
Michael Chisholm 667e730946
Improve dlna_dmr code quality (#56886)
* Listen for config updates from DlnaDmrEntity.async_added_to_hass

Use `Entity.async_on_remove` for dealing with callback cancellation,
instead of re-inventing the wheel with `_remove_ssdp_callbacks`.

* Use async_write_ha_state within async methods

* Import YAML config from async_setup_platform

* Import flow prompts user when device is uncontactable during migration

When config flow is able to contact a device, or when it has information
from SSDP, it will create config entries without error. If the device is
uncontactable at this point then it will appear as unavailable in HA
until it is turned on again.

When import flow cannot migrate an entry because it needs to contact the
device and can't, it will notify the user with a config flow form.

* Don't del unused parameters, HA pylint doesn't care

* Remove unused imports from tests

* Abort config flow at earliest opportunity

* Return async_abort instead of raising AbortFlow

* Consolidate config entry test cleanup into a single function

* fixup! Consolidate config entry test cleanup into a single function

Revert "Consolidate config entry test cleanup into a single function"

This reverts commit 8220da7263.

* Check resource acquisition/release in specific tests

* fixup! Check resource acquisition/release in specific tests

* Remove unused network dependency from manifest

* _on_event runs in async context

* Call async_write_ha_state directly (not via shedule_update)

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

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-10-07 22:14:00 +02:00
J. Nick Koston 2f960e558f
Prevent dlna_dmr from opening sockets in tests (#57059)
Supports #55516
2021-10-04 20:25:46 +02:00
Michael Chisholm f7d95588f8
Provide most media metadata in DlnaDmrEntity (#56728)
Co-authored-by: Steven Looman <steven.looman@gmail.com>
2021-09-28 19:37:23 -05:00
Michael Chisholm a28fd7d61b
Config-flow for DLNA-DMR integration (#55267)
* Modernize dlna_dmr component: configflow, test, types

* Support config-flow with ssdp discovery
* Add unit tests
* Enforce strict typing
* Gracefully handle network devices (dis)appearing

* Fix Aiohttp mock response headers type to match actual response class

* Fixes from code review

* Fixes from code review

* Import device config in flow if unavailable at hass start

* Support SSDP advertisements

* Ignore bad BOOTID, fix ssdp:byebye handling

* Only listen for events on interface connected to device

* Release all listeners when entities are removed

* Warn about deprecated dlna_dmr configuration

* Use sublogger for dlna_dmr.config_flow for easier filtering

* Tests for dlna_dmr.data module

* Rewrite DMR tests for HA style

* Fix DMR strings: "Digital Media *Renderer*"

* Update DMR entity state and device info when changed

* Replace deprecated async_upnp_client State with TransportState

* supported_features are dynamic, based on current device state

* Cleanup fully when subscription fails

* Log warnings when device connection fails unexpectedly

* Set PARALLEL_UPDATES to unlimited

* Fix spelling

* Fixes from code review

* Simplify has & can checks to just can, which includes has

* Treat transitioning state as playing (not idle) to reduce UI jerking

* Test if device is usable

* Handle ssdp:update messages properly

* Fix _remove_ssdp_callbacks being shared by all DlnaDmrEntity instances

* Fix tests for transitioning state

* Mock DmrDevice.is_profile_device (added to support embedded devices)

* Use ST & NT SSDP headers to find DMR devices, not deviceType

The deviceType is extracted from the device's description XML, and will not
be what we want when dealing with embedded devices.

* Use UDN from SSDP headers, not device description, as unique_id

The SSDP headers have the UDN of the embedded device that we're interested
in, whereas the device description (`ATTR_UPNP_UDN`) field will always be
for the root device.

* Fix DMR string English localization

* Test config flow with UDN from SSDP headers

* Bump async-upnp-client==0.22.1, fix flake8 error

* fix test for remapping

* DMR HA Device connections based on root and embedded UDN

* DmrDevice's UpnpDevice is now named profile_device

* Use device type from SSDP headers, not device description

* Mark dlna_dmr constants as Final

* Use embedded device UDN and type for unique ID when connected via URL

* More informative connection error messages

* Also match SSDP messages on NT headers

The NT header is to ssdp:alive messages what ST is to M-SEARCH responses.

* Bump async-upnp-client==0.22.2

* fix merge

* Bump async-upnp-client==0.22.3

Co-authored-by: Steven Looman <steven.looman@gmail.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-09-27 15:47:01 -05:00