OK I have a much better understanding of the timings of various events now.
Using these Items:
Switch TV_PowerSW "TV Power " <television> { autoupdate="true", channel="lgwebos:WebOSTV:f522b9efbf:power" }
String TV_AppLauncher "Application [%s]" { channel="lgwebos:WebOSTV:f522b9efbf:appLauncher"}
I made these rules:
var Timer tv_app_timer = null
rule "WebOS TV Thing Status"
when Thing "lgwebos:WebOSTV:f522b9efbf" changed
then
logInfo("TV Thing Status changed to", getThingStatusInfo("lgwebos:WebOSTV:f522b9efbf").toString)
end
//=====================================================================
rule "test SW"
when Item testSW received command ON
then
var TVthingStatusInfo = getThingStatusInfo("lgwebos:WebOSTV:f522b9efbf")
logInfo("TV STARTING", "Status: " + TVthingStatusInfo.getStatus.toString + " power: " + TV_PowerSW.state.toString + " app: " + TV_AppLauncher.state.toString)
TV_PowerSW.sendCommand(ON) //as status is offline binding sends a WOL
TV_AppLauncher.sendCommand("com.webos.app.hdmi3")
tv_app_timer = createTimer(now,[|
if(TV_AppLauncher.state.toString != "com.webos.app.hdmi3")
{
TV_AppLauncher.sendCommand("com.webos.app.hdmi3")
if(tv_app_timer !== null)tv_app_timer.reschedule(now)
}
else
{
logInfo("TV App Status changed to", TV_AppLauncher.state.toString)
tv_app_timer?.cancel
tv_app_timer = null
}
])
testSW.postUpdate(OFF)
end
I then turned on the TestSW and monitored the logs.
This is a combination of the events.log and openhab.log sorted by the timestamp with a few pertinent entries highlighted with **:
2022-12-08 08:40:39.878 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'testSW' received command ON
2022-12-08 08:40:39.897 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'testSW' changed from NULL to ON
**2022-12-08 08:40:39.908 [INFO ] [penhab.core.model.script.TV STARTING] - Status: OFFLINE power: NULL app: NULL**
2022-12-08 08:40:39.917 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_PowerSW' received command ON
2022-12-08 08:40:39.946 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:39.990 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:39.993 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:39.996 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TV_PowerSW' changed from NULL to ON
2022-12-08 08:40:40.000 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'testSW' changed from ON to OFF
2022-12-08 08:40:42.178 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TV_OnLineSW' changed from OFF to ON
2022-12-08 08:40:43.760 [INFO ] [openhab.event.InboxAddedEvent ] - Discovery Result with UID 'lgwebos:WebOSTV:a3c77ba0-654a-0982-c480-f726662f05b8' has been added.
2022-12-08 08:40:43.761 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'lgwebos:WebOSTV:a3c77ba0-654a-0982-c480-f726662f05b8' to inbox.
2022-12-08 08:40:47.948 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'avrLrZ1_Power' changed from OFF to ON
2022-12-08 08:40:48.866 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:48.870 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:48.882 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:48.970 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:48.977 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:48.994 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.080 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.084 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.095 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.183 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.187 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.200 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.289 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.294 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.306 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.397 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.405 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.421 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.499 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.507 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.536 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.606 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.616 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.632 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.719 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.724 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.736 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.771 [INFO ] [openhab.event.InboxAddedEvent ] - Discovery Result with UID 'onkyo:onkyoUnsupported:b074063b-003b-06BB-b000-0009b074063b' has been added.
2022-12-08 08:40:49.829 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.834 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.847 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:49.934 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:49.940 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:49.958 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:50.039 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:50.044 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:50.056 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:50.146 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:50.153 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:50.166 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:50.253 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:50.261 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:50.279 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:50.360 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:50.376 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:50.389 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:50.469 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:50.475 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:50.496 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:50.645 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:50.651 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become NULL
2022-12-08 08:40:50.663 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
**2022-12-08 08:40:50.736 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'lgwebos:WebOSTV:f522b9efbf' changed from OFFLINE: TV is off to ONLINE: Registering - You may need to confirm pairing on TV.**
**2022-12-08 08:40:50.741 [INFO ] [el.script.TV Thing Status changed to] - ONLINE: @text/online.registering**
2022-12-08 08:40:50.750 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:50.763 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become com.webos.app.hdmi3
2022-12-08 08:40:50.779 [WARN ] [lgwebos.internal.LauncherApplication] - No application list cached for this device lgwebos:WebOSTV:f522b9efbf, ignoring command.
2022-12-08 08:40:50.794 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TV_AppLauncher' changed from NULL to com.webos.app.hdmi3
**2022-12-08 08:40:50.839 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'lgwebos:WebOSTV:f522b9efbf' changed from ONLINE: Registering - You may need to confirm pairing on TV. to ONLINE: Connected**
*2022-12-08 08:40:50.906 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TV_AppLauncher' changed from com.webos.app.hdmi3 to com.webos.app.hdmi4*
**2022-12-08 08:40:53.471 [INFO ] [el.script.TV Thing Status changed to] - ONLINE: @text/online.connected**
2022-12-08 08:40:53.475 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TV_AppLauncher' received command com.webos.app.hdmi3
2022-12-08 08:40:53.483 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TV_AppLauncher' predicted to become com.webos.app.hdmi3
2022-12-08 08:40:53.489 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TV_AppLauncher' changed from com.webos.app.hdmi4 to com.webos.app.hdmi3
**2022-12-08 08:41:22.413 [INFO ] [odel.script.TV App Status changed to] - com.webos.app.hdmi3**
So, with the TV having been turned off for over 8 hours I could initiate a ‘cold start’ starting with:
TV thing OFFLINE
TV Power OFF
TV App NULL
I normally start the TV in ‘com.webos.app.hdmi4’ and this would have been the app in use when the TV was powered off last night.
For this experiment I powered up the TV to use ‘com.webos.app.hdmi3’ .
As seen in the ** highlights:
From status OFFLINE to ONLINE.CONNECTED took approximately 13s.
From app NULL to ‘com.webos.app.hdmi3’ took approximately 41s
What surprised me was the highlight * when after approximately 11s the TV tried to initialise ‘com.webos.app.hdmi4’ the ‘last used’ app despite the cold start app being NULL.
The application list is available less than 0.1secs after status becomes ONLINE.
Bottom line is that I have plenty to work with!