Page 1 of 1

ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Sunday 09 October 2022 17:43
by henrybcn
Hi everyone..... Trying to make my google mini to trigger a scene. Before it worked. But since ifttt/google assistant changed (2ys ago aprox) stopped working. I tried to recreate, but do not stop getting errors.
if I open the URL in a browser, I get:
{
"status" : "OK",
"title" : "SwitchScene"
}

But if I trigger from google home, I get the error:
domoticz.JPG
domoticz.JPG (56.94 KiB) Viewed 4193 times
Any idea what I am doing wrong?

Re: ifttt -> google assistant

Posted: Tuesday 11 October 2022 18:25
by meal
Hello
Since 31/08/2022 the integration of IFTTT with google has changed and it is no longer possible to perform the action you mentioned with a parameter.
I moved from IFTTT to a DZGA Domoticz Google Assistant solution successfully.
BR

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Tuesday 18 October 2022 19:39
by henrybcn
Tks @meal!
I just tried to use DZGA, but find too complicated to configure for just 2 commands I need.

Does anyone have a suggestion on how through a voice command "hey google, turn on stairs", trigger a webhook? I can enter the URL in any browser and the lights will go on/off. There must be something out there without spending a few hours, no? I have been with domoticz for years and I am very happy with it. Just struggling for a few months on how to simply connect 1 scene with my google mini so I can activate by voice.....

Anyone with a good/easy solution?

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Tuesday 18 October 2022 23:18
by FireWizard
Hi, @henrybcn,

You might want to look at Node-RED. Together with Smartnora, you can use up to 5 devices with your Google Home speaker for free.

See: https://circuitdigest.com/microcontroll ... automation

Regards

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Friday 21 October 2022 12:59
by henrybcn
Tks so much @FireWizard!
Indeed it is much simpler than other methods...
I managed to add a single switch without any issue, but now I am struggling on how to make the scene to work. I can turn it on, but not turn it off. Google responds with: "power control is not supported yet"
Anyone with experience? Or any idea how to turn on 2 switches at the same time with a single voice command?
Tks again All!

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Friday 21 October 2022 14:48
by FireWizard
Hello @henrybcn,
In viewtopic.php?p=293629#p293629, you raised the following question.
I just started to use Node-RED this week. I used IFTTT for years to turn on/off lights through my google mini. As they do not support it anymore, this is the easiest tool I found!
I am able to configure everything to turn on/off 1 switch per "flow". I am using domoticz-node-red-nora.
But I am struggling to turn on 2 swithes at the same time. I can do that with scenes in domoticz. In fact I have a flow that allows me turn the scene on, but does not turn it off. Google says:"power control is not supported yet". I do not need to necessarily use NORA scene. It is my preference as it does not create any icon in my google assistant. But if there is an option to group 2 switches with a single voice command, I am fine too. Any idea what I am doing wrong? Here you have the 2 flows I have been playing:

In this one I can turn it on, but not off: This one nothing happens: Both flows were copied from other people and I tried to adjust.
Any help?
Tks so much! Henry
A few things:

1. NORA has been deprecated and has been replaced by SmartNora. This has happened in April 2021. Since December 1st, 2021 SmarNora is a paid service, if you want to use more than 5 devices.
So do not use NORA anymore, but use SmartNora.

If you need more than 5 devices, you can either pay for your account or choose another service.

2. You did not include any flow in your posts.
[Edit] I saw pictures of your flow on the Node RED forum, but you did not part there a flow either.
Again!!! Do not cross post on multiple places It will not help you.

3. A scene in SmartNora is something you can activate or deactivate ( if Scene reversible is checked )
Google will tell you and activate the scene. With the received message you can control as many devices you want.

An alternative is that you create the scene in your Google Home app and select the devices you want to control.

If you send the flow, I can have a look.

Regards

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Friday 21 October 2022 19:56
by henrybcn
Tks @FireWizard! And sorry for duplicating the post. Fully agree and understand your comments! ;)

I was too fast in my post. Yes, I am using SmartNora ;)
Here you have my flow

Code: Select all

[
    {
        "id": "6e251134eafd988e",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "4528e53.782fb1c",
        "type": "mqtt in",
        "z": "6e251134eafd988e",
        "name": "",
        "topic": "domoticz/out",
        "qos": "0",
        "datatype": "auto",
        "broker": "34e4d2fc.90d346",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 170,
        "y": 380,
        "wires": [
            [
                "3e9a9a76.9cb2f6"
            ]
        ]
    },
    {
        "id": "3e9a9a76.9cb2f6",
        "type": "json",
        "z": "6e251134eafd988e",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 330,
        "y": 380,
        "wires": [
            [
                "681631c8.dbc208"
            ]
        ]
    },
    {
        "id": "681631c8.dbc208",
        "type": "switch",
        "z": "6e251134eafd988e",
        "name": "",
        "property": "payload.switchType",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "On/Off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 470,
        "y": 380,
        "wires": [
            [
                "f9798848.30054"
            ]
        ]
    },
    {
        "id": "f9798848.30054",
        "type": "function",
        "z": "6e251134eafd988e",
        "name": "Function In on/off",
        "func": "msg.topic = msg.payload.idx\nif (msg.payload.nvalue == 1)\n{\n    msg.payload = true\n}\nelse if (msg.payload.nvalue === 0)\n{\n    msg.payload = false\n}\n    return msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 650,
        "y": 320,
        "wires": [
            [
                "c7d42d19.b2e198"
            ]
        ]
    },
    {
        "id": "c7d42d19.b2e198",
        "type": "switch",
        "z": "6e251134eafd988e",
        "name": "Switch",
        "property": "topic",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 850,
        "y": 200,
        "wires": [
            [
                "e818b645722e4615"
            ]
        ]
    },
    {
        "id": "805526ff.cf4d08",
        "type": "function",
        "z": "6e251134eafd988e",
        "name": "Function out On/Off",
        "func": "var idx = parseInt(msg.topic);\nif ( msg.payload === true )\n{\nmsg.payload = { \"command\": \"switchlight\", \"idx\": 9, \"switchcmd\": \"On\" };\n}\nelse if ( msg.payload === false )\n{\nmsg.payload = { \"command\": \"switchlight\", \"idx\": 9, \"switchcmd\": \"Off\" };\n}\nreturn msg\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1330,
        "y": 340,
        "wires": [
            [
                "7d584545.8c9544"
            ]
        ]
    },
    {
        "id": "7d584545.8c9544",
        "type": "json",
        "z": "6e251134eafd988e",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 1530,
        "y": 560,
        "wires": [
            [
                "caefbcc2.78bf18"
            ]
        ]
    },
    {
        "id": "caefbcc2.78bf18",
        "type": "mqtt out",
        "z": "6e251134eafd988e",
        "name": "",
        "topic": "domoticz/in",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "34e4d2fc.90d346",
        "x": 1750,
        "y": 600,
        "wires": []
    },
    {
        "id": "e818b645722e4615",
        "type": "noraf-switch",
        "z": "6e251134eafd988e",
        "devicename": "Stairs",
        "roomhint": "",
        "name": "",
        "passthru": false,
        "errorifstateunchaged": false,
        "nora": "d83ece29a87dbcd3",
        "topic": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "offvalue": "false",
        "offvalueType": "bool",
        "twofactor": "off",
        "twofactorpin": "",
        "filter": false,
        "asyncCmd": false,
        "outputs": 1,
        "x": 1110,
        "y": 200,
        "wires": [
            [
                "805526ff.cf4d08",
                "974ebb4877c23e82"
            ]
        ]
    },
    {
        "id": "974ebb4877c23e82",
        "type": "function",
        "z": "6e251134eafd988e",
        "name": "Function out On/Off",
        "func": "var idx = parseInt(msg.topic);\nif ( msg.payload === true )\n{\nmsg.payload = { \"command\": \"switchlight\", \"idx\": 6, \"switchcmd\": \"On\" };\n}\nelse if ( msg.payload === false )\n{\nmsg.payload = { \"command\": \"switchlight\", \"idx\": 6, \"switchcmd\": \"Off\" };\n}\nreturn msg\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1390,
        "y": 200,
        "wires": [
            [
                "7d584545.8c9544"
            ]
        ]
    },
    {
        "id": "34e4d2fc.90d346",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.0.157",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "d83ece29a87dbcd3",
        "type": "noraf-config",
        "name": "nora config",
        "group": "",
        "twofactor": "off",
        "twofactorpin": "",
        "localexecution": true,
        "structure": "",
        "storeStateInContext": false,
        "disableValidationErrors": false,
        "sendDeviceNameAndLocation": false
    }
]
Instead of using the scene, I was able to combine 2 IDX in one single smartnora switch and that is perfect
The only issue I have is if I turn it on/off from domoticz directly, I do not see it reflected in node-red. I guess this is possible right?
Tks much again!
Henry

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Friday 21 October 2022 21:29
by FireWizard
Hello @henrybcn,

Okay, thank you for the flow.
For now it is okay but in the future it is easier to export the flow to your clipboard and then paste it between </>, like

Code: Select all

 This is code
See the 5th button from left.

This weekend I will load it into my test system and will come back to you.

Regards

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Saturday 22 October 2022 14:09
by henrybcn
tks again @FireWizard! I just edited the post. Did not know how to embed the code ;)
;)

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Saturday 22 October 2022 16:29
by FireWizard
Hi @henrybcn,

No problem, I loaded your code (flow) in my test system.
The only issue I have is if I turn it on/off from domoticz directly, I do not see it reflected in node-red. I guess this is possible right?
Yes, normally it should be indicated under the Smartnora node.

smartnora_nodes.png
smartnora_nodes.png (25.5 KiB) Viewed 4026 times

I took a look at your flow and simplified it.

Test_flow_with_smartnora.png
Test_flow_with_smartnora.png (27.22 KiB) Viewed 4026 times
Let me explain.

1. The "domoticz/out" node is capable to send a JSON payload.
So change the "Output" from "auto-detect (string or buffer)" to "a parsed JSON object"
The "auto-detect (string or buffer)" is deprecated and has been replaced by "auto-detect (parsed JSON object, string or buffer)"

In this case you can remove the JSON node. This saves a node.

2. With the "Switch" node you filter the message. In this case every message that contains msg.payload.switchType = "On/Off" will go through and all others are blocked. So if you have more than one "Switch" in Domoticz, all the switches are going to the Smartnora node.
If you have more than one "Switch" that has to go to more Smartnora nodes, it is better to filter on msg.payload.idx

3. Before the Smartnora node, you will almost always need a "Function" node.
In this "Function" node you can store the incoming idx number in the topic. This is saved and used later in the outgoing message.
However you have chosen to use fixed idx numbers (6 and 9) and therefore that line is not necessary.

The contents off the Function node is as follows:

Code: Select all

if (msg.payload.nvalue === 1)
    {
    msg.payload = true
    }
else if (msg.payload.nvalue === 0)
    {
    msg.payload = false
    }
return msg
So if any Switch in Domoticz is "On". you send a boolean true, otherwise a boolean false.

4. Lets look to the Smartnora node.

If you want to filter e.g. a specific idx number, you can use the previous (now removed) line msg.topic = msg.payload.idx and filter on that topic.
In this case you can tick the box after "Ignore input messages that don't match the topic value:" and set then that topic.
Set ALWAYS a Room hint, as that is used by Google.

5. Let us look to the "Function" node that has been connected to the output of the Smartnora node.

Code: Select all

let msg1 = {};
let msg2 = {};

if ( msg.payload === true )
{
    msg1.payload = { "command": "switchlight", "idx": 6, "switchcmd": "On" };
    msg2.payload = { "command": "switchlight", "idx": 9, "switchcmd": "On" };
}
else if ( msg.payload === false )
{
    msg1.payload = { "command": "switchlight", "idx": 6, "switchcmd": "Off" };
    msg2.payload = { "command": "switchlight", "idx": 9, "switchcmd": "Off" };
}
return [[msg1,msg2]]
If you want to switch two switches with one command, you can combine these in one function node.

First you have to declare two new variables msg1 and msg2.
Then you combine it and send it to one output.
See: https://nodered.org/docs/user-guide/writing-functions

An alternative, and perhaps even better, is to create a group in Domoticz (Scenes > Add a Scene, and create a group with your two idx numbers)

In that case you can use the 'Function" node with the following contents:

Code: Select all

if (msg.payload === true)
{
    msg.payload = { "command": "switchscene", "idx": 1, "switchcmd": "On" };
}
else if (msg.payload === false)
{
    msg.payload = { "command": "switchscene", "idx": 1, "switchcmd": "Off" };
}
return msg
I will send you the complete flow below.
I have "Debug" nodes inserted. If you are satisfied, you can remove these. Or at least, disable the output.

Code: Select all

[{"id":"6e251134eafd988e","type":"tab","label":"Test","disabled":false,"info":"","env":[]},{"id":"4528e53.782fb1c","type":"mqtt in","z":"6e251134eafd988e","name":"","topic":"domoticz/out","qos":"0","datatype":"json","broker":"38b35487299a036d","nl":false,"rap":false,"inputs":0,"x":150,"y":380,"wires":[["681631c8.dbc208"]]},{"id":"681631c8.dbc208","type":"switch","z":"6e251134eafd988e","name":"","property":"payload.switchType","propertyType":"msg","rules":[{"t":"eq","v":"On/Off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":330,"y":380,"wires":[["f9798848.30054","dc07d78e60be9700"]]},{"id":"f9798848.30054","type":"function","z":"6e251134eafd988e","name":"Function In on/off","func":"if (msg.payload.nvalue === 1)\n    {\n    msg.payload = true\n    }\nelse if (msg.payload.nvalue === 0)\n    {\n    msg.payload = false\n    }\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":380,"wires":[["19084c543048e582","e818b645722e4615"]]},{"id":"caefbcc2.78bf18","type":"mqtt out","z":"6e251134eafd988e","name":"","topic":"domoticz/in","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"38b35487299a036d","x":1170,"y":380,"wires":[]},{"id":"e818b645722e4615","type":"noraf-switch","z":"6e251134eafd988e","devicename":"Stairs","roomhint":"Stair","name":"","passthru":false,"errorifstateunchaged":true,"nora":"d83ece29a87dbcd3","topic":"","onvalue":"true","onvalueType":"bool","offvalue":"false","offvalueType":"bool","twofactor":"off","twofactorpin":"","filter":false,"asyncCmd":false,"outputs":1,"x":730,"y":380,"wires":[["974ebb4877c23e82"]]},{"id":"974ebb4877c23e82","type":"function","z":"6e251134eafd988e","name":"Function out On/Off","func":"let msg1 = {};\nlet msg2 = {};\n\nif ( msg.payload === true )\n{\n    msg1.payload = { \"command\": \"switchlight\", \"idx\": 6, \"switchcmd\": \"On\" };\n    msg2.payload = { \"command\": \"switchlight\", \"idx\": 9, \"switchcmd\": \"On\" };\n}\nelse if ( msg.payload === false )\n{\n    msg1.payload = { \"command\": \"switchlight\", \"idx\": 6, \"switchcmd\": \"Off\" };\n    msg2.payload = { \"command\": \"switchlight\", \"idx\": 9, \"switchcmd\": \"Off\" };\n}\nreturn [[msg1,msg2]]","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":380,"wires":[["d9e60f915db67447","caefbcc2.78bf18"]]},{"id":"dc07d78e60be9700","type":"debug","z":"6e251134eafd988e","name":"debug 31","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":320,"wires":[]},{"id":"19084c543048e582","type":"debug","z":"6e251134eafd988e","name":"debug 32","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":320,"wires":[]},{"id":"a678fedbdd0fefb5","type":"function","z":"6e251134eafd988e","name":"function 1","func":"if (msg.payload === true)\n{\n    msg.payload = { \"command\": \"switchscene\", \"idx\": 1, \"switchcmd\": \"On\" };\n}\nelse if (msg.payload === false)\n{\n    msg.payload = { \"command\": \"switchscene\", \"idx\": 1, \"switchcmd\": \"Off\" };\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":440,"wires":[["a6ea09b3960410ba"]]},{"id":"59eace82f56d0bec","type":"inject","z":"6e251134eafd988e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":730,"y":440,"wires":[["a678fedbdd0fefb5"]]},{"id":"88ef72b948534082","type":"inject","z":"6e251134eafd988e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":730,"y":480,"wires":[["a678fedbdd0fefb5"]]},{"id":"d9e60f915db67447","type":"debug","z":"6e251134eafd988e","name":"debug 33","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1160,"y":320,"wires":[]},{"id":"a6ea09b3960410ba","type":"debug","z":"6e251134eafd988e","name":"debug 34","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1080,"y":440,"wires":[]},{"id":"38b35487299a036d","type":"mqtt-broker","name":"Raspberry Pi 1","broker":"192.168.10.51","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"d83ece29a87dbcd3","type":"noraf-config","name":"nora config","group":"","twofactor":"off","twofactorpin":"","localexecution":true,"structure":"","storeStateInContext":false,"disableValidationErrors":false,"sendDeviceNameAndLocation":false}]
Let know, if it is working for you.
I do not use Smartnora (anymore), so I did not test it with voice commands.

Regards

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Monday 24 October 2022 16:09
by henrybcn
@FireWizard,
Tks so much again! The code is now simpler and works like a charm! Can not tk you enough! ;)
The only one I did not really get is the scene. I would prefer the scene than the switch to be hones as I prefer not to have another icon in my google home.

I added the scene, but does not really trigger anything....

Image

I replaced the inject with the scene. Is this the way to do it?

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Monday 24 October 2022 16:32
by FireWizard
Hello @henrybcn,

Just 2 questions.

1. What is the output, if you activate the scene by voice.
So connect a debug node directly to the output from the Smartnora node (called Scene)
Let me know, what it shows and also what does "debug 34" show,

2. Did you configure the Group in Domoticz?
Check its idx.

Let me know.

Regards

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Tuesday 25 October 2022 15:54
by henrybcn
Hi @FireWizard,
I think I am doing something very stupid/lame.....
Anyway...
1 - I am using voice command and I can see in debug:
10/25/2022, 3:49:09 PMnode: debug 34
msg.payload : Object
{ command: "switchscene", idx: 1, switchcmd: "On" }
10/25/2022, 3:49:10 PMnode: debug 34
msg.payload : Object
{ command: "switchscene", idx: 1, switchcmd: "On" }

2 - My domoticz group is idx 1 as below:
Image

when I activate the command, domoticz switches/scene do not change :o

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Tuesday 25 October 2022 16:21
by FireWizard
Hello @henrybcn

Did you add devices to the group?

Screenshot_Group_Config_Domoticz.png
Screenshot_Group_Config_Domoticz.png (187.84 KiB) Viewed 3979 times

As I test it, it works. The commands are correct.

Regards

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Thursday 27 October 2022 11:55
by henrybcn
tks @FireWizard, that is really strange. I can trigger to turn it on. I see it in debug, but domoticz does not change. This scene I setup years ago:

Image

Anyway, I will use the 2 switches as they work well ;)

Tks again!

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Thursday 27 October 2022 12:26
by FireWizard
Hi, @henrybcn,

Really strange and I do not understand, why it doesn't work.
I can trigger to turn it on. I see it in debug
Can you show that debug as a screenshot and not only as copied text?
but domoticz does not change
Can you check the Domoticz log, after you send the MQTT command?
This scene I setup years ago:
Has this scene (group) always worked for you and does it still works? (Domoticz version?)

Regards

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Saturday 29 October 2022 15:41
by henrybcn
Hey @FireWizard,

I tried to tweak and compare a few flows..... Now it works, but with something a bit different.....

Code: Select all

[
    {
        "id": "966f530f88a9e949",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "cdb1e20b77f2b2af",
        "type": "function",
        "z": "966f530f88a9e949",
        "name": "Function Scene",
        "func": "var idx = parseInt(msg.topic)\n\nif (msg.payload === true) {\n    msg.payload = { \"command\": \"switchscene\", \"idx\": 1, \"switchcmd\": \"On\" };\n}\nelse if (msg.payload === false) {\n    msg.payload = { \"command\": \"switchscene\", \"idx\": 1, \"switchcmd\": \"Off\" };\n}\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1300,
        "y": 480,
        "wires": [
            [
                "29a338fa26e86724"
            ]
        ]
    },
    {
        "id": "29a338fa26e86724",
        "type": "json",
        "z": "966f530f88a9e949",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 1650,
        "y": 380,
        "wires": [
            [
                "cfc1f5083c9220d1"
            ]
        ]
    },
    {
        "id": "cfc1f5083c9220d1",
        "type": "mqtt out",
        "z": "966f530f88a9e949",
        "name": "",
        "topic": "domoticz/in",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "34e4d2fc.90d346",
        "x": 1910,
        "y": 420,
        "wires": []
    },
    {
        "id": "4b528ab4b532e057",
        "type": "noraf-scene",
        "z": "966f530f88a9e949",
        "devicename": "Scene test",
        "roomhint": "",
        "scenereversible": true,
        "name": "",
        "nora": "d83ece29a87dbcd3",
        "topic": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "offvalue": "false",
        "offvalueType": "bool",
        "twofactor": "off",
        "twofactorpin": "",
        "x": 940,
        "y": 480,
        "wires": [
            [
                "cdb1e20b77f2b2af"
            ]
        ]
    },
    {
        "id": "78868d8639b347e3",
        "type": "function",
        "z": "966f530f88a9e949",
        "name": "function 2",
        "func": "\n\nvar idx = parseInt(msg.topic)\n\nif (msg.payload === true) {\n    msg.payload = { \"command\": \"switchscene\", \"idx\": 1, \"switchcmd\": \"On\" };\n}\nelse if (msg.payload === false) {\n    msg.payload = { \"command\": \"switchscene\", \"idx\": 1, \"switchcmd\": \"Off\" };\n}\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1320,
        "y": 240,
        "wires": [
            [
                "8cb62f4e1a288628"
            ]
        ]
    },
    {
        "id": "8cb62f4e1a288628",
        "type": "debug",
        "z": "966f530f88a9e949",
        "name": "debug 38",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1500,
        "y": 240,
        "wires": []
    },
    {
        "id": "1da7b973094b189a",
        "type": "noraf-scene",
        "z": "966f530f88a9e949",
        "devicename": "bubble",
        "roomhint": "",
        "scenereversible": true,
        "name": "",
        "nora": "d83ece29a87dbcd3",
        "topic": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "offvalue": "false",
        "offvalueType": "bool",
        "twofactor": "off",
        "twofactorpin": "",
        "x": 1030,
        "y": 220,
        "wires": [
            [
                "78868d8639b347e3"
            ]
        ]
    },
    {
        "id": "34e4d2fc.90d346",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.0.157",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "d83ece29a87dbcd3",
        "type": "noraf-config",
        "name": "nora config",
        "group": "",
        "twofactor": "off",
        "twofactorpin": "",
        "localexecution": true,
        "structure": "",
        "storeStateInContext": false,
        "disableValidationErrors": false,
        "sendDeviceNameAndLocation": false
    }
]
The first one is what you sent me. It triggers rednode, but does not reach domoticz. I guess it is because there is no domoticz in/out
The 2nd one now works. I realized that on SCENE ICON, I did not have the "scene reversible" ticked. Now I can turn on/off nicely
Tks again for the huge help! It is really much simpler than any other solution! ;)

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Saturday 29 October 2022 21:57
by FireWizard
Hi, @henrybcn,

You wrote:
The first one is what you sent me. It triggers rednode, but does not reach domoticz. I guess it is because there is no domoticz in/out
That is correct. There is no MQTT Output node connected (which contains the topic domoticz/out)
Probably I did not include that, because it might cause confusion, as it contains my own configuration.
The 2nd one now works. I realized that on SCENE ICON, I did not have the "scene reversible" ticked. Now I can turn on/off nicely
You can omit the JSON node, as it is not necessary. The output from the "Function" node is already JSON.

And of course, if you want to reverse the scene, you have to tick that box.

Regards

Re: ifttt -> google assistant. Any easier way to use it to turn on/off lights?

Posted: Sunday 30 October 2022 7:45
by henrybcn
Tks again @FireWizard! ;)
All set!