Movie mode lighting automation

  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!

Ah, we’re getting closer :wink:
So your trigger doesnt use any conditions. In that case simply use a state node.
Same as with HT Power.

In order to find out what service call is turning on the lights i might suggest adding some debug nodes.
Connect them after the Lights Service Call amd set them to show the full message. Then let it run in the background until it happens and check the debug field in nodered. It will show you where its coming from and help in identifying a solution.

Hope this is what you mean?? The lights came on when I turned off the HT Power when I had finished viewing and I think it make be due to the fact the last item on the switch was configured as “idle”…

{"topic":"media_player.kodi_ht","payload":"idle","data":{"entity_id":"media_player.kodi_ht","old_state":{"entity_id":"media_player.kodi_ht","state":"off","attributes":{"friendly_name":"Kodi HT","supported_features":54847},"last_changed":"2019-10-12T07:48:16.162318+00:00","last_updated":"2019-10-12T07:48:16.162318+00:00","context":{"id":"be17861eac444ffebf261da0bc11a193","parent_id":null,"user_id":null}},"new_state":{"entity_id":"media_player.kodi_ht","state":"idle","attributes":{"friendly_name":"Kodi HT","supported_features":54847},"last_changed":"2019-10-12T07:48:17.035230+00:00","last_updated":"2019-10-12T07:48:17.035230+00:00","context":{"id":"dbddae0b33354f59aace846802b11ca3","parent_id":null,"user_id":null},"timeSinceChangedMs":10}},"_msgid":"6ea1807a.4468"}

I have since changed ‘idle’ to ‘stopped’ hoping the HT Lights would come on when I tapped stop on my remote app…but they didn’t. I still wanted to scroll through my library for next movie but the lights stayed off…any suggestions??

Ok,… so let me try to understand. You only want the lights to turn on (EVER) if the HT Power is on as well correct? So depending on what you currently emply in your node, either add this constraint to your trigger state, or add an additional current state node that checks for the HT Power after the Kodi State Node. That would stop them turning on when your HT Power is off, but your Kodi reports, idle or stopped.

So… i just created a mockup of your setup in my NodeRed.
As i dont have your devices, i just replaced the HT Power with a switch and the Kodi with one of my plex players.
Please try it out for yourself.
Works fine for me.

[
    {
        "id": "fdb3cb0b.429ab8",
        "type": "server-state-changed",
        "z": "6b8efe0d.bc75e",
        "name": "HT POWER",
        "server": "2fba4297.e4145e",
        "version": 1,
        "entityidfilter": "switch.adguard_parental_control",
        "entityidfiltertype": "exact",
        "outputinitially": true,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "x": 190,
        "y": 1020,
        "wires": [
            [
                "71a4668a.3ac128"
            ]
        ]
    },
    {
        "id": "71a4668a.3ac128",
        "type": "switch",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "on",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 380,
        "y": 1000,
        "wires": [
            [
                "eed144a6.54b358",
                "5541ed08.1c2c14"
            ],
            [
                "eed144a6.54b358",
                "967220d3.57dd3"
            ]
        ]
    },
    {
        "id": "eed144a6.54b358",
        "type": "debug",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 610,
        "y": 920,
        "wires": []
    },
    {
        "id": "b5b26840.7163e8",
        "type": "comment",
        "z": "6b8efe0d.bc75e",
        "name": "ON",
        "info": "",
        "x": 630,
        "y": 980,
        "wires": []
    },
    {
        "id": "8919e0ed.d37f7",
        "type": "comment",
        "z": "6b8efe0d.bc75e",
        "name": "OFF",
        "info": "",
        "x": 630,
        "y": 1120,
        "wires": []
    },
    {
        "id": "a7fb31ed.2b483",
        "type": "inject",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "topic": "msg.payload",
        "payload": "on",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 180,
        "y": 940,
        "wires": [
            [
                "71a4668a.3ac128"
            ]
        ]
    },
    {
        "id": "84495d95.c6fcb",
        "type": "inject",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "topic": "msg.payload",
        "payload": "off",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 180,
        "y": 980,
        "wires": [
            [
                "71a4668a.3ac128"
            ]
        ]
    },
    {
        "id": "5541ed08.1c2c14",
        "type": "api-call-service",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "server": "2fba4297.e4145e",
        "version": 1,
        "service_domain": "light",
        "service": "turn_on",
        "entityId": "light.living_room_back_left",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 670,
        "y": 1020,
        "wires": [
            []
        ]
    },
    {
        "id": "967220d3.57dd3",
        "type": "api-call-service",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "server": "2fba4297.e4145e",
        "version": 1,
        "service_domain": "light",
        "service": "turn_off",
        "entityId": "light.living_room_back_left",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 670,
        "y": 1160,
        "wires": [
            []
        ]
    },
    {
        "id": "f5ba2e60.9bb96",
        "type": "trigger-state",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "server": "2fba4297.e4145e",
        "entityid": "media_player.plex_desktop_o5fu3ku",
        "entityidfiltertype": "exact",
        "debugenabled": false,
        "constraints": [
            {
                "id": "hquhg30r2jn",
                "targetType": "entity_id",
                "targetValue": "switch.adguard_parental_control",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            }
        ],
        "constraintsmustmatch": "all",
        "outputs": 2,
        "customoutputs": [],
        "outputinitially": false,
        "state_type": "str",
        "x": 190,
        "y": 1180,
        "wires": [
            [
                "da884cb1.36b77",
                "eed144a6.54b358"
            ],
            []
        ]
    },
    {
        "id": "da884cb1.36b77",
        "type": "switch",
        "z": "6b8efe0d.bc75e",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "playing",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "stopped",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "paused",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 470,
        "y": 1180,
        "wires": [
            [
                "967220d3.57dd3"
            ],
            [
                "5541ed08.1c2c14"
            ],
            [
                "5541ed08.1c2c14"
            ]
        ]
    },
    {
        "id": "2fba4297.e4145e",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "hassio": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]

1 Like

Wow…that’s a bit more complicated than my setup.

It took me a while to work out how where all the values were…but I got it done in the end!

I am stumped though, on how to apply these settings to my trigger-state??

“constraints”: [
{
“id”: “hquhg30r2jn”,
“targetType”: “entity_id”,
“targetValue”: “switch.adguard_parental_control”,
“propertyType”: “current_state”,
“propertyValue”: “new_state.state”,
“comparatorType”: “is”,
“comparatorValueDatatype”: “str”,
“comparatorValue”: “off”

In the meantime, I deployed these changes and fired up my system and everything worked the way I want.

Thanks so much for your input AlmostSerious…your a saint!!

This is my flow now…

image
Simply click on add constraint, and add the HT Power as Entity ID and Current State to on.

1 Like

Got it!!

Thanks again for your help … I really appreciate it!!

@Cranks can you post your flow as JSON for others (e.g. me :stuck_out_tongue: ) to learn from ?

Having some annoying activity every time we watch movies etc…the lights come on at random times. This only started a couple of days ago after a period of the flow working perfectly.

This is the only info in the debug mode…hope it helps??

{"topic":"light.home_theatre_gpo","payload":"off","data":{"entity_id":"light.home_theatre_gpo","old_state":{"entity_id":"light.home_theatre_gpo","state":"unavailable","attributes":{"friendly_name":"Home Theatre GPO","supported_features":63},"last_changed":"2019-10-25T20:03:32.215389+00:00","last_updated":"2019-10-25T20:03:32.215389+00:00","context":{"id":"29e4eacdb4d54075a8397fbfe42fee5e","parent_id":null,"user_id":null}},"new_state":{"entity_id":"light.home_theatre_gpo","state":"off","attributes":{"min_mireds":153,"max_mireds":500,"effect_list":["colorloop","random"],"friendly_name":"Home Theatre GPO","supported_features":63},"last_changed":"2019-10-25T20:03:33.080847+00:00","last_updated":"2019-10-25T20:03:33.080847+00:00","context":{"id":"bcab054c4e4f4368856d4d2c4bafaa82","parent_id":null,"user_id":null},"timeSinceChangedMs":80}},"_msgid":"b26cbfde.7891b"}

Looks like your state changed to unavailable and then to off again. Maybe you lost connection to your device shortly. In this case, maybe you need to filter out the unavailable message if this happens often.

Would this be done by changing the properties of the HT Power node to ‘stopping after first match’ ?? like this below…

Possibly. Depends on where the failure is coming from. But this could already be enough.

It’s gone crazy! Lights are coming on at irregular intervals and the only way I can seem to stop it is to disable the flow completely.
Here are the latest debug messages:-

[{"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":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":180,"y":300,"wires":[["9d77c212.d1457","5b17a3d2.a02afc"],[]]},{"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 not using the ‘stopping after first match’ as indicated previously.

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