Would be great if you can activate (json, post message body) a switch based on the switch name, or levelname instead of the idx
{"command": "switchlight", "name": "lamp_x", "switchcmd": "Off"}
also tried
http://192.168.20.35:82/json.htm?type=d ... e=lantaarn to read the IDX in NODE-red
In google home you can give the command: turn lamp_x or lamp_y on or off
Using a IDX in natural languages does not make sense...
In IFTTT you only have to write two scripts ON or OFF and use a variable for the device_name...
My (working) configuation:
Google home (RPI 3b+) --> IFTTT --> NODE-RED --> MQTT --> domoticz....
I tried to let NODE-RED do the conversion name --> id, but i did not get it working....
I have generic POST and GET's working on my NODE-red with MQTT and domoticz
mqtt or json
Moderators: leecollings, remb0
-
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
mqtt or json
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Jablotron connection, Ikea
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: mqtt or json
Would it help if you could change this to ?pvklink wrote: ↑Tuesday 11 June 2019 20:54 Would be great if you can activate (json, post message body) a switch based on the switch name, or levelname instead of the idx
In google home you can give the command: turn lamp_x or lamp_y on or off
Using a IDX in natural languages does not make sense...
In IFTTT you only have to write two scripts ON or OFF and use a variable for the device_name...
My (working) configuation: Google home (RPI 3b+) --> IFTTT --> NODE-RED --> MQTT --> domoticz....
Google home (RPI 3b+) --> IFTTT --> domoticz user variable (control var) --> dzVents script --> domoticz device
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
Re: mqtt or json
In IFTT you can ask for the "name" and ON/OFF so you only need one IFTT script !
i made three flows,
1. one for post's with IDX --> already working!
2. one for get's with IDX --> already working!
Under construction
3. one for post's with device name,
- {"command":"switchlight","name":"lantaarn","switchcmd":"On"}
- then i do a http://xxxxxx/json.htm?type=command&par ... htswitches
- then search for the "name", change the message, use idx instead of name and then the normal POST flow....
i hope and think this is going to work!
When they all work i will combine them and then you have a sort off API between IFTTT and MQTT via node-red for POSTS, GETS, idx or names
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Jablotron connection, Ikea
-
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
Re: mqtt or json
thougt about your CONTROLVAR solution...
That is GREAT!
Does it contains something like "Lantaarn ON"
And then a default DZVENTS script to interpretate and execute it?
I can also combine this with node-red
/json.htm?type=command¶m=updateuservariable&vname=USERVARIABLENAME&vtype=USERVARIABLETYPE&vvalue=USERVARIABLEVALUE
i make a default message for this and ASK within IFTT for name
{"command": "updateuservariable","vname":"ifttvar","vtype":"String","vvalue":" {{TextField}}"}
then the uservar is filled.. i think
That is GREAT!
Does it contains something like "Lantaarn ON"
And then a default DZVENTS script to interpretate and execute it?
I can also combine this with node-red
/json.htm?type=command¶m=updateuservariable&vname=USERVARIABLENAME&vtype=USERVARIABLETYPE&vvalue=USERVARIABLEVALUE
i make a default message for this and ASK within IFTT for name
{"command": "updateuservariable","vname":"ifttvar","vtype":"String","vvalue":" {{TextField}}"}
then the uservar is filled.. i think
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Jablotron connection, Ikea
-
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
Re: mqtt or json
I got the first part working from ifttt and nodered/mqttt
http://192.168.20.35:82/json.htm?type=c ... 2&vvalue=a
domoticz mqttt does not execute the change in the uservar
This is the payload to mqttt
12-6-2019 14:10:47node: d0f0155b.51fc88
msg.payload : string[77]
"{"command":"updateuservariable","vname":"iftttvar","vtype":2,"vvalue":"lamp"}"
strange, this works with switches etc....
@update found it!
https://www.domoticz.com/wiki/MQTT
{"command":"setuservariable","idx":12,"value":"lamp"}
http://192.168.20.35:82/json.htm?type=c ... 2&vvalue=a
domoticz mqttt does not execute the change in the uservar
This is the payload to mqttt
12-6-2019 14:10:47node: d0f0155b.51fc88
msg.payload : string[77]
"{"command":"updateuservariable","vname":"iftttvar","vtype":2,"vvalue":"lamp"}"
strange, this works with switches etc....
@update found it!
https://www.domoticz.com/wiki/MQTT
{"command":"setuservariable","idx":12,"value":"lamp"}
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Jablotron connection, Ikea
-
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
Re: mqtt or json
I can manage the uservar IFTTTVAR now by speech. it gets the value LAMP X ON or LAMP x OFF
so i have Google home --> IFTTT --> NODE-RED --> MQTT --> domoticz uservar IFTTTVAR
so i have Google home --> IFTTT --> NODE-RED --> MQTT --> domoticz uservar IFTTTVAR
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Jablotron connection, Ikea
-
- Posts: 4
- Joined: Sunday 09 September 2018 19:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Location: Sweden
- Contact:
Re: mqtt or json
It would indeed be very nice if I can use the device name instead of the device IDX when sending
measurements from a sensor using MQTT.
I have a NodeMCU/ESP8266 based sensor node with a 1-Wire interface. This sensor node is sending
temperature measurements to Domoticz using MQTT. The device IDX has to be hardcoded in the
NodeMCU sketch and this is not optimal I think.
The sketch code is here: https://github.com/hansake/Domoticz_NodeMCU_MQTT
The device IDX could be determined by sending a query to Domoticz using MQTT but this would
complicate the code in the NodeMCU.
Regards
Hans-Åke
measurements from a sensor using MQTT.
I have a NodeMCU/ESP8266 based sensor node with a 1-Wire interface. This sensor node is sending
temperature measurements to Domoticz using MQTT. The device IDX has to be hardcoded in the
NodeMCU sketch and this is not optimal I think.
The sketch code is here: https://github.com/hansake/Domoticz_NodeMCU_MQTT
The device IDX could be determined by sending a query to Domoticz using MQTT but this would
complicate the code in the NodeMCU.
Regards
Hans-Åke
-
- Posts: 822
- Joined: Wednesday 12 November 2014 15:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest b
- Contact:
Re: mqtt or json
i migrated all my iftt applets to use the @waaren ifttt solution, works great.
i tried to adjust it a little bit so that i can use it also for selecting selector switches with an selector id instead off selector name..
so parm1 for example could be Radio or 20
i need a check to check if parm1 is a string or a number .
if it is a number the action =
target.switchSelector(tonumber(parm1)) --parm selector_id
if it is a number then
target.switchSelector(parm1) --parm selector_name
i tried to adjust it a little bit so that i can use it also for selecting selector switches with an selector id instead off selector name..
so parm1 for example could be Radio or 20
i need a check to check if parm1 is a string or a number .
if it is a number the action =
target.switchSelector(tonumber(parm1)) --parm selector_id
if it is a number then
target.switchSelector(parm1) --parm selector_name
Code: Select all
local iftttvar = "iftttvar"
return
{
on =
{ variables = { iftttvar },
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'ifttt',
},
execute = function(dz, item)
local validBaseTypes = { device=true, group=true, scene=true, uservariable=false, camera=false }
local validActions = { ON=true, OFF=true }
result = dz.utils.stringSplit(item.value,'/')
local name = result[1]
local action = string.upper(result[2])
local parm1 = result[3]
local function getBaseType(name)
for i, tuple in ipairs(_G.domoticzData) do
if tuple.name == name then
return tuple.baseType, tuple.id
end
end
end
local baseType, idx = getBaseType(name)
if baseType and validBaseTypes[baseType] then
local target
if baseType == 'device' then
target = dz.devices(name)
elseif baseType == 'group' then
target = dz.groups(name)
elseif baseType == 'scene' then
target = dz.scenes(name)
validActions.OFF = nil -- No Off action for scenes
end
if validActions[action] then
if action == 'ON' then
if parm1 then
--2019-06-29 11:46:37.971 Error: dzVents: Error: (2.4.23) ifttt: xxx IFTTT target:denon_volumeparm1:30/ en waarde van uservar:denon_volume/On/30
--2019-06-29 11:46:37.971 Error: dzVents: Error: (2.4.23) ifttt: levelname 30 does not exist
dz.log('xxx IFTTT target:' .. tostring(target.name) .. 'parm1:' .. parm1 .. '/ en waarde van uservar:' .. item.value,dz.LOG_ERROR)
target.switchSelector(parm1) --parm selector_name
--target.switchSelector(tonumber(parm1)) --parm selector_id
else
target.switchOn()
end
elseif action == 'OFF' then target.switchOff()
else -- no other actions implemented yet
end
else
dz.log('action ' .. action .. ' is not implemented for ' .. baseType .. ' ' .. name .. '!',dz.LOG_ERROR)
end
elseif baseType then
dz.log(name .. " is a " .. baseType .. " don't know what to do with that!",dz.LOG_ERROR)
else
dz.log(name .. " Not found!",dz.LOG_ERROR)
end
end
}
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Jablotron connection, Ikea
Who is online
Users browsing this forum: Bing [Bot] and 1 guest