Got one of these and would want to control it from LUA/dzvents. Anyone have a sample script that can be used ? (On/Off / Dimmer level / Color)
2022-06-20 09:43:52.438 Smart: onCommand called for Unit 8: Parameter 'Set Color', Level: 100
2022-06-20 09:43:52.438 Smart: Sending command for DeviceID=bf499c0155a4056e57sspm
2022-06-20 09:43:52.439 Smart: color={'b': 0, 'cw': 0, 'g': 255, 'm': 3, 'r': 51, 't': 0, 'ww': 0} h=0.3 s=1.0
2022-06-20 09:43:52.455 (Smart - Smart Bulb 600hz) Updating device from 1:'100' to have values 1:'100'.
Thanks
WIFI Control Smart Life Tuya IP66 Outdoor 30W RGBCW LED Floodlight
Moderator: leecollings
- waltervl
- Posts: 5761
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: WIFI Control Smart Life Tuya IP66 Outdoor 30W RGBCW LED Floodlight
Check the wiki of DzVents, there are lots of examples in it https://www.domoticz.com/wiki/DzVents:_ ... _scripting
Let’s say you have a script that checks the status of a lamp and is triggered by motion detector:
For dimmer switches/lights you have the following options (from the wiki documentation)
Let’s say you have a script that checks the status of a lamp and is triggered by motion detector:
Code: Select all
return {
on = {
timer = { 'every 5 minutes' },
devices = { 'myDetector' }
},
execute = function(domoticz, item)
if (item.isTimer) then
-- the timer was triggered
domoticz.devices('myLamp').switchOff()
elseif (item.isDevice and item.active) then
-- it must be the detector
domoticz.devices('myLamp').switchOn()
end
end
}
Switch (dimmer, selector etc.)
There are many switch-like devices. Not all methods are applicable for all switch-like devices. You can always use the generic setState(newState) method.
close(): Function. Set device to Close if it supports it. Supports command options.
dimTo(percentage): Function. Switch a dimming device on and/or dim to the specified level. Supports command options.
lastLevel: Number. The level of a dimmer just before it was switched off. Note: lastLevel only shows you the previous level if you have a trigger for the device itself. So for instance you have a on-trigger for ‘myDimmer’ and the dimmer is set from 20% to 30%, in your script myDimmer.level == 30 and myDimmer.lastLevel == 20.
level: Number. For dimmers and other ‘Set Level..%’ devices this holds the level like selector switches.
levelActions: String. |-separated list of url actions for selector switches.
levelName: String. Current level name for selector switches.
levelNames: Table. Table holding the level names for selector switch devices.
levelVal: Number. The numeric level of a selector.
maxDimLevel: Number.
open(): Function. Set device to Open if it supports it. Supports command options.
quietOn(): Function. Set deviceStatus to on without physically switching it. Subsequent Events are triggered. Supports some command options.
quietOff(): Function. set deviceStatus to off without physically switching it. Subsequent Events are triggered. Supports some command options.
setLevel(percentage): Function. Set device to a given level if it supports it (e.g. blinds percentage). Supports command options.
stop(): Function. Set device to Stop if it supports it (e.g. blinds). Supports command options.
switchOff(): Function. Switch device off it is supports it. Supports command options.
switchOn(): Function. Switch device on if it supports it. Supports command options.
switchSelector(<[level]|[levelname] >) : Function. Switches a selector switch to a specific level ( levelname or level(numeric) required ) levelname must be exact, for level the closest fit will be picked. See the edit page in Domoticz for such a switch to get a list of the values). Levelname is only supported when level 0 (“Off”) is not removed Supports command options.
toggleSwitch(): Function. Toggles the state of the switch (if it is togglable) like On/Off, Open/Close etc.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
- waltervl
- Posts: 5761
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: WIFI Control Smart Life Tuya IP66 Outdoor 30W RGBCW LED Floodlight
For color you different options, also from wiki docs:
RGBW(W) / Lighting Limitless/Applamp
decreaseBrightness(): deprecated because only very limited supported and will be removed from API
getColor(); Function. Returns table with color attributes or nil when color field of device is not set.
increaseBrightness(): deprecated because only very limited supported and will be removed from API
setColor(r, g, b, br, cw, ww, m, t): Function. Sets the light to requested color. r, g, b required, others optional. Supports command options. Meaning and limits of parms can be found here.
setColorBrightness(): same as setColor
setDiscoMode(modeNum): deprecated because only very limited supported and will be removed from API
setHex(r, g, b): Function. Sets the light to requested color. r, g, b required (decimal Values 0-255). Supports command options.
setHue(hue, brightness, isWhite): Function. Sets the light to requested Hue. Hue and brightness required. Supports command options.
setKelvin(Kelvin): Function. Sets Kelvin level of the light (For RGBWW devices only). Supports command options.
setNightMode(): Function. Sets the lamp to night mode. Supports command options.
setRGB(red, green, blue): Function. Set the lamps RGB color. Values are from 0-255. Supports command options.
setWhiteMode(): Function. Sets the lamp to white mode. Supports command options.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest