Dzvents

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
aukesp
Posts: 14
Joined: Wednesday 24 December 2014 21:16
Target OS: Linux
Domoticz version: 2202.2
Location: Netherlands
Contact:

Dzvents

Post by aukesp »

Hi All,

I am quiet a new bee and I am struggling with some Dzvents code.
problem is a have device
I have the following code:

Code: Select all

return {
	on = {
		timer = { 'every 1 minutes at daytime' },   
	},
	execute = function(domoticz, device)

				local CurPower = domoticz.devices('ScreenBijkeuken') 
				local oldvalue = domoticz.devices('SMACurPower')
				domoticz.log('Sensor value: ' .. oldvalue, domoticz.LOG_DEBUG)
--				CurPower.updateCustomSensor(oldvalue) -- this is step 2 update an virtual device
			
				domoticz.log('Device ' .. oldvalue.value .. ' was changed', domoticz.LOG_INFO)
			end
}
I hoped to see the oldvalue in the logfile but i just got an error

2022-06-28 15:15:00.500 Error: dzVents: Error: (3.1.8) ...86)\Domoticz\scripts\dzVents\scripts/VirtualSwitches.lua:12: attempt to concatenate a table value (local 'oldvalue'

What I am doing wrong?
User avatar
waltervl
Posts: 5843
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Dzvents

Post by waltervl »

You forgot the read the value extension to old value. It is now referring to the device itself but you would like to have a value of that device. For example actualWatt value of SMACurPower:

local oldvalue = domoticz.devices('SMACurPower').actualWatt

Change .actualWatt to the device value you would like to use.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
aukesp
Posts: 14
Joined: Wednesday 24 December 2014 21:16
Target OS: Linux
Domoticz version: 2202.2
Location: Netherlands
Contact:

Re: Dzvents

Post by aukesp »

Thanks for your reply,
I try to find the device value, but how do I now what valua to use?
Where can I find this value name?
I only see state value's like state and value but they have also value nil.
User avatar
waltervl
Posts: 5843
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Dzvents

Post by waltervl »

It is all documented in the wiki: https://www.domoticz.com/wiki/DzVents:_ ... _scripting
Especially in the devices section, there are attributes and methods for all but also device specific:
https://www.domoticz.com/wiki/DzVents:_ ... ll_devices
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
aukesp
Posts: 14
Joined: Wednesday 24 December 2014 21:16
Target OS: Linux
Domoticz version: 2202.2
Location: Netherlands
Contact:

Re: Dzvents

Post by aukesp »

Thanks, but still confusing.
For my temparature device i use temperature value because i found so on the forum.
At Wiki I do not find such device value names??
Could you please give me some extra info?
User avatar
waltervl
Posts: 5843
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Dzvents

Post by waltervl »

From the wiki:
Temperature sensor
.temperature: Number
.updateTemperature(temperature): Function. Note: temperature must be in Celsius. Use domoticz.toCelsius() to convert a Fahrenheit temperature to Celsius. Supports command options.
So to read the temperature use

Code: Select all

local ReadTemp = domoticz.devices('YourTempDevice').temperature
To update a dummy temperature device to 30 degrees(that is not set by another hardware gateway!)

Code: Select all

domoticz.devices('YourTempDevice').updateTemperature(30)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
aukesp
Posts: 14
Joined: Wednesday 24 December 2014 21:16
Target OS: Linux
Domoticz version: 2202.2
Location: Netherlands
Contact:

Re: Dzvents

Post by aukesp »

Hi Waltervl,
Thanks for your reply, this helps
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest