Movie mode lighting automation

That’s correct I am, I know i need to upgrade it but that’s going to involve replacing a whole bunch of nodes as i’m still using the old node-red-contrib-home-assistant package so I’ve held off doing it for now.

Thanks for the tip, I’d be interested to see what you’ve got. I wasn’t aware of a dedicated node for Kodi!

Yes, the KODI node really works awesome and you can utilize the entire JSON functionality provided by KODI.

As I’m using WIFI and/or Ethernet on my KODI boxes I have generated 2 enry and exit points per KODI (e.g. TS Kodi)

There is no light control in this example as I have my light automation in dedicated flows calling from these playing states.

here is a sample video for the playing status

[{"id":"49c63ea8.8a147","type":"kodi-in","z":"2a59a65.117295a","name":"TS Kodi","controller":"85f19228.2703f","x":90,"y":540,"wires":[["bc46bb0c.f41c38","8c2c552.d1370a8","4b099f8d.4b985"]]},{"id":"bc46bb0c.f41c38","type":"switch","z":"2a59a65.117295a","name":"ScreenSaver","property":"payload.notification","propertyType":"msg","rules":[{"t":"eq","v":"GUI.OnScreensaverActivated","vt":"str"},{"t":"eq","v":"GUI.OnScreensaverDeactivated","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":520,"wires":[["820787c8.cf2bb8"],["d26c116f.7a294"]]},{"id":"8c2c552.d1370a8","type":"debug","z":"2a59a65.117295a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":220,"y":680,"wires":[]},{"id":"4b099f8d.4b985","type":"switch","z":"2a59a65.117295a","name":"Playing","property":"payload.notification","propertyType":"msg","rules":[{"t":"eq","v":"Player.OnPlay","vt":"str"},{"t":"eq","v":"Player.OnPause","vt":"str"},{"t":"eq","v":"Player.OnStop","vt":"str"},{"t":"eq","v":"System.OnQuit","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":115,"y":871,"wires":[["d26c116f.7a294","2c274dda.5291f2"],["932f50f4.bfa01"],["a78d0782.d2f0f8"],["3560a381.17070c"]]},{"id":"f5d34f7d.bd52c","type":"kodi-in","z":"2a59a65.117295a","name":"TS Kodi","controller":"5d6b605e.1f277","x":90,"y":580,"wires":[["bc46bb0c.f41c38","4b099f8d.4b985","8c2c552.d1370a8"]]},{"id":"820787c8.cf2bb8","type":"link out","z":"2a59a65.117295a","name":"","links":["395ff4f8.f09efc"],"x":475,"y":520,"wires":[]},{"id":"d26c116f.7a294","type":"link out","z":"2a59a65.117295a","name":"TV on","links":["88116503.c233a8","be34b4e.9beed48"],"x":475,"y":600,"wires":[]},{"id":"2c274dda.5291f2","type":"template","z":"2a59a65.117295a","name":"Movie started","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n    \"cmd\": \"GUI.ShowNotification\",\n    \"args\": {\n        \"title\": \"Movie started [xx%]\",\n        \"message\": \"---\"\n    }\n}","output":"str","x":755,"y":831,"wires":[["4a9f7b98.83b554","1ee73792.439c88"]]},{"id":"932f50f4.bfa01","type":"template","z":"2a59a65.117295a","name":"Movie paused","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n    \"cmd\": \"GUI.ShowNotification\",\n    \"args\": {\n        \"title\": \"Movie paused [xx%]\",\n        \"message\": \"---\"\n    }\n}","output":"str","x":755,"y":871,"wires":[["4a9f7b98.83b554"]]},{"id":"a78d0782.d2f0f8","type":"template","z":"2a59a65.117295a","name":"Movie stop","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n    \"cmd\": \"GUI.ShowNotification\",\n    \"args\": {\n        \"title\": \"Movie stopped [xx%]\",\n        \"message\": \"---\"\n    }\n}","output":"str","x":745,"y":911,"wires":[["4a9f7b98.83b554"]]},{"id":"3560a381.17070c","type":"link out","z":"2a59a65.117295a","name":"TS TV off","links":["395ff4f8.f09efc"],"x":335,"y":940,"wires":[]},{"id":"f46e88ca.a57b38","type":"inject","z":"2a59a65.117295a","name":"off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":580,"wires":[["820787c8.cf2bb8"]]},{"id":"dc5d7027.69f59","type":"inject","z":"2a59a65.117295a","name":"on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":620,"wires":[["d26c116f.7a294"]]},{"id":"4a9f7b98.83b554","type":"change","z":"2a59a65.117295a","name":"+ Title","rules":[{"t":"change","p":"payload","pt":"msg","from":"---","fromt":"str","to":"Kodi_TS.title","tot":"global"},{"t":"change","p":"payload","pt":"msg","from":"xx","fromt":"str","to":"Kodi_TS.progress","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":965,"y":871,"wires":[["d4b36daa.426ca"]]},{"id":"1ee73792.439c88","type":"link out","z":"2a59a65.117295a","name":"TV on -","links":["5ddf80e1.4b98c"],"x":1090,"y":831,"wires":[]},{"id":"d4b36daa.426ca","type":"link out","z":"2a59a65.117295a","name":"TS Kodi","links":["607f0588.d0e7bc"],"x":1090,"y":871,"wires":[]},{"id":"85f19228.2703f","type":"kodi-controller","z":"","name":"TS_Kodi_wifi","host":"","port":"9090"},{"id":"5d6b605e.1f277","type":"kodi-controller","z":"","name":"Kodi_ts_lan","host":"","port":"9090"}]

and a sample flow for notifications on the TV using KODI

[{“id”:“49c63ea8.8a147”,“type”:“kodi-in”,“z”:“2a59a65.117295a”,“name”:“TS Kodi”,“controller”:“85f19228.2703f”,“x”:90,“y”:540,“wires”:[[“bc46bb0c.f41c38”,“8c2c552.d1370a8”,“4b099f8d.4b985”]]},{“id”:“bc46bb0c.f41c38”,“type”:“switch”,“z”:“2a59a65.117295a”,“name”:“ScreenSaver”,“property”:“payload.notification”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“GUI.OnScreensaverActivated”,“vt”:“str”},{“t”:“eq”,“v”:“GUI.OnScreensaverDeactivated”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:250,“y”:520,“wires”:[[“820787c8.cf2bb8”],[“d26c116f.7a294”]]},{“id”:“8c2c552.d1370a8”,“type”:“debug”,“z”:“2a59a65.117295a”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“x”:220,“y”:680,“wires”:[]},{“id”:“4b099f8d.4b985”,“type”:“switch”,“z”:“2a59a65.117295a”,“name”:“Playing”,“property”:“payload.notification”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“Player.OnPlay”,“vt”:“str”},{“t”:“eq”,“v”:“Player.OnPause”,“vt”:“str”},{“t”:“eq”,“v”:“Player.OnStop”,“vt”:“str”},{“t”:“eq”,“v”:“System.OnQuit”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:4,“x”:115,“y”:871,“wires”:[[“d26c116f.7a294”,“2c274dda.5291f2”],[“932f50f4.bfa01”],[“a78d0782.d2f0f8”],[“3560a381.17070c”]]},{“id”:“f5d34f7d.bd52c”,“type”:“kodi-in”,“z”:“2a59a65.117295a”,“name”:“TS Kodi”,“controller”:“5d6b605e.1f277”,“x”:90,“y”:580,“wires”:[[“bc46bb0c.f41c38”,“4b099f8d.4b985”,“8c2c552.d1370a8”]]},{“id”:“820787c8.cf2bb8”,“type”:“link out”,“z”:“2a59a65.117295a”,“name”:"",“links”:[“395ff4f8.f09efc”],“x”:475,“y”:520,“wires”:[]},{“id”:“d26c116f.7a294”,“type”:“link out”,“z”:“2a59a65.117295a”,“name”:“TV on”,“links”:[“88116503.c233a8”,“be34b4e.9beed48”],“x”:475,“y”:600,“wires”:[]},{“id”:“2c274dda.5291f2”,“type”:“template”,“z”:“2a59a65.117295a”,“name”:“Movie started”,“field”:“payload”,“fieldType”:“msg”,“format”:“handlebars”,“syntax”:“mustache”,“template”:"{\n “cmd”: “GUI.ShowNotification”,\n “args”: {\n “title”: “Movie started [xx%]”,\n “message”: “—”\n }\n}",“output”:“str”,“x”:755,“y”:831,“wires”:[[“4a9f7b98.83b554”,“1ee73792.439c88”]]},{“id”:“932f50f4.bfa01”,“type”:“template”,“z”:“2a59a65.117295a”,“name”:“Movie paused”,“field”:“payload”,“fieldType”:“msg”,“format”:“handlebars”,“syntax”:“mustache”,“template”:"{\n “cmd”: “GUI.ShowNotification”,\n “args”: {\n “title”: “Movie paused [xx%]”,\n “message”: “—”\n }\n}",“output”:“str”,“x”:755,“y”:871,“wires”:[[“4a9f7b98.83b554”]]},{“id”:“a78d0782.d2f0f8”,“type”:“template”,“z”:“2a59a65.117295a”,“name”:“Movie stop”,“field”:“payload”,“fieldType”:“msg”,“format”:“handlebars”,“syntax”:“mustache”,“template”:"{\n “cmd”: “GUI.ShowNotification”,\n “args”: {\n “title”: “Movie stopped [xx%]”,\n “message”: “—”\n }\n}",“output”:“str”,“x”:745,“y”:911,“wires”:[[“4a9f7b98.83b554”]]},{“id”:“3560a381.17070c”,“type”:“link out”,“z”:“2a59a65.117295a”,“name”:“TS TV off”,“links”:[“395ff4f8.f09efc”],“x”:335,“y”:940,“wires”:[]},{“id”:“f46e88ca.a57b38”,“type”:“inject”,“z”:“2a59a65.117295a”,“name”:“off”,“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:270,“y”:580,“wires”:[[“820787c8.cf2bb8”]]},{“id”:“dc5d7027.69f59”,“type”:“inject”,“z”:“2a59a65.117295a”,“name”:“on”,“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:270,“y”:620,“wires”:[[“d26c116f.7a294”]]},{“id”:“4a9f7b98.83b554”,“type”:“change”,“z”:“2a59a65.117295a”,“name”:"+ Title",“rules”:[{“t”:“change”,“p”:“payload”,“pt”:“msg”,“from”:"—",“fromt”:“str”,“to”:“Kodi_TS.title”,“tot”:“global”},{“t”:“change”,“p”:“payload”,“pt”:“msg”,“from”:“xx”,“fromt”:“str”,“to”:“Kodi_TS.progress”,“tot”:“global”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:965,“y”:871,“wires”:[[“d4b36daa.426ca”]]},{“id”:“1ee73792.439c88”,“type”:“link out”,“z”:“2a59a65.117295a”,“name”:“TV on -”,“links”:[“5ddf80e1.4b98c”],“x”:1090,“y”:831,“wires”:[]},{“id”:“d4b36daa.426ca”,“type”:“link out”,“z”:“2a59a65.117295a”,“name”:“TS Kodi”,“links”:[“607f0588.d0e7bc”],“x”:1090,“y”:871,“wires”:[]},{“id”:“85f19228.2703f”,“type”:“kodi-controller”,“z”:"",“name”:“TS_Kodi_wifi”,“host”:“”,“port”:“9090”},{“id”:“5d6b605e.1f277”,“type”:“kodi-controller”,“z”:"",“name”:“Kodi_ts_lan”,“host”:“”,“port”:“9090”}]

I hope it helps

Yeah, if you’re not using the websocket version a lot of my flow won’t work correctly.

The upgrade should be pretty painless. You don’t need to replace any nodes just check your poll-state and current-state nodes for it outputting what you expect it to output.

Right, just read the migration notes on the node’s page. Potentially a stupid question, but how can I remove the old package in order to add the new one? As I have nodes in use it doesn’t allow me.

Perfect, thanks! I had to jump through some extra hoops as I run stuff in containers but that was spot on.

Sorry to hijack this tread… I am after some assistance to troubleshoot my first node-red flow.

I have two lights working with Phillips Hue app…HT Lights and Millen Falc switch. And I have Kodi on a HTPC that I’d like them to interact with.

Note: as my HT is in a dedicated room that is pitch black I only want my lights to turn off and on at their current preset levels.

So…What I’d like is:

  • Turn off lights when a movie or tv show is playing
  • Turn lights on when a movie or tv show is paused
  • Turn lights on when a movie or tv show is finished or stopped

Here is my node-red config - it worked a couple of times but since I added the HT Power node (tried to have the one action to turn power to HT on and also turn lights on and have them behave as per above, but this is not occurring) nothing happens. I am currently turning HT Lights and Millen Falc switch on and off via the Hue app.

The ultimate aim is to turn on the all HT lights and power with the HT Power switch via the Hue app. I am using Yatse remote app as my remote control for Kodi running on an Android tablet.

Any/all assistance gratefully received!

The events you are asking for are already provided by your Kodi - node … I’m using these events successfully in my switch-node … looks like you are doing that as well

The only issue I see in your flow is the “Trigger State Kodi HT” which does not make sense in this place as it will impact the status-update from your “Kodi HT” (green) … you should move that trigger check somewhere else!

Ok…great…Ill try this and report back!

I made some changes and it works pretty much like I want…except the HT lights turn on randomly while watching movies and tv shows.

I have also notice the random action of the HT lights turning on occurs randomly through the night as well.

What could be causing this??

This is my current config…

I have disconnected the links between HT Power and Ht Lights and the trigger states to avoid any random activity.

Since disconnect the nodes the HT lights still come on randomly…very strange! What could be the issue??
I have turned off the Pi for now so no HA until this is sorted.

Those trigger-state nodes probably aren’t doing exactly what you think they’re doing. They’re normally used as a start of a flow not as a conditional.

I’m totally confused what I need to do…

All I want is:-
Turn on the HT Power via Hue App (this turns on power to equip rack) then through the flow turn on HT Lights and Millen Falc Power (effects lighting)

Then when a movie or tv show is playing:-

  • Turn lights off, then
  • Turn lights on when a movie or tv show is paused, then
  • Turn lights on when a movie or tv show has stopped.

The switch node’s configured with… on. off, playing, paused, idle (from top to bottom).

I have disconnected all flows now.

Yes you probably can get rid of either the trigger-state nodes the state nodes. The trigger state nodes will always fire if the conditions are met, even if there is no previous incoming payload from another node.

So basically, you only need to:

  1. check the state of the HT Power (make sure to select the option of: Only update on state change) and then turn on (off) the power to the lights (i’d use a switch node for that too).
  2. Check the state of KODI and turn off/on the lights based on the status with your switch node.

If the lights are only ever on if the HT Power is on, then you can also skip the state check of the lights.

Is this what you mean AlmostSerious??

After I turn on the HT Power via the Hue App, HT Power & the HT Lights & Millen Falc switch turn on but there is no change to them when I press play, pause or stop on Kodi…they remain on.

Seems fine. If it doesn’t change your lights when paused, playing etc then it seems something is wrong with handling of the state.

I see that you changed the node from a state node to a udp/tcp? node.

Not sure what exactly you are using to check the current state of your kodi. You might need to check the payloads via the debug node to make sure your switch node can handle it the way you want it to.

If you can post the debug node output (full message) then we can help you in identifying the correct msg to use. (Unfortunately i dont use KODI myself to quickly check on my instance)


I have changed to this config and all seems to be working the way I want… thanks for you input!!

I thought I had to have the Kodi udp/tcp node linked to the Trigger State Kodi HT node for this to work…I removed it and added the Trigger State Kodi HT state node.

One additional function I’d like, is when I shutdown Kodi via the remote app on my tablet, the HT Power turns off thus eliminating one action…how do I achieve this??

Update: Something is amiss…the lights came on randomly last night while we were watching shows. I was able to turn them off using the hue app - is the Trigger State Kodi HT doing this??

  1. Can you share an image of your Trigger State Config?
  2. Did you select the “output only on state change” in the HT Power State Node?

You want to turn off all the lights when the HT Power turns off?
Easy, use the same logic as with the switch for the HT Power State. On = Turn On Light, Off = Turn Off Light.

Yes…It works as expected. Though now that is all that happens. When I watch a Movie or TV Show the lights stay on.

Got it!