For WebOS 6. Maybe it works for earlier or later versions...?
Register as an LG WebOS developer
- Then you can connect with your tv:
ares-setup-device
- Check out the code
- Run the following command:
npm install
- Update these fields in
src\index.ts
:
const config: LgTvMqttConfig = {
host: 'YOUR MQTT BROKER HOST',
port: 1883,
username: 'YOUR MQTT USERNAME',
password: 'YOUR MQTT PASSWORD',
deviceID: 'webOSTVService'
};
- Update
package-and-install.bat
with the id of your tv, if needed - Run
package-and-install.bat
The service and app are now installed.
The app is now installed on the home screen, and can be started from there.
Based on a notification (Can MQTT be turned on?) and home-assistant-variables:
alias: "Start TV app MQTT "
description: ""
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: TURN_TV_MQTT_ON
condition: []
action:
- service: var.update
data:
entity_id: var.tv_media_source
- service: media_player.select_source
data:
source: LG TV 2 MQTT TV App
target:
entity_id: media_player.living_room_tv
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: media_player.select_source
data:
source: "{{states('var.tv_media_source')}}"
target:
entity_id: media_player.living_room_tv
mode: single
If you have the MQTT integration enabled in Home Assistant, the service should be auto discovered:
The sensor.webostvservice_play_state
should be updated when you play, pause, or stop an app on the tv.
An example automation:
alias: Turn lights off when playing a movie
description: ""
trigger:
- platform: state
entity_id:
- sensor.webostvservice_play_state
to: playing
condition: []
action:
- service: light.turn_off
target:
entity_id:
- light.some_light_entity
data: {}
mode: single
- Make sure the sdk is working
- Run
ssh prisoner@<tv IP> -p 9922 -i <key location> "/bin/sh -i"
- Run
cat /var/luna/preferences/devmode_enabled
and safe the promting key - in Home Asisstant configuration.yaml:
rest_command: update_lg_dev: url: "https://developer.lge.com/secure/ResetDevModeSession.dev?sessionToken=<the key from step 3>"
- Create an automation:
alias: Reset LG Dev session description: "" trigger: - platform: time at: "01:00:00" condition: [] action: - service: rest_command.update_lg_dev data: {} mode: single
notes:
The key is located in ~/ssh name is webos with your device name
You can ignore the prompting error message
- Use the app to configure the service via the tv
- Send a screenshot/some color information to color lights when pausing
- Renew developer session automatically