Page 1 of 1

No devicechanged with a virtual device

Posted: Thursday 29 June 2023 22:56
by djdehaan
Hi, I have a question about the virtual devices, and how to script in Lua a response to a value change of the virtual device. My problem is this. I have the following 2 devices: P1GW AC and P1GW Power. The first one is a virtual device, the other a preset type in Domoticz (P1 Smart Meter). Both devices are updated. The below script does work for the preset type but does not work for the virtual device. That device, when updated, will show the new value on the webpage but will not trigger the below Lua event. How do I catch changes is a virtual device?

Below a fragment of the script_device_ALL.lua

Code: Select all

local DEV_P1GWAC = 'P1GW AC'
if (devicechanged[DEV_P1GWAC]) then
    print("P1GW AC Power update")
  myClass.sendUDPAC(IP_IXII)
end

local DEV_P1GWPW = 'P1GW Power'
if (devicechanged[DEV_P1GWPW]) then
  print("P1GW P1 Power update")
  myClass.sendUDPP1(IP_IXII)
end
Thanks for any thoughts,
DJ

Re: No devicechanged with a virtual device

Posted: Monday 03 July 2023 21:28
by FlyingDomotic
You may try something like:

Code: Select all

for deviceName,deviceValue in pairs(devicechanged) do
	if (deviceName=='P1GW AC') then
		print("P1GW AC Power update")
		myClass.sendUDPAC(IP_IXII)
	end
	if (deviceName=='P1GW Power') then
		print("P1GW AC Power update")
		myClass.sendUDPAC(IP_IXII)
	end
end
Check names, as they should exactly be the same as declared in Domoticz (including case and spaces).
Check also that changes to virtual device are not done silently (which are not triggering change events).

Re: No devicechanged with a virtual device

Posted: Tuesday 04 July 2023 14:00
by djdehaan
Hi,

Thanks for your reply. I did do the for .. in pairs routine, and the device does not appear there.

I think the cause may be in this sentence:
Check also that changes to virtual device are not done silently (which are not triggering change events).

In what situation do I do a change silently?

Regards,
DJ

Re: No devicechanged with a virtual device

Posted: Tuesday 04 July 2023 23:29
by FlyingDomotic
Hi,
Did you properly checked the exact names?
For silent changes, this could be done by dzVents scripts, using .slient() after a switch command.
You can also use http command on json.html with &parsetrigger=false