This is a small util package for WebOS based LG Smart TVs, built by using node module lgtv2
.
For this to work, you'll have to allow LG Connected Apps on your TV, see LG Documentation for more information.
It is assumed that you already have node
and npm
installed on your system.
Clone this git repository and install dependencies:
git clone https://github.com/mgor/lgtv-utils.js.git
cd lgtv-utils.js/
npm install
An example configuration file exists in config/example.json
:
{
"ipaddress": "192.168.0.20",
"maxVolume": 10,
"overstep": {
"period": 60,
"count": 3,
"timeout": 120
}
}
Copy the example configuration to config/default.json
and edit the values according to your preference.
Type: string
Unit: IPv4 address
The LG Smart TV IP address in your network.
Type: integer
Unit: level
Maximum allowed volume level.
If volume goes over maxVolume
, overstep.count
number of times within overstep.period
, the TV will shutoff.
If volume stays below maxVolume
(after exceeding it the first time), the overstep state will be cleared after overstep.timeout
seconds.
Type: integer
Unit: number
Type: integer
Unit: seconds
Type: integer
Unit: seconds
A util that will log all channel and volume changes. It will also monitor the volume level and don't allow going over a configured value. If the configured value is exceeded to many times with in a specified time period, the TV will shutoff.
To run the watcher:
cd lgtv-utils.js/
./watcher
Information is printed to stdout
(colorized) and written in log/watcher.log
If the TV is not on, it will try to connect to it every 5 seconds, hence it will automagically connect if the TV was off when it was started.
The first time you run the util you'll have to allow it as an LG Connected App. The approved credentials will be stored in credentials/
.