Movie mode lighting automation

How do I do this? Is there a particular node I need insert into the flow?? I have checked the logs and I think the culprit is the Hue Bridge becomes unavailable thus making all entities unavailable. Though it doesn’t seem to affect activities when I use the Hue app on my mobile or tablet.

In this case you could try adding another condition to your state trigger, saying that the previous state of the hue bulb is NOT unavailable.

Like this??

image

no, try it like this for the condition itself.
image

& change current state to previous state :slight_smile:

Got it…thanks!

Bummer…that didn’t work! The lights came on 8 times while we were watching a 40min TV Show. And, none of the features of the second switch worked at all!

Something very screwy going on with my flow

You should first find out what exactly makes your automation go haywire.
i.e.: What device frequently changes to being unavailable?
And then, it might be good to also find out why. Because this is not normal behaviour.
Currently, we are filtering out the unavailable state of media_player.kodi_ht.

Maybe its actually your HT Power? Or your Hue?
Try to find out what device is the troublemaker

I’ve done some further investigation and it appears that the light.home_theatre_lights & light.ht_millenfalcon_switch become unavailable quite regularly. So I have added two constraints to the trigger state node: media_player.kodi_ht to make them both ‘is Not unavailable’.

I also thought it may be due to the Pi3 being in another room to my router. I’ve now moved it next to the router to see if there are any improvements.

I’ve rolled back my firmware to 0.97.0 as I read later versions can cause slow running this may help also reduce the number of log entries.

Let’s see how this goes.

That didn’t work. So I have deleted the previous conditions and changed…

light.home_theatre_lights & light.ht_millenfalcon_switch & light.home_theatre_power & This entity’s to current state is available.

Don’t know what to do if this doesn’t work…maybe move to OpenHab??

Something is seriously wrong in your setup. Maybe we should start from the beginning :slight_smile:
Can you post your current flow please?
And also just quickly highlight with what you are working and what exactly you expect to happen?
i.e.: the HTPower - Is this a Hue controlled WallPlug? etc.

My Flow.

[{“id”:“af16abc1.4fce48”,“type”:“tab”,“label”:“HT Lights”,“disabled”:false,“info”:""},{“id”:“9d77c212.d1457”,“type”:“switch”,“z”:“af16abc1.4fce48”,“name”:“Switch”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“playing”,“vt”:“str”},{“t”:“eq”,“v”:“paused”,“vt”:“str”},{“t”:“eq”,“v”:“idle”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:3,“x”:330,“y”:380,“wires”:[[“17b20ee9.8fef71”,“c7646377.3865e”],[“b65a4f7b.a8717”,“b5276725.27f458”],[“b5276725.27f458”,“b65a4f7b.a8717”]]},{“id”:“b5276725.27f458”,“type”:“api-call-service”,“z”:“af16abc1.4fce48”,“name”:“HT Lights on”,“server”:“a9a818ea.bf9678”,“version”:1,“service_domain”:“light”,“service”:“turn_on”,“entityId”:“light.home_theatre_lights”,“data”:"",“dataType”:“json”,“mergecontext”:"",“output_location”:"",“output_location_type”:“none”,“mustacheAltTags”:false,“x”:599,“y”:230,“wires”:[[“4b71a616.294d08”]]},{“id”:“b65a4f7b.a8717”,“type”:“api-call-service”,“z”:“af16abc1.4fce48”,“name”:“Millen Falc switch on”,“server”:“a9a818ea.bf9678”,“version”:1,“service_domain”:“light”,“service”:“turn_on”,“entityId”:“light.ht_millenfalcon_switch”,“data”:"",“dataType”:“json”,“mergecontext”:"",“output_location”:"",“output_location_type”:“none”,“mustacheAltTags”:false,“x”:629,“y”:350,“wires”:[[“dab0baaf.bebfa8”]]},{“id”:“17b20ee9.8fef71”,“type”:“api-call-service”,“z”:“af16abc1.4fce48”,“name”:“HT Lights off”,“server”:“a9a818ea.bf9678”,“version”:1,“service_domain”:“light”,“service”:“turn_off”,“entityId”:“light.home_theatre_lights”,“data”:"",“dataType”:“json”,“mergecontext”:"",“output_location”:"",“output_location_type”:“none”,“mustacheAltTags”:false,“x”:599,“y”:290,“wires”:[[]]},{“id”:“c7646377.3865e”,“type”:“api-call-service”,“z”:“af16abc1.4fce48”,“name”:“Millen Falc switch off”,“server”:“a9a818ea.bf9678”,“version”:1,“service_domain”:“light”,“service”:“turn_off”,“entityId”:“light.ht_millenfalcon_switch”,“data”:"",“dataType”:“json”,“mergecontext”:"",“output_location”:"",“output_location_type”:“none”,“mustacheAltTags”:false,“x”:629,“y”:410,“wires”:[[]]},{“id”:“5948f058.d4f7c”,“type”:“server-state-changed”,“z”:“af16abc1.4fce48”,“name”:“HT Power”,“server”:“a9a818ea.bf9678”,“version”:1,“entityidfilter”:“light.home_theatre_gpo”,“entityidfiltertype”:“exact”,“outputinitially”:true,“state_type”:“str”,“haltifstate”:"",“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:1,“output_only_on_state_change”:false,“x”:120,“y”:210,“wires”:[[“451ed37a.bbba2c”]]},{“id”:“451ed37a.bbba2c”,“type”:“switch”,“z”:“af16abc1.4fce48”,“name”:“Switch”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“on”,“vt”:“str”},{“t”:“eq”,“v”:“off”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:330,“y”:210,“wires”:[[“5b17a3d2.a02afc”,“b5276725.27f458”,“b65a4f7b.a8717”],[“5b17a3d2.a02afc”]]},{“id”:“5b17a3d2.a02afc”,“type”:“debug”,“z”:“af16abc1.4fce48”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“x”:590,“y”:160,“wires”:[]},{“id”:“f99c168a.ce7888”,“type”:“inject”,“z”:“af16abc1.4fce48”,“name”:"",“topic”:“msg payload”,“payload”:“on”,“payloadType”:“str”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:140,“y”:111,“wires”:[[“451ed37a.bbba2c”]]},{“id”:“3865c4cc.e1ca7c”,“type”:“inject”,“z”:“af16abc1.4fce48”,“name”:"",“topic”:“msg payload”,“payload”:“off”,“payloadType”:“str”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:140,“y”:160,“wires”:[[“451ed37a.bbba2c”]]},{“id”:“45d216e4.16c418”,“type”:“trigger-state”,“z”:“af16abc1.4fce48”,“name”:"",“server”:“a9a818ea.bf9678”,“entityid”:“media_player.kodi_ht”,“entityidfiltertype”:“exact”,“debugenabled”:true,“constraints”:[{“id”:“yes59l3l6cd”,“targetType”:“this_entity”,“targetValue”:"",“propertyType”:“current_state”,“propertyValue”:“new_state.state”,“comparatorType”:“is”,“comparatorValueDatatype”:“str”,“comparatorValue”:“on”},{“id”:“v2owzychq7”,“targetType”:“entity_id”,“targetValue”:“light.home_theatre_power”,“propertyType”:“current_state”,“propertyValue”:“new_state.state”,“comparatorType”:“is”,“comparatorValueDatatype”:“str”,“comparatorValue”:“available”},{“id”:“0mbkrd4gibkc”,“targetType”:“entity_id”,“targetValue”:“light.home_theatre_lights”,“propertyType”:“current_state”,“propertyValue”:“new_state.state”,“comparatorType”:“is”,“comparatorValueDatatype”:“str”,“comparatorValue”:“available”},{“id”:“54nmlwhgh3d”,“targetType”:“entity_id”,“targetValue”:“light.ht_millenfalcon_switch”,“propertyType”:“current_state”,“propertyValue”:“new_state.state”,“comparatorType”:“is”,“comparatorValueDatatype”:“str”,“comparatorValue”:“available”}],“constraintsmustmatch”:“all”,“outputs”:2,“customoutputs”:[],“outputinitially”:false,“state_type”:“str”,“x”:180,“y”:300,“wires”:[[“5b17a3d2.a02afc”,“9d77c212.d1457”],[]]},{“id”:“4b71a616.294d08”,“type”:“debug”,“z”:“af16abc1.4fce48”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“x”:780,“y”:230,“wires”:[]},{“id”:“dab0baaf.bebfa8”,“type”:“debug”,“z”:“af16abc1.4fce48”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“x”:830,“y”:350,“wires”:[]},{“id”:“a9a818ea.bf9678”,“type”:“server”,“z”:"",“name”:“Home Assistant”}]

I am using a Hue bridge to connect to all light switches (HT liights), GPO (HT Power) and Zigbee Smart Outlet Socket (Millen Falc Switch).

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

It had been working for about 2 weeks then started playing up - that was a few weeks ago.

I’m almost ready to give up!

[
    {
        "id": "f60ccadd.46e268",
        "type": "switch",
        "z": "1c68d9b0.20b6d6",
        "name": "Switch",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "paused",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "idle",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "playing",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 330,
        "y": 280,
        "wires": [
            [
                "a5009fb0.4788c",
                "e5cfeb6d.a15f78"
            ],
            [
                "a5009fb0.4788c",
                "e5cfeb6d.a15f78"
            ],
            [
                "ac18ddda.02f9a",
                "40624a14.2a4e74"
            ]
        ]
    },
    {
        "id": "a5009fb0.4788c",
        "type": "api-call-service",
        "z": "1c68d9b0.20b6d6",
        "name": "HT Lights on",
        "server": "84fa2880.b9dee8",
        "version": 1,
        "service_domain": "light",
        "service": "turn_on",
        "entityId": "light.home_theatre_lights",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 590,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "e5cfeb6d.a15f78",
        "type": "api-call-service",
        "z": "1c68d9b0.20b6d6",
        "name": "Millen Falc switch on",
        "server": "84fa2880.b9dee8",
        "version": 1,
        "service_domain": "light",
        "service": "turn_on",
        "entityId": "light.ht_millenfalcon_switch",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 620,
        "y": 260,
        "wires": [
            []
        ]
    },
    {
        "id": "ac18ddda.02f9a",
        "type": "api-call-service",
        "z": "1c68d9b0.20b6d6",
        "name": "HT Lights off",
        "server": "84fa2880.b9dee8",
        "version": 1,
        "service_domain": "light",
        "service": "turn_off",
        "entityId": "light.home_theatre_lights",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 590,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "40624a14.2a4e74",
        "type": "api-call-service",
        "z": "1c68d9b0.20b6d6",
        "name": "Millen Falc switch off",
        "server": "84fa2880.b9dee8",
        "version": 1,
        "service_domain": "light",
        "service": "turn_off",
        "entityId": "light.ht_millenfalcon_switch",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 620,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "da4a806c.86789",
        "type": "server-state-changed",
        "z": "1c68d9b0.20b6d6",
        "name": "HT Power",
        "server": "84fa2880.b9dee8",
        "version": 1,
        "entityidfilter": "light.home_theatre_gpo",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "unavailable",
        "halt_if_type": "str",
        "halt_if_compare": "is_not",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 100,
        "y": 220,
        "wires": [
            [
                "7f6cf9cb.099028"
            ],
            []
        ]
    },
    {
        "id": "7f6cf9cb.099028",
        "type": "switch",
        "z": "1c68d9b0.20b6d6",
        "name": "Switch",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "on",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 330,
        "y": 220,
        "wires": [
            [
                "a5009fb0.4788c",
                "e5cfeb6d.a15f78"
            ],
            [
                "ac18ddda.02f9a",
                "40624a14.2a4e74"
            ]
        ]
    },
    {
        "id": "89a12e59.008f6",
        "type": "server-state-changed",
        "z": "1c68d9b0.20b6d6",
        "name": "Kodi HT",
        "server": "84fa2880.b9dee8",
        "version": 1,
        "entityidfilter": "media_player.kodi_ht",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "unavailable",
        "halt_if_type": "str",
        "halt_if_compare": "is_not",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 100,
        "y": 280,
        "wires": [
            [
                "f60ccadd.46e268"
            ],
            []
        ]
    },
    {
        "id": "84fa2880.b9dee8",
        "type": "server",
        "z": "",
        "name": "Home Assistant"
    }
]

Very simple:


But should work…

FYI… not sure if it still exists, but in the past there was a plugin for Kodi that allowed you to do the same… just directly from Kodi. Whenever something was playing it was turning off the lamps (or dimmed) specified from Hue.
Not sure what it was called, it was kind of an ambilight clone as well.

Thanks for this new flow Marcus.

Tried it and still have the same issue of the lights coming on randomly.

After extensive research it seems the Hue bridge frequently becomes unavailable and I have tried changing the Hue Zigbee channels and that has limited results.

I’ve added this too my config also…

hue:
bridges:
- host: 192.168.x.x
allow_unreachable: true
allow_hue_groups: false

without success. The next option is to factory reset the Hue and add all lights and switches. Not so much of a problem as I only have about 8 entities at present and one flow to control lights turning on at set times and turning off as required. This one works always!

I’ll keep working on this problem ‘unavailable’ problem before I concentrate on getting this flow working 100%. Tho, this may take some time as I have wrecked my back and have very limited movement.

Yes thats a good idea, first get the Hue to work :slight_smile:
However, in my above flow, a Hue light turning unavailable and come back online should not turn them on as there is no trigger happening.

One alternative i was thinking about: Do you have stable electricity? Stable Power? Maybe your bulbs loose power and then turn on once they come back to power. You can also try to set the PowerOn State in the Hue Hub to the previous state they were before they lost power.

Dodgy power is not a problem in my home.

However, I have a couple of new issues that have appeared in the past couple of days…

1/ I have a second instance of a Hue bridge in my HA - don’t know how that got there as I only have one Hue bridge
2/ More of a problem is my HA is very slow or doesn’t allow me to connect via duckdns. It’s installed on a Pi3 with 64gb Scandisk card. After unplugging it for a while it behaves tho not always, and clearing cache in all browsers has help a bit.

More researching on the cards for me…

Some components do create a virtual HUE bridge on your local network to make their devices visible to Alexa or Google home.

I had the same performance issues as described by you and separated my HA from Node-Red by installing NR onto a dedicated RPI3.

Interested in how you achieved this! Care to share??

I am almost ready to dump everything, however if node red on the Pi runs smoothly (does it need HA to be running?) I’ll go with this.

My primary system is NR in meanwhile and it runs very smooth on RPI3 and does not need HA at all. NR is much more flexible and I can realize complex automation tasks much faster.

However, there are a few benefits of having HA

  • The User-Interface and especially dashboards are easier/nicer
  • New components are usually faster supported by HA
  • The community is very supportive in case there are any questions or issues

Im using HA as test system for new devices until I have the support on NodeRed

PI-Install with SSH access:

  • Download the latest image from Raspbian. I never use the desktop version to keep the system light
  • Install the image with Etcher onto your SD-Card (32GB should be ok)
  • Attach the RPI to a monitor and use a USB Keyboard
  • Insert the SD-Card and power-up
  • use the below commands to configure your RPI and activate SSH
$ sudo apt -y update
$ sudo apt -y upgrade
$ sudo raspi-config
– config hostname
– config timezone
– enable ssh

$ sudo shutdown -r now
login via ssh
  • Now you can remote-login with any SSH tool (like PUTYY)

Node-Red-Install

$ sudo apt -y install npm
$ sudo npm install -g n
$ sudo n stable
$ bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
$ cd ~/.node-red
$ npm rebuild

Now setup Autostart on boot

$ sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/nodered.service -O /lib/systemd/system/nodered.service
$ sudo systemctl daemon-reload
$ sudo systemctl enable nodered.service
$ sudo shutdown -r now

Your system should be up and running now!!

Off to get a 32gb card and give this a go!

Thanks for the tutorial!!

Before I get into this, will this setup of NR allow me to schedule light events (On/Off at set times) and,

how difficult will it be to get the Movie Mode Lighting Automation up and running?

I’m not a programmer, just a ‘Joe Bloggs’ who’d like to have some reliable automations working.