Hi there,
Got some smal skills with LUA and domoticz API, and i don't found how to do what i need, so i'm looking in dz events for this, mayb e away to convert me...let's try.
Working on a script for a esp8266 based module, his goal is to drive french electrique heating using pilot wire.
this module is cloud base, APi is quiete clear and easy to parse :
Get : to retrive Token, Device ID, and actual status
Post : to drive it
Retrive token, stroe it on a uservariable, refresh it every 5 day as asken : no problemo
Get device ID = one per module, no problemo, to be more easy to use i want to store this Device Id on Switch description, then with a device script, when switch is trigger, parsing json, get Device ID, and use it with parsed token from uservariable, will make easier to use for people : just wirte device IDX on script variable, and enjoy.
But how to write on description case ?, using mysql ? ggrr don't like this idea.
Does dz event allow to do this ?
Write in description Case
Moderator: leecollings
-
deennoo
- Posts: 784
- Joined: Wednesday 10 December 2014 13:06
- Target OS: Linux
- Domoticz version: beta
- Location: Bordeaux France
- Contact:
Write in description Case
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
-
dannybloe
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Write in description Case
For what I know is that you have to use the GUI api to do so as there is no other way that I know of:
This is how I do it in my dzVents integration tests:
The only problem is that you have to provide all the parameters for it to work. But all that info is available on the device in dzVents. So, what you could do to make this nice is create a helper function (see doc) and put it in global_data.lua:
Then in your event script you can do this:
One note though.. I suspect this doesn't work with all devices as some devices need more parameters to be sent to the 'setused' api. I have tested this only with switches. But with a little trial and error you can get this to work.
This is how I do it in my dzVents integration tests:
Code: Select all
function updateSwitch(idx, name, description, switchType)
local url = "type=setused&idx=" ..
tostring(idx) ..
"&name=" .. name ..
"&description=" .. description ..
"&strparam1=&strparam2=&protected=false&" ..
"switchtype=" .. tostring(switchType) .. "&customimage=0&used=true&addjvalue=0&addjvalue2=0&options="
return url
end
domoticz.openURL(updateSwitch(....))
Code: Select all
return {
helpers = {
updateDescription = function(domoticz, device, description)
local url = "type=setused&idx=" ..
tostring(device.id) ..
"&name=" .. device.name ..
"&description=" .. description ..
"&strparam1=&strparam2=&protected=false&" ..
"switchtype=" .. tostring(device.switchType) .. "&customimage=0&used=true&addjvalue=0&addjvalue2=0&options="
domoticz.openURL(url)
end
}
}
Code: Select all
return {
...
execute = function(domoticz, device)
domoticz.helpers.updateDescription(domoticz, device, 'My new description')
end
}
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
deennoo
- Posts: 784
- Joined: Wednesday 10 December 2014 13:06
- Target OS: Linux
- Domoticz version: beta
- Location: Bordeaux France
- Contact:
Re: Write in description Case
Ok, thanks.
The same Can be done with lua and parsing value...surely more complexe.
That an hard solution for people who start with Domoticz. Idea was to make it easy.
Other solution is to provied à python script
The same Can be done with lua and parsing value...surely more complexe.
That an hard solution for people who start with Domoticz. Idea was to make it easy.
Other solution is to provied à python script
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
Who is online
Users browsing this forum: No registered users and 1 guest