Keeping the session alive
So the Developer Mode app has a session timer within itself, this is lasting 50 hours. When 50 hours has passed it will log out and remove your developer mode apps.
This 50 hours doesn't seem to be "powered on hours", instead it's human time passed amount in hours.
This is a bit inconvenient since it would mean that you'd have to go into the Developer Mode app every second day and press a button to not have Jellyfin going away.
First attempt using a systemd timer
Some time passed by, then I listened to Late Night Linux – Episode 183 where they talked about the webOS device manager and that one could use a cron-job to renew the session, so I found this script devmode-reset.sh from webosbrew. So I integrated it into my NixOS configuration to run this script every night.
The script, all the bits worked, like fetching the token from the TV itself
and posting it to LG all seemed to work. I got a 200 OK
back from LG with
some JSON telling me that it seemed fine.
However, the session never extended from this method.
Second attempt using Home Assistant
Then it struck me, Home Assistant is capable of running series of commands,
including sending Wake-On-LAN packages, switching input on TV's, sending fake
button presses and turning of TV's. So it requires to have the line
wake_on_lan:
in configuration.yaml
to enable Wake-On-LAN, then you'd have
to have the Home Assistant integration set up with the TV itself.
So now I have a script in home assistant that does exactly this:
- Turn on TV (then wait 10 seconds)
- Switch to the Developer Mode app (then wait 5 seconds)
- Loop twice to press the DOWN button (then wait 1 second)
- Press the ENTER button (then wait 5 seconds)
- Turn off the TV
This script is then put in an automation that is executed in the middle of the night (if the TV is off to not disrupt any late night TV watching).
This is pulled from my scripts.yaml
:
tv_extend_developer_session_time: alias: 'TV: Extend developer session time' sequence: - service: wake_on_lan.send_magic_packet data: mac: "" # INSERT YOUR TV's MAC ADDRESS HERE # The following options may be required in some network setups. broadcast_address: "xxx.xxx.xxx.xxx" broadcast_port: 9 - delay: hours: 0 minutes: 0 seconds: 10 milliseconds: 0 - service: media_player.select_source data: source: Developer Mode target: entity_id: media_player.lg_webos_smart_tv # MAKE SURE THIS MATCHES YOUR INTEGRATION SETUP - delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0 - repeat: count: 2 sequence: - service: webostv.button data: entity_id: media_player.lg_webos_smart_tv # MAKE SURE THIS MATCHES YOUR INTEGRATION SETUP button: DOWN - delay: hours: 0 minutes: 0 seconds: 1 milliseconds: 0 - service: webostv.button data: entity_id: media_player.lg_webos_smart_tv # MAKE SURE THIS MATCHES YOUR INTEGRATION SETUP button: ENTER - delay: hours: 0 minutes: 0 seconds: 5 milliseconds: 0 - service: media_player.turn_off data: {} target: entity_id: media_player.lg_webos_smart_tv # MAKE SURE THIS MATCHES YOUR INTEGRATION SETUP mode: single icon: mdi:remote-tv
This is pulled from my automations.yaml
:
- alias: 'TV: Extend developer session time automation' description: '' trigger: - platform: time at: 04:00:00 condition: - condition: device device_id: 03387d9e75f0ab1b4e81c6a249f9806e # MAKE SURE THIS MATCHES YOUR INTEGRATION SETUP domain: media_player entity_id: media_player.lg_webos_smart_tv # MAKE SURE THIS MATCHES YOUR INTEGRATION SETUP type: is_off action: - service: script.tv_extend_developer_session_time data: {} mode: single