pylgnetcast
Advanced tools
+21
| The MIT License (MIT) | ||
| Copyright (c) 2016 wokar | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+52
-49
| Metadata-Version: 2.1 | ||
| Name: pylgnetcast | ||
| Version: 0.3.3 | ||
| Version: 0.3.4 | ||
| Summary: Client for the LG Smart TV running NetCast 3 or 4. | ||
@@ -9,50 +9,2 @@ Home-page: https://github.com/Drafteed/python-lgnetcast | ||
| License: MIT | ||
| Description: # Python LG Netcast | ||
| A Python 3 library and command line tool to control LG Smart TV running NetCast 3.0 (LG Smart TV models released in 2012) and NetCast 4.0 (LG Smart TV models released in 2013) via TCP/IP. | ||
| This library was forked from [wokar/pylgnetcast](https://github.com/wokar/pylgnetcast) and is primarily being developed with the intent of supporting [home-assistant](https://github.com/home-assistant/home-assistant). | ||
| ## Dependencies | ||
| * Python 3 | ||
| * [requests](https://pypi.python.org/pypi/requests) package. | ||
| ## API Usage | ||
| ```python | ||
| from xml.etree import ElementTree | ||
| from pylgnetcast import LgNetCastClient, LG_COMMAND, LG_QUERY | ||
| with LgNetCastClient('192.168.1.5', '889955') as client: | ||
| client.send_command(LG_COMMAND.MUTE_TOGGLE) | ||
| data = client.query_data(LG_QUERY.VOLUME_INFO) | ||
| if data: | ||
| print(ElementTree.tostring(data[0], encoding='unicode')) | ||
| ``` | ||
| ## Command Line Tool | ||
| PyLgNetCast also provides a simple command line tool to remote control a TV. | ||
| The tool needs a pairing key to be allowed to send commands to your TV. | ||
| To get the pairing key just start the tool while your TV is on: | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> | ||
| ``` | ||
| This will display the pairing key on your TV. | ||
| To retrieve status information from your TV start the tool like: | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> --pairing_key <pairing key of your TV> | ||
| ``` | ||
| This will display information about the current channel, volume, 3D mode, etc. retrieved from your TV. | ||
| If you want to send a command to your TV, for instance to turn the volume up, check the list of available commands in the pylgnetcast.py file. | ||
| The class LG_COMMAND defines all supported commands and volume up would be defined as 24. | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> --pairing_key <pairing key of your TV> --command 24 | ||
| ``` | ||
| Platform: UNKNOWN | ||
@@ -64,1 +16,52 @@ Classifier: Programming Language :: Python :: 3 | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| # Python LG Netcast | ||
| A Python 3 library and command line tool to control LG Smart TV running NetCast 3.0 (LG Smart TV models released in 2012) and NetCast 4.0 (LG Smart TV models released in 2013) via TCP/IP. | ||
| This library was forked from [wokar/pylgnetcast](https://github.com/wokar/pylgnetcast) and is primarily being developed with the intent of supporting [home-assistant](https://github.com/home-assistant/home-assistant). | ||
| ## Dependencies | ||
| * Python 3 | ||
| * [requests](https://pypi.python.org/pypi/requests) package. | ||
| ## API Usage | ||
| ```python | ||
| from xml.etree import ElementTree | ||
| from pylgnetcast import LgNetCastClient, LG_COMMAND, LG_QUERY | ||
| with LgNetCastClient('192.168.1.5', '889955') as client: | ||
| client.send_command(LG_COMMAND.MUTE_TOGGLE) | ||
| data = client.query_data(LG_QUERY.VOLUME_INFO) | ||
| if data: | ||
| print(ElementTree.tostring(data[0], encoding='unicode')) | ||
| ``` | ||
| ## Command Line Tool | ||
| PyLgNetCast also provides a simple command line tool to remote control a TV. | ||
| The tool needs a pairing key to be allowed to send commands to your TV. | ||
| To get the pairing key just start the tool while your TV is on: | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> | ||
| ``` | ||
| This will display the pairing key on your TV. | ||
| To retrieve status information from your TV start the tool like: | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> --pairing_key <pairing key of your TV> | ||
| ``` | ||
| This will display information about the current channel, volume, 3D mode, etc. retrieved from your TV. | ||
| If you want to send a command to your TV, for instance to turn the volume up, check the list of available commands in the pylgnetcast.py file. | ||
| The class LG_COMMAND defines all supported commands and volume up would be defined as 24. | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> --pairing_key <pairing key of your TV> --command 24 | ||
| ``` | ||
| Metadata-Version: 2.1 | ||
| Name: pylgnetcast | ||
| Version: 0.3.3 | ||
| Version: 0.3.4 | ||
| Summary: Client for the LG Smart TV running NetCast 3 or 4. | ||
@@ -9,50 +9,2 @@ Home-page: https://github.com/Drafteed/python-lgnetcast | ||
| License: MIT | ||
| Description: # Python LG Netcast | ||
| A Python 3 library and command line tool to control LG Smart TV running NetCast 3.0 (LG Smart TV models released in 2012) and NetCast 4.0 (LG Smart TV models released in 2013) via TCP/IP. | ||
| This library was forked from [wokar/pylgnetcast](https://github.com/wokar/pylgnetcast) and is primarily being developed with the intent of supporting [home-assistant](https://github.com/home-assistant/home-assistant). | ||
| ## Dependencies | ||
| * Python 3 | ||
| * [requests](https://pypi.python.org/pypi/requests) package. | ||
| ## API Usage | ||
| ```python | ||
| from xml.etree import ElementTree | ||
| from pylgnetcast import LgNetCastClient, LG_COMMAND, LG_QUERY | ||
| with LgNetCastClient('192.168.1.5', '889955') as client: | ||
| client.send_command(LG_COMMAND.MUTE_TOGGLE) | ||
| data = client.query_data(LG_QUERY.VOLUME_INFO) | ||
| if data: | ||
| print(ElementTree.tostring(data[0], encoding='unicode')) | ||
| ``` | ||
| ## Command Line Tool | ||
| PyLgNetCast also provides a simple command line tool to remote control a TV. | ||
| The tool needs a pairing key to be allowed to send commands to your TV. | ||
| To get the pairing key just start the tool while your TV is on: | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> | ||
| ``` | ||
| This will display the pairing key on your TV. | ||
| To retrieve status information from your TV start the tool like: | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> --pairing_key <pairing key of your TV> | ||
| ``` | ||
| This will display information about the current channel, volume, 3D mode, etc. retrieved from your TV. | ||
| If you want to send a command to your TV, for instance to turn the volume up, check the list of available commands in the pylgnetcast.py file. | ||
| The class LG_COMMAND defines all supported commands and volume up would be defined as 24. | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> --pairing_key <pairing key of your TV> --command 24 | ||
| ``` | ||
| Platform: UNKNOWN | ||
@@ -64,1 +16,52 @@ Classifier: Programming Language :: Python :: 3 | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| # Python LG Netcast | ||
| A Python 3 library and command line tool to control LG Smart TV running NetCast 3.0 (LG Smart TV models released in 2012) and NetCast 4.0 (LG Smart TV models released in 2013) via TCP/IP. | ||
| This library was forked from [wokar/pylgnetcast](https://github.com/wokar/pylgnetcast) and is primarily being developed with the intent of supporting [home-assistant](https://github.com/home-assistant/home-assistant). | ||
| ## Dependencies | ||
| * Python 3 | ||
| * [requests](https://pypi.python.org/pypi/requests) package. | ||
| ## API Usage | ||
| ```python | ||
| from xml.etree import ElementTree | ||
| from pylgnetcast import LgNetCastClient, LG_COMMAND, LG_QUERY | ||
| with LgNetCastClient('192.168.1.5', '889955') as client: | ||
| client.send_command(LG_COMMAND.MUTE_TOGGLE) | ||
| data = client.query_data(LG_QUERY.VOLUME_INFO) | ||
| if data: | ||
| print(ElementTree.tostring(data[0], encoding='unicode')) | ||
| ``` | ||
| ## Command Line Tool | ||
| PyLgNetCast also provides a simple command line tool to remote control a TV. | ||
| The tool needs a pairing key to be allowed to send commands to your TV. | ||
| To get the pairing key just start the tool while your TV is on: | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> | ||
| ``` | ||
| This will display the pairing key on your TV. | ||
| To retrieve status information from your TV start the tool like: | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> --pairing_key <pairing key of your TV> | ||
| ``` | ||
| This will display information about the current channel, volume, 3D mode, etc. retrieved from your TV. | ||
| If you want to send a command to your TV, for instance to turn the volume up, check the list of available commands in the pylgnetcast.py file. | ||
| The class LG_COMMAND defines all supported commands and volume up would be defined as 24. | ||
| ```sh | ||
| python -m pylgnetcast --host <IP of your TV> --pairing_key <pairing key of your TV> --command 24 | ||
| ``` | ||
@@ -0,1 +1,2 @@ | ||
| LICENSE | ||
| README.md | ||
@@ -2,0 +3,0 @@ setup.py |
@@ -13,2 +13,3 @@ """ | ||
| import requests | ||
| import time | ||
| from xml.etree import ElementTree | ||
@@ -166,2 +167,23 @@ | ||
| def get_volume(self): | ||
| volume_info = self.query_data("volume_info") | ||
| if volume_info: | ||
| volume_info = volume_info[0] | ||
| volume = float(volume_info.find("level").text) | ||
| muted = volume_info.find("mute").text == "true" | ||
| return volume, muted | ||
| def set_volume(self, volume): | ||
| current_volume, _ = self.get_volume() | ||
| volume_difference = volume - current_volume | ||
| command = LG_COMMAND.VOLUME_UP if volume_difference > 0 else LG_COMMAND.VOLUME_DOWN | ||
| for i in range(abs(volume_difference)): | ||
| self.send_command(command) | ||
| time.sleep( | ||
| 0.35 | ||
| ) # tv jumps over volume steps after quick consecutive presses | ||
| current_volume, _ = self.get_volume() | ||
| if current_volume != volume: | ||
| self.set_volume(volume) | ||
| def _get_session_id(self): | ||
@@ -168,0 +190,0 @@ """Get the session key for the TV connection. |
+1
-1
@@ -10,3 +10,3 @@ from setuptools import setup | ||
| name='pylgnetcast', | ||
| version='0.3.3', | ||
| version='0.3.4', | ||
| maintainer='Artem Draft', | ||
@@ -13,0 +13,0 @@ maintainer_email='artemon_93@mail.ru', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
18988
7.11%14
7.69%277
7.78%