Commit Graph

59 Commits (d0e5e51863d7649c19bab67f87b0d147d030243c)

Author SHA1 Message Date
epenet de130d3b28
Update REST api mocking in SamsungTV (#68172)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-28 09:04:19 -10:00
J. Nick Koston 6cec53bea1
Add support for finding the samsungtv MainTvAgent service location (#68763) 2022-03-27 22:01:07 -10:00
epenet c024033dae
Add Upnp volume control/status to SamsungTV (#68663)
Co-authored-by: epenet <epenet@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-03-27 12:27:24 -10:00
J. Nick Koston b5496441ae
Use new samsungtv exception to detect when reauth is needed (#68762) 2022-03-27 12:12:32 -10:00
J. Nick Koston cc75cebfc5
Add support for setting up encrypted samsung tvs from config flow (#68717)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-27 10:30:45 -10:00
epenet b13e14b80c
Add command support to SamsungTV H/J models (#68301)
Co-authored-by: epenet <epenet@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-03-24 07:58:58 -10:00
epenet 9ba0475644
Use callback to get app_list in SamsungTV (#68506)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-23 11:12:12 -10:00
epenet df6cc94b25
Cleanup SamsungTV following dependency bump (#68562)
* send_command -> send_commands

* Remove TODO

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-23 20:35:58 +02:00
epenet 87378016c1
Add basic support for SamsungTV encrypted models (#68500)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-22 00:11:41 -10:00
Paulus Schoutsen 8bbbd1947d
Raise if referenced entity does not support service (#68394) 2022-03-20 16:01:58 -07:00
epenet 23b8229143
Adjust ms.remote.control error logging in SamsungTV (#67988)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-12 01:20:04 -10:00
epenet d12118a425
Fix reauth trigger in SamsungTV (#67850)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-08 11:02:00 +01:00
epenet 36049ac514
Batch send commands in SamsungTV (#67847)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-08 10:10:17 +01:00
epenet 6f38eda114
Adjust power_off for TheFrame in SamsungTV (#67841)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-08 08:20:58 +01:00
epenet 1793c29fac
Move key sequences to bridge in SamsungTV (#67762)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-08 07:46:34 +01:00
epenet c70bed86ff
Adjust websocket bridge logging in SamsungTV (#67809)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-07 23:31:57 +01:00
epenet c5f7e7d1b0
Refactor run app in SamsungTV (#67616)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-04 14:37:27 -10:00
epenet 8e3b0f6554
Cleanup mac fixtures in samsungtv tests (#67529)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-03 08:07:08 -10:00
epenet 74483d2669
Fix Samsung TV state when the device is turned off (#67541)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-03 08:06:33 -10:00
epenet b8861578ff
Implement async websocket in samsungtv (#67127)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-03-02 09:30:33 -10:00
epenet 1556868d56
Use async rest api in SamsungTV (#67369)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-28 09:53:42 -10:00
epenet 715d7f70f0
Adjust SamsungTV abstraction layer (#67216)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-25 17:15:45 +01:00
epenet 3aa18ea5d8
Add installed apps to samsungtv sources (#66752)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-18 13:33:49 -08:00
epenet 8bf19655f1
Fix samsung mocks (#66765)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-17 13:04:48 -08:00
epenet 6d0a06c57a
Add type hints in samsungtv tests (#66632)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-17 12:47:58 -08:00
epenet 0138caa277
Fix side_effect patching in samsungtv tests (#66651)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-16 12:40:11 -08:00
epenet 2d33e435b9
Fix token refresh in samsungtv (#66533) 2022-02-16 12:28:01 -08:00
epenet 14e48bac3a
Fix SamsungTVWS mocking in samsungtv tests (#66650)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-16 12:13:11 -08:00
epenet cf5652737a
Cleanup samsungtv tests (#66570)
* Drop unused init method

* Add type hints to media_player tests

* Adjust test_init

* Adjust media_player

* Add type hints to conftest

* Use Mock in test_media_player

* Use lowercase in test_init

* Use relative import in diagnostics

* Add type hints to config_flow

* Adjust coveragerc

* Make gethostbyname autouse

* Cleanup gethostbyname and remote fixtures

* Drop unused fixtures

* Undo type hints and usefixtures on media_player

* Undo type hints and usefixtures in test_init

* Undo type hints in conftest

* Undo usefixtures in test_config_flow

* Format

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-02-16 09:29:52 +01:00
Franck Nijhof 4732e37005
Remove passing loop into sleep in SamsungTV (#66030) 2022-02-07 20:08:54 +01:00
Robert Hillis 3bd1f00b76
Use enums in samsungtv tests (#62195)
* Use enums in samsungtv tests

* uno mas
2021-12-17 16:26:53 +01:00
Erik Montnemery ec52763706
Prevent 3rd party lib from opening sockets in samsungtv tests (#56334) 2021-09-18 22:24:27 -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 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
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01: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
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
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