Commit Graph

49 Commits (d279211f0c0cd3d886f92952dbb337cd4868f13e)

Author SHA1 Message Date
Robert Hillis 3bd1f00b76
Use enums in samsungtv tests (#62195)
* Use enums in samsungtv tests

* uno mas
2021-12-17 16:26:53 +01: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
Simone Chemelli 15f62a7237
More tests optimizations for SamsungTV (#60297)
* More tests optimizations

* Apply review comments
2021-11-24 22:54:49 +01:00
Simone Chemelli 8e6a3b2799
Fix init slow tests for SamsungTV (#60245) 2021-11-24 11:25:25 +01:00
epenet 77dfeb062f
Update ZeroconfServiceInfo in tests (n-t) (#60219)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-23 10:35:44 -06:00
epenet 560546f65e
Use dataclass for DhcpServiceInfo (#60136)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-11-23 13:35:53 +01:00
Simone Chemelli e673d9dbd0
Fix missing mocking (#60181) 2021-11-23 11:56:16 +01:00
epenet a72a5486c2
Use ServiceInfo in samsungtv tests (#60097) 2021-11-21 16:00:59 -06: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 ec52763706
Prevent 3rd party lib from opening sockets in samsungtv tests (#56334) 2021-09-18 22:24:27 -10:00
Simone Chemelli 2025afe14b
Add MAC to SamsungTV when missing (#53479)
* Add MAC when missing

* Fix I/O

* Add test for missing MAC address
2021-07-26 16:43:05 +02:00
J. Nick Koston 19b4d2e4d2
Add OUIs for legacy samsungtv (#52928) 2021-07-15 14:43:35 +02:00
Simone Chemelli 13c142a402
Fix Soundbar exclusion from SamsungTV (#51023)
* Improved check

* Fix tests

* Fix logic and tests

* Update tests
2021-07-12 08:58:53 +02:00
J. Nick Koston a71af8e9d3
Abort samsungtv config flow for existing hosts when the unique id is set (#52138)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-06-25 10:31:33 -10:00
J. Nick Koston d009f06a55
Handle connection being closed in legacy samsungtv (#52137)
* Handle connection being closed in legacy samsungtv

- Mirror the websocket behavior

Fixes
```
2021-06-24 02:54:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.89_guestroom fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 401, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 609, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/samsungtv/media_player.py", line 124, in update
    self._state = STATE_ON if self._bridge.is_on() else STATE_OFF
  File "/usr/src/homeassistant/homeassistant/components/samsungtv/bridge.py", line 113, in is_on
    return self._get_remote() is not None
  File "/usr/src/homeassistant/homeassistant/components/samsungtv/bridge.py", line 232, in _get_remote
    self._remote = Remote(self.config.copy())
  File "/usr/local/lib/python3.8/site-packages/samsungctl/remote.py", line 9, in __init__
    self.remote = RemoteLegacy(config)
  File "/usr/local/lib/python3.8/site-packages/samsungctl/remote_legacy.py", line 32, in __init__
    self._read_response(True)
  File "/usr/local/lib/python3.8/site-packages/samsungctl/remote_legacy.py", line 77, in _read_response
    raise exceptions.ConnectionClosed()
samsungctl.exceptions.ConnectionClosed
```

* add coverage

* pass instead
2021-06-25 07:31:44 +02:00
J. Nick Koston 5695710463
Add mac address to samsungtv config entry data if missing (#51634)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-06-24 08:15:16 -10:00
J. Nick Koston 4722fdf465
Fix race condition in samsungtv turn off (#51716)
- The state would flip flop if the update happened before the TV had fully shutdown
2021-06-10 19:24:30 +02:00
J. Nick Koston ab490bc769
Ensure samsungtv reloads after reauth (#51714)
* Ensure samsungtv reloads after reauth

- Fixes a case of I/O in the event loop

* Ensure config entry is reloaded
2021-06-10 19:23:00 +02:00
J. Nick Koston b3d826f2e2
Fix samsungtv yaml import without configured name (#51204) 2021-05-28 16:06:17 +02:00
Franck Nijhof c5383219f1
Remove stale debug statements from tests (#51059) 2021-05-25 11:52:20 +02:00
J. Nick Koston 45897b59f2
Turn on samsungtv with wakeonlan (#50964)
If we have the mac address from discovery, we can use it to wake
the TV.  Currently the TV goes unavailable when you turn it off
as the only way to turn it back on is wake on lan or via the remote.

Users who are not using host networking can use a script instead.
2021-05-22 15:33:37 -05:00
Simone Chemelli b9a0fb93eb
Add samsungtv dhcp and zeroconf discovery (#48022)
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-05-22 10:41:18 -05:00
Ville Skyttä 153d6e891e
Use config_entries.SOURCE_* constants (#49631) 2021-04-25 11:27:40 +02:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
zetvio 78b4c3981f
Use reference strings in Samsung TV config flow (#41248)
* Use reference strings in samsungtv config flow

* Adjust samsungtv config flow tests
2020-10-05 11:45:35 +02:00
Franck Nijhof 1c2ebdf307
Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
escoand 9c6b019ca9
Better timeout handling in samsungtv integration (#38759)
* handle PlatformNotReady

* set timeout in bridge

* set timeout in test

* Revert "handle PlatformNotReady"

This reverts commit 118ee06ba0.
2020-08-15 20:25:37 +02:00
Kyle Hendricks 0a7dc40712
Fix issue with certain Samsung TVs repeatedly showing auth dialog (#38308)
Through some testing with the samsungtvws library, it was determined
that the issue is related to the short read timeout (1s).  Increasing
the timeout to 10s should solve the issue.
2020-07-28 12:03:56 +02:00
Paulus Schoutsen ec47216388
Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00
Ziv ffa111deb9
Fix exceptions in tests for samsung_tv (#33732) 2020-04-06 11:21:52 +02:00
escoand 2bb29485be
Try all Samsung TV websocket ports (#33001)
* Update bridge.py

* add test

* silence pylint

* correct pylint

* add some tests

* Update test_media_player.py
2020-03-21 16:50:18 +01:00
escoand f9a0b4b3cf
Fix legacy Samsung TV (#32719)
* Update bridge.py

* Update test_init.py
2020-03-12 10:29:11 +01:00
Paolo Tuninetto a8758ed3a1
Add support for newer SamsungTV models (#31537)
* Added support for newer SamsungTV models

* Fixed legacy port

* store token in HA config directory

* Change token name

* rebasing and exception handling

* implement update

* fix error creating mediaplayer

* Debug logging

* Increase timeout

* Restore update timeout

* Store token_file path in config_entry

* Introduction of samsung bridge class

* Added bridge class functions

* Code cleanup

* more fixes

* Begin testing

* samsungtvws 1.2.0

* Config flow tests 0.1

* Fixed some mediaplayer tests

* Fixed fixture in media player

* use of constants and turn off

* more media player tests

* samsungtvws 1.3.1 and other fixes

* WS tv update rewritten

* more tests

* test_init

* fixed tests

* removed reset mock

* tests reset mock

* close_remote and tests

* deprecate port config

* deprecate port config 2

* deprecate port config 3

* save token only if needed

* cleanup

* better websocket protocol detection

* config removal
2020-03-10 11:48:09 +01:00
Paulus Schoutsen d4615fd432
Freeze config entry data (#32615)
* Freeze config entry data

* Fix mutating entry.data

* Fix config entry options tests
2020-03-09 14:07:50 -07:00
escoand 0823ee4385
Fix exceptions when using newer Samsung TVs (#31602)
* try to fix websocket problems

* use tuple

* catch websocket exceptions

* typo
2020-02-08 12:03:35 +01:00
escoand 4550968316
Samsung TV refinements (#31248)
* use st not deviceType

* show model in flow title

* Update strings.json

* add re-auth to entity

* add re-auth to config_flow

* handle auth popup better

* use media player domain const

* fix tests

* rename not_found to not_successful

* authz not authn

* Update media_player.py

* Update config_flow.py

* Update media_player.py

* Update test_media_player.py

* finalize re-auth

* fix ssd tests

* better naming

* fix ip-address-mock serialization

* fix turn_on_action serialization

* add type of hass object

* fix acces denied test

* remove half-added typing

* async get ip address

* fix pylint
2020-02-03 20:34:02 +01:00
Paolo Tuninetto fc95744bb7 Change Samsung TV state detection (#30236)
* Changed Samsung TV state detection

* Trying codecov fix

* Update Rewritten

* Changed update method

* Timeout handling

* Fixed autodetect tests

* Fixed last test

* Added test to complete codecov

* Removed state settings in send_key method

* Fixed pylint

* Fixed some tests

* codecov fix
2020-01-23 21:43:30 +01:00
escoand ef05aa2f39 Add Samsung TV config flow (#28306)
* add config flow

* add tests

* add user step error handling

* remove unload function

* add missing test file

* handle authentication correctly

* remove old discovery mode

* better handling of remote class

* optimized abort messages

* add already configured test for user flow

* Import order

* use ip property instead context

* Black

* small syntax

* use snake_case

* Revert "use ip property instead context"

This reverts commit 91502407eb216f8a0b1b90e3e6fb165b81406f8f.

* disable wrong pylint errors

* disable wrong no-member

* Try to fix review comments

* Try to fix review comments

* Fix missing self

* Fix ip checks

* methods to functions

* simplify user check

* remove user errors

* use async_setup for config

* fix after rebase

* import config to user config flow

* patch all samsungctl

* fix after rebase

* fix notes

* remove unused variable

* ignore old setup function

* fix after merge

* pass configuration to import step

* isort

* fix recursion

* remove timeout config

* add turn on action (dry without testing)

* use upstream checks

* cleanup

* minor

* correctly await async method

* ignore unused import

* async call send_key

* Revert "async call send_key"

This reverts commit f37057819f.

* fix comments

* fix timeout test

* test turn on action

* Update media_player.py

* Update test_media_player.py

* Update test_media_player.py

* use async executor

* use newer ssdp data

* update manually configured with ssdp data

* dont setup component directly

* ensure list

* check updated device info

* Update config_flow.py

* Update __init__.py

* fix duplicate check

* simplified unique check

* move method detection to config_flow

* move unique test to init

* fix after real world test

* optimize config_validation

* update device_info on ssdp discovery

* cleaner update listener

* fix lint

* fix method signature

* add note for manual config to confirm message

* fix turn_on_action

* pass script

* patch delay

* remove device info update
2020-01-10 03:19:10 +01:00
Bas Nijholt 23b92b2a56 Sort imports according to PEP8 for components starting with "S" (#29777) 2019-12-09 14:38:01 +01:00
escoand 430f7bdfd4 Catch samsungtv websocket exceptions (#28849)
* catch websocket exceptions

* fix syntax

* use exceptions from base class

* add comments

* add test
2019-11-25 10:45:50 +01:00
Jay Newstrom cb63a9d7e1 Add broadcast address for WOL and samsungtv (#28819)
* Add broadcast address for WOL and samsungtv

* Fix style

* Fix tests, and add new test for new functionality

* Fix code style
2019-11-17 13:17:22 +01:00
Paolo Tuninetto b4ccc0202a Change keys for Samsung TV next and prev track command (#28213) 2019-11-15 09:53:16 +01:00
Quentame 136f1f7fe9 Move imports in samsungtv component (#27775)
* Move imports in samsungtv component

* Fix tests

* Fix review 1

* Fix review 2

* wakeonlan is a module
2019-11-05 15:04:19 +01:00
escoand ecf2e9c0ab Fix flaky Samsung TV tests (#28503) 2019-11-03 18:32:01 +01:00
escoand 9661efc312 Add Samsung TV automatic protocol detection (#27492)
* added automatic protocol detection

* fix logger tests

* fix async tests

* add missin const.py

* fix log formatting

* wait for first update call

* migrate first tests

* migrated all test functions

* started to use state machine

* updated all tests to use async_setup_component

* slove hints

* update tests

* get state at correct position

* remove impossible tests

* fix autodetect tests

* use caplog fixture

* add test for duplicate

* catch concrete exceptions

* don't mock samsungctl exceptions

* add test for discovery

* get state when possible

* add test for autodetect without connection
2019-10-25 14:32:12 +02:00
kennedyshead 98ac8a217d Adding device_class to samsungtv (#28168)
* Adding device_id to samsungtv

* Lint

* Adding test
2019-10-24 13:41:07 -07:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
escoand 73008885c8 Add source selection to Samsung TV media player (#22612)
* add source selection

* return generic list

* remove useless timeout

* Fix test

* Add test for select_source

* Add negative source test

* Change order

* Arghhh

* Add hass object

* Simplify source list

Co-Authored-By: escoand <escoand@users.noreply.github.com>
2019-06-17 15:00:11 -07:00
Penny Wood f195ecca4b Consolidate all platforms that have tests (#22109)
* Moved climate components with tests into platform dirs.

* Updated tests from climate component.

* Moved binary_sensor components with tests into platform dirs.

* Updated tests from binary_sensor component.

* Moved calendar components with tests into platform dirs.

* Updated tests from calendar component.

* Moved camera components with tests into platform dirs.

* Updated tests from camera component.

* Moved cover components with tests into platform dirs.

* Updated tests from cover component.

* Moved device_tracker components with tests into platform dirs.

* Updated tests from device_tracker component.

* Moved fan components with tests into platform dirs.

* Updated tests from fan component.

* Moved geo_location components with tests into platform dirs.

* Updated tests from geo_location component.

* Moved image_processing components with tests into platform dirs.

* Updated tests from image_processing component.

* Moved light components with tests into platform dirs.

* Updated tests from light component.

* Moved lock components with tests into platform dirs.

* Moved media_player components with tests into platform dirs.

* Updated tests from media_player component.

* Moved scene components with tests into platform dirs.

* Moved sensor components with tests into platform dirs.

* Updated tests from sensor component.

* Moved switch components with tests into platform dirs.

* Updated tests from sensor component.

* Moved vacuum components with tests into platform dirs.

* Updated tests from vacuum component.

* Moved weather components with tests into platform dirs.

* Fixed __init__.py files

* Fixes for stuff moved as part of this branch.

* Fix stuff needed to merge with balloob's branch.

* Formatting issues.

* Missing __init__.py files.

* Fix-ups

* Fixup

* Regenerated requirements.

* Linting errors fixed.

* Fixed more broken tests.

* Missing init files.

* Fix broken tests.

* More broken tests

* There seems to be a thread race condition.
I suspect the logger stuff is running in another thread, which means waiting until the aio loop is done is missing the log messages.
Used sleep instead because that allows the logger thread to run. I think the api_streams sensor might not be thread safe.

* Disabled tests, will remove sensor in #22147

* Updated coverage and codeowners.
2019-03-18 23:07:39 -07:00