No devicechanged with a virtual device

Moderator: leecollings

Post Reply
djdehaan
Posts: 44
Joined: Thursday 11 June 2015 23:36
Target OS: Windows
Domoticz version: 2023.2
Location: Utrecht, NL
Contact:

No devicechanged with a virtual device

Post 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
FlyingDomotic
Posts: 303
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: No devicechanged with a virtual device

Post 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).
djdehaan
Posts: 44
Joined: Thursday 11 June 2015 23:36
Target OS: Windows
Domoticz version: 2023.2
Location: Utrecht, NL
Contact:

Re: No devicechanged with a virtual device

Post 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
FlyingDomotic
Posts: 303
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: No devicechanged with a virtual device

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest