'How-to' for LUA Split sensor data and fill 'multi-sensor'

Moderator: leecollings

Post Reply
jake
Posts: 744
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

'How-to' for LUA Split sensor data and fill 'multi-sensor'

Post by jake »

Is there a more complete documentation set available that explains what happens (what each part of a scirpt line does) when a (for instance) temp/hum/bar sensor is splitted? I don't understand what those magic [%+xyz] etc means

Also, to update a multiple value sensor, like the p1 smart meter, I don't understand the way those commands are built up and they seem to differ between sensors. What do things like |0| mean and ..sensorname.

In a summary, is there, beside the JSON Wiki page also a LUA (wiki) page that explains per sensor proper usage? It would be more then welcome, since I am comparing scripts all the time and having no clue what I am actually doing.[sub?[/sub]
antares
Posts: 48
Joined: Saturday 24 September 2016 9:25
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Germany
Contact:

Re: 'How-to' for LUA Split sensor data and fill 'multi-sensor'

Post by antares »

I would appreciate some documentation / explanation on that as well. Thanks for asking @jake.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: 'How-to' for LUA Split sensor data and fill 'multi-sensor'

Post by Nautilus »

For the "magic" character I suggest looking up some general LUA documentation, nothing Domoticz specific there :) There is also wiki page for events:
https://www.domoticz.com/wiki/Events, check especially:
To modify an otherdevice value, you should use commandArray['UpdateDevice']='idx|nValue|sValue' where idx is the device index, nValue and sValue the values to modify (see json page for details - Domoticz API/JSON URL's)
And
Some valid examples:

commandArray['Switch']='On'
commandArray['Scene:Livingroom']='On'
commandArray['Group:Kitchen']='Inactive'
commandArray['Keyfob']='Group On'
commandArray['DimmableDevice']='Set Level 50'
commandArray['Selector']='Set Level: 50'
commandArray['SendNotification']='subject#body#0'
commandArray['SendEmail']='subject#body#[email protected]'
commandArray['OpenURL']='www.yourdomain.com/api/movecamtopreset.cgi'
commandArray['Blinds']='On RANDOM 30'
commandArray['Porch Light']='On FOR 2'
commandArray['Variable:MyVar']='Some value'
commandArray['Variable:MyVar']='Some value AFTER 3'
commandArray[textDeviceIdx] = { ['UpdateDevice'] = textDeviceIdx..'|0|'..'some text' }
commandArray[tempDeviceIdx] = { ['UpdateDevice'] = tempDeviceIdx..'|0|'..temp }
commandArray[tempHumDevIdx] = { ['UpdateDevice'] = tempHumDevIdx..'|0|'.. temp ..';'.. hum ..';'.. hum_stat }
If there is some specific script you need help with, then I'd say the first thing would be to post the actual script and specify which parts need explaining. I'm not using P1 myself so not sure if I can give any advice there but I'm sure there are others here who can answer once they know the question... ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest