UserVariables not always set after Device Trigger Off[edit]

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

Moderator: leecollings

Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Having some troubles on detecting if a script is triggered by a timerrule or device.

I have the following test event;

Code: Select all

return {
	on = {
	    timer = {'every 15 minutes'},
		devices = {'Badkamer verlichting'}
	},
	execute = function(domoticz, device, triggerInfo)
	    
	    if(device.isDevice)then
	            domoticz.variables('BadkVerwarmingOnTime').set(os.time())
	    	    domoticz.variables('BadkVerwarmingOffTime').set(os.time())
	    	    device.dump()
	    end
	end
}
When running this code only when switching the "Badkamer verlichting" On, the variables are updated.
When switching the device Off, nothing happens.

I tried to debug with some notifications and the loggin page and from execute line till the last "}", all notifications are send/received.
Also tried to dump the "device" variable and I noticed that only when the device is switch On, the paramater isDevice is precence.
When switch off, the parameter isScene is precence with the value "False".

So it looks like there's something wrong with this.
Don't no whats going on and/or what i'm doing wrong....
Hope somebody can help :)

Here's an log from switching the device on;

Code: Select all

2019-01-28 12:13:54.998 Status: dzVents: > hour: 12
2019-01-28 12:13:54.998 Status: dzVents: > isUTC: false
2019-01-28 12:13:54.998 Status: dzVents: > daysAgo: 0
2019-01-28 12:13:54.998 Status: dzVents: > isToday: true
2019-01-28 12:13:54.998 Status: dzVents: > minutes: 13
2019-01-28 12:13:54.998 Status: dzVents: > hoursAgo: 0
2019-01-28 12:13:54.998 Status: dzVents: > kodiPause()
2019-01-28 12:13:54.998 Status: dzVents: > updateTempHumBaro()
2019-01-28 12:13:54.998 Status: dzVents: > kodiStop()
2019-01-28 12:13:54.998 Status: dzVents: > baseType: device
2019-01-28 12:13:54.998 Status: dzVents: > hardwareID: 9
2019-01-28 12:13:54.998 Status: dzVents: > play()
2019-01-28 12:13:54.998 Status: dzVents: > setKelvin()
2019-01-28 12:13:54.999 Status: dzVents: > updateRadiation()
2019-01-28 12:13:54.999 Status: dzVents: > signalLevel: 12
2019-01-28 12:13:54.999 Status: dzVents: > armAway()
2019-01-28 12:13:54.999 Status: dzVents: > updateCustomSensor()
2019-01-28 12:13:54.999 Status: dzVents: > setWhiteMode()
2019-01-28 12:13:54.999 Status: dzVents: > updateVoltage()
2019-01-28 12:13:54.999 Status: dzVents: > updateVisibility()
2019-01-28 12:13:54.999 Status: dzVents: > updateP1()
2019-01-28 12:13:54.999 Status: dzVents: > icon: lightbulb
2019-01-28 12:13:54.999 Status: dzVents: > updateText()
2019-01-28 12:13:54.999 Status: dzVents: > timedOut: false
2019-01-28 12:13:54.999 Status: dzVents: > setRGB()
2019-01-28 12:13:54.999 Status: dzVents: > dump()
2019-01-28 12:13:54.999 Status: dzVents: > setNightMode()
2019-01-28 12:13:54.999 Status: dzVents: > changed: true
2019-01-28 12:13:54.999 Status: dzVents: > isDevice: true
2019-01-28 12:13:54.999 Status: dzVents: > hardwareName: Zwave
2019-01-28 12:13:54.999 Status: dzVents: > name: Badkamer verlichting
2019-01-28 12:13:54.999 Status: dzVents: > playFavorites()
2019-01-28 12:13:54.999 Status: dzVents: > active: true
2019-01-28 12:13:54.999 Status: dzVents: > updateWetness()
2019-01-28 12:13:54.999 Status: dzVents: > updateSoilMoisture()
2019-01-28 12:13:54.999 Status: dzVents: > armHome()
2019-01-28 12:13:54.999 Status: dzVents: > updateTempBaro()
2019-01-28 12:13:54.999 Status: dzVents: > decreaseBrightness()
2019-01-28 12:13:54.999 Status: dzVents: > rawData:
2019-01-28 12:13:54.999 Status: dzVents: > 1: 0
2019-01-28 12:13:54.999 Status: dzVents: > increaseBrightness()
2019-01-28 12:13:54.999 Status: dzVents: > updateMode()
2019-01-28 12:13:54.999 Status: dzVents: > updateRain()
2019-01-28 12:13:54.999 Status: dzVents: > updatePercentage()
2019-01-28 12:13:54.999 Status: dzVents: > _data:
2019-01-28 12:13:54.999 Status: dzVents: > lastUpdate: 2019-01-28 12:13:04
2019-01-28 12:13:54.999 Status: dzVents: > rawData:
2019-01-28 12:13:54.999 Status: dzVents: > 1: 0
2019-01-28 12:13:54.999 Status: dzVents: > baseType: device
2019-01-28 12:13:54.999 Status: dzVents: > deviceType: Light/Switch
2019-01-28 12:13:55.000 Status: dzVents: > signalLevel: 12
2019-01-28 12:13:55.000 Status: dzVents: > subType: Switch
2019-01-28 12:13:55.000 Status: dzVents: > switchTypeValue: 0
2019-01-28 12:13:55.000 Status: dzVents: > description: Alexa_Name: bathroom lights
2019-01-28 12:13:55.000 Status: dzVents: > timedOut: false
2019-01-28 12:13:55.000 Status: dzVents: > lastLevel: 0
2019-01-28 12:13:55.000 Status: dzVents: > changed: true
2019-01-28 12:13:55.000 Status: dzVents: > data:
2019-01-28 12:13:55.000 Status: dzVents: > _state: On
2019-01-28 12:13:55.000 Status: dzVents: > icon: lightbulb
2019-01-28 12:13:55.000 Status: dzVents: > hardwareType: OpenZWave USB
2019-01-28 12:13:55.000 Status: dzVents: > hardwareID: 9
2019-01-28 12:13:55.000 Status: dzVents: > usedByCamera: false
2019-01-28 12:13:55.000 Status: dzVents: > maxDimLevel: 100
2019-01-28 12:13:55.000 Status: dzVents: > hardwareName: Zwave
2019-01-28 12:13:55.000 Status: dzVents: > protected: false
2019-01-28 12:13:55.000 Status: dzVents: > _nValue: 1
2019-01-28 12:13:55.000 Status: dzVents: > hardwareTypeValue: 21
2019-01-28 12:13:55.000 Status: dzVents: > levelVal: 0
2019-01-28 12:13:55.000 Status: dzVents: > unit: 1
2019-01-28 12:13:55.000 Status: dzVents: > name: Badkamer verlichting
2019-01-28 12:13:55.000 Status: dzVents: > batteryLevel: 255
2019-01-28 12:13:55.000 Status: dzVents: > switchType: On/Off
2019-01-28 12:13:55.000 Status: dzVents: > deviceID: 00000801
2019-01-28 12:13:55.000 Status: dzVents: > id: 237
2019-01-28 12:13:55.000 Status: dzVents: > updateGas()
2019-01-28 12:13:55.000 Status: dzVents: > updateUV()
2019-01-28 12:13:55.000 Status: dzVents: > setDiscoMode()
2019-01-28 12:13:55.000 Status: dzVents: > bState: true
2019-01-28 12:13:55.000 Status: dzVents: > startPlaylist()
2019-01-28 12:13:55.000 Status: dzVents: > kodiSwitchOff()
2019-01-28 12:13:55.000 Status: dzVents: > stop()
2019-01-28 12:13:55.000 Status: dzVents: > deviceType: Light/Switch
2019-01-28 12:13:55.000 Status: dzVents: > updateTemperature()
2019-01-28 12:13:55.000 Status: dzVents: > updateElectricity()
2019-01-28 12:13:55.000 Status: dzVents: > hardwareType: OpenZWave USB
2019-01-28 12:13:55.000 Status: dzVents: > updateSetPoint()
2019-01-28 12:13:55.000 Status: dzVents: > updateHumidity()
2019-01-28 12:13:55.000 Status: dzVents: > switchOff()
2019-01-28 12:13:55.000 Status: dzVents: > levelVal: 0
2019-01-28 12:13:55.000 Status: dzVents: > updateDistance()
2019-01-28 12:13:55.000 Status: dzVents: > updateCounter()
2019-01-28 12:13:55.000 Status: dzVents: > state: On
2019-01-28 12:13:55.001 Status: dzVents: > usedByCamera: false
2019-01-28 12:13:55.001 Status: dzVents: > updateBarometer()
2019-01-28 12:13:55.001 Status: dzVents: > idx: 237
2019-01-28 12:13:55.001 Status: dzVents: > isSecurity: false
2019-01-28 12:13:55.001 Status: dzVents: > unit: 1
2019-01-28 12:13:55.209 Status: Set UserVariable BadkVerwarmingOnTime = 1548674035
2019-01-28 12:13:55.210 Status: Set UserVariable BadkVerwarmingOffTime = 1548674035
2019-01-28 12:13:57.242 (Zwave) General/kWh (kWh Meter)
2019-01-28 12:13:59.931 (Zwave) General/kWh (kWh Meter)

And here from switching it off;

Code: Select all

2019-01-28 12:25:33.650 Status: dzVents: > switchOn()
2019-01-28 12:25:33.650 Status: dzVents: > kodiStop()
2019-01-28 12:25:33.650 Status: dzVents: > setHotWater()
2019-01-28 12:25:33.650 Status: dzVents: > _adapters:
2019-01-28 12:25:33.651 Status: dzVents: > 1: Switch device adapter
2019-01-28 12:25:33.651 Status: dzVents: > updateTemperature()
2019-01-28 12:25:33.651 Status: dzVents: > updateMode()
2019-01-28 12:25:33.651 Status: dzVents: > setWhiteMode()
2019-01-28 12:25:33.651 Status: dzVents: > updateWind()
2019-01-28 12:25:33.651 Status: dzVents: > updateDistance()
2019-01-28 12:25:33.651 Status: dzVents: > updateRain()
2019-01-28 12:25:33.651 Status: dzVents: > updateYouless()
2019-01-28 12:25:33.651 Status: dzVents: > stop()
2019-01-28 12:25:33.651 Status: dzVents: > isGroup: false
2019-01-28 12:25:33.651 Status: dzVents: > updateWaterflow()
2019-01-28 12:25:33.651 Status: dzVents: > updateUV()
2019-01-28 12:25:33.651 Status: dzVents: > play()
2019-01-28 12:25:33.651 Status: dzVents: > updateTempBaro()
2019-01-28 12:25:33.651 Status: dzVents: > updateTempHum()
2019-01-28 12:25:33.651 Status: dzVents: > updateP1()
2019-01-28 12:25:33.651 Status: dzVents: > isSecurity: false
2019-01-28 12:25:33.651 Status: dzVents: > signalLevel: 12
2019-01-28 12:25:33.651 Status: dzVents: > deviceId: 00000801
2019-01-28 12:25:33.651 Status: dzVents: > armHome()
2019-01-28 12:25:33.651 Status: dzVents: > setState()
2019-01-28 12:25:33.651 Status: dzVents: > isVariable: false
2019-01-28 12:25:33.651 Status: dzVents: > disarm()
2019-01-28 12:25:33.651 Status: dzVents: > pause()
2019-01-28 12:25:33.651 Status: dzVents: > switchOff()
2019-01-28 12:25:33.651 Status: dzVents: > armAway()
2019-01-28 12:25:33.651 Status: dzVents: > updateCounter()
2019-01-28 12:25:33.651 Status: dzVents: > setDiscoMode()
2019-01-28 12:25:33.651 Status: dzVents: > _data:
2019-01-28 12:25:33.651 Status: dzVents: > changed: true
2019-01-28 12:25:33.651 Status: dzVents: > deviceID: 00000801
2019-01-28 12:25:33.651 Status: dzVents: > subType: Switch
2019-01-28 12:25:33.651 Status: dzVents: > description: Alexa_Name: bathroom lights
2019-01-28 12:25:33.651 Status: dzVents: > data:
2019-01-28 12:25:33.651 Status: dzVents: > _nValue: 0
2019-01-28 12:25:33.651 Status: dzVents: > icon: lightbulb
2019-01-28 12:25:33.651 Status: dzVents: > usedByCamera: false
2019-01-28 12:25:33.651 Status: dzVents: > hardwareName: Zwave
2019-01-28 12:25:33.651 Status: dzVents: > protected: false
2019-01-28 12:25:33.651 Status: dzVents: > hardwareTypeValue: 21
2019-01-28 12:25:33.651 Status: dzVents: > unit: 1
2019-01-28 12:25:33.651 Status: dzVents: > maxDimLevel: 100
2019-01-28 12:25:33.651 Status: dzVents: > hardwareType: OpenZWave USB
2019-01-28 12:25:33.651 Status: dzVents: > levelVal: 0
2019-01-28 12:25:33.651 Status: dzVents: > _state: Off
2019-01-28 12:25:33.652 Status: dzVents: > hardwareID: 9
2019-01-28 12:25:33.652 Status: dzVents: > rawData:
2019-01-28 12:25:33.652 Status: dzVents: > 1: 0
2019-01-28 12:25:33.652 Status: dzVents: > lastUpdate: 2019-01-28 12:17:30
2019-01-28 12:25:33.652 Status: dzVents: > signalLevel: 12
2019-01-28 12:25:33.652 Status: dzVents: > switchTypeValue: 0
2019-01-28 12:25:33.652 Status: dzVents: > switchType: On/Off
2019-01-28 12:25:33.652 Status: dzVents: > lastLevel: 0
2019-01-28 12:25:33.652 Status: dzVents: > batteryLevel: 255
2019-01-28 12:25:33.652 Status: dzVents: > baseType: device
2019-01-28 12:25:33.652 Status: dzVents: > timedOut: false
2019-01-28 12:25:33.652 Status: dzVents: > id: 237
2019-01-28 12:25:33.652 Status: dzVents: > name: Badkamer verlichting
2019-01-28 12:25:33.652 Status: dzVents: > deviceType: Light/Switch
2019-01-28 12:25:33.652 Status: dzVents: > baseType: device
2019-01-28 12:25:33.652 Status: dzVents: > timedOut: false
2019-01-28 12:25:33.652 Status: dzVents: > updateCustomSensor()
2019-01-28 12:25:33.652 Status: dzVents: > setRGB()
2019-01-28 12:25:33.652 Status: dzVents: > hardwareID: 9
2019-01-28 12:25:33.652 Status: dzVents: > changed: true
2019-01-28 12:25:33.652 Status: dzVents: > updateVoltage()
2019-01-28 12:25:33.652 Status: dzVents: > cancelQueuedCommands()
2019-01-28 12:25:33.652 Status: dzVents: > icon: lightbulb
2019-01-28 12:25:33.652 Status: dzVents: > hardwareId: 9
2019-01-28 12:25:33.652 Status: dzVents: > idx: 237
2019-01-28 12:25:33.652 Status: dzVents: > setKelvin()
2019-01-28 12:25:33.652 Status: dzVents: > maxDimLevel: 100
2019-01-28 12:25:33.652 Status: dzVents: > isTimer: false
2019-01-28 12:25:33.652 Status: dzVents: > hardwareTypeValue: 21
2019-01-28 12:25:33.652 Status: dzVents: > updateVisibility()
2019-01-28 12:25:33.652 Status: dzVents: > active: false
2019-01-28 12:25:33.652 Status: dzVents: > updateSoundLevel()
2019-01-28 12:25:33.652 Status: dzVents: > updateLux()
2019-01-28 12:25:33.652 Status: dzVents: > playFavorites()
2019-01-28 12:25:33.652 Status: dzVents: > description: Alexa_Name: bathroom lights
2019-01-28 12:25:33.652 Status: dzVents: > isScene: false
2019-01-28 12:25:33.652 Status: dzVents: > decreaseBrightness()
2019-01-28 12:25:33.652 Status: dzVents: > protected: false
2019-01-28 12:25:33.652 Status: dzVents: > increaseBrightness()
2019-01-28 12:25:33.652 Status: dzVents: > updateRadiation()
2019-01-28 12:25:33.652 Status: dzVents: > switchType: On/Off
2019-01-28 12:25:33.652 Status: dzVents: > updateWetness()
2019-01-28 12:25:33.652 Status: dzVents: > unit: 1
2019-01-28 12:25:33.653 Status: dzVents: > bState: false
2019-01-28 12:25:33.653 Status: dzVents: > _state: Off
2019-01-28 12:25:33.653 Status: dzVents: > updateSetPoint()
2019-01-28 12:25:33.653 Status: dzVents: > updateBarometer()
2019-01-28 12:25:33.653 Status: dzVents: > setVolume()
2019-01-28 12:25:33.653 Status: dzVents: > kodiSwitchOff()
2019-01-28 12:25:33.653 Status: dzVents: > _nValue: 0
2019-01-28 12:25:33.653 Status: dzVents: > deviceType: Light/Switch
2019-01-28 12:25:34.858 OpenZWave: Domoticz has send a Switch command! NodeID: 6 (0x06)
2019-01-28 12:25:34.872 (Zwave) Usage (Badkamer Verwarming(Watt))
2019-01-28 12:25:34.922 (Zwave) General/kWh (Badkamer Verwarming(kWh))
2019-01-28 12:25:34.930 (Zwave) Light/Switch (Badkamer Verwarming)


some extra info;
Running version 4.10362

Raspbian;
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Hardware:
Raspberry Pi 3 Model B Plus Rev 1.3
Last edited by Freemann on Monday 28 January 2019 22:26, edited 3 times in total.
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
Doler
Posts: 142
Joined: Friday 31 July 2015 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Sint-Oedenrode, Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by Doler »

I also noticed something strange: using the following script:

Code: Select all

return {
	active = true,
	on = {
		--timer = { 'every minute' },
		devices = { 'Testswitch' },
	},
	logging = {
		level = LOG_LEVEL,
		marker = LOG_MARKER
	},
	execute = function(dz, response, triggerInfo)
	
		for i, v in pairs(response) do
			print(i .. ': ' .. tostring(v))
		end	
	
	end
}
I get the following on a timer event:
Spoiler: show
2019-01-28 13:13:00.329 Status: dzVents: isScene: false
2019-01-28 13:13:00.330 Status: dzVents: isGroup: false
2019-01-28 13:13:00.330 Status: dzVents: isVariable: false
2019-01-28 13:13:00.330 Status: dzVents: isHTTPResponse: false
2019-01-28 13:13:00.330 Status: dzVents: baseType: timer
2019-01-28 13:13:00.330 Status: dzVents: isSecurity: false
2019-01-28 13:13:00.330 Status: dzVents: isTimer: true
2019-01-28 13:13:00.330 Status: dzVents: isDevice: false
2019-01-28 13:13:00.330 Status: dzVents: trigger: every minute
which is exactly what you expect. But when you get a device event you get something weird:
Spoiler: show
2019-01-28 13:14:19.158 (DummyHW) Light/Switch (Testswitch)
2019-01-28 13:14:19.312 Status: dzVents: updateYouless: function: 0x6e6be4c0
2019-01-28 13:14:19.312 Status: dzVents: isSecurity: false
2019-01-28 13:14:19.312 Status: dzVents: signalLevel: 12
2019-01-28 13:14:19.313 Status: dzVents: isHTTPResponse: false
2019-01-28 13:14:19.313 Status: dzVents: pause: function: 0x6e63fee8
2019-01-28 13:14:19.313 Status: dzVents: protected: false
2019-01-28 13:14:19.313 Status: dzVents: updateWeight: function: 0x6e6b0db0
2019-01-28 13:14:19.313 Status: dzVents: levelVal: 0
2019-01-28 13:14:19.313 Status: dzVents: updateWaterflow: function: 0x6e6bf6a8
2019-01-28 13:14:19.313 Status: dzVents: disarm: function: 0x6e6850c8
2019-01-28 13:14:19.313 Status: dzVents: switchSelector: function: 0x6e6c50f8
2019-01-28 13:14:19.313 Status: dzVents: state: Off
2019-01-28 13:14:19.313 Status: dzVents: dimTo: function: 0x6e6c50d0
2019-01-28 13:14:19.313 Status: dzVents: _data: table: 0x6e605bd8
2019-01-28 13:14:19.313 Status: dzVents: deviceType: Light/Switch
2019-01-28 13:14:19.313 Status: dzVents: kodiPlayPlaylist: function: 0x6e688670
2019-01-28 13:14:19.313 Status: dzVents: hardwareType: Dummy (Does nothing, use for virtual switches only)
2019-01-28 13:14:19.313 Status: dzVents: increaseBrightness: function: 0x6e651968
2019-01-28 13:14:19.313 Status: dzVents: switchOn: function: 0x6e670e00
2019-01-28 13:14:19.313 Status: dzVents: toggleSwitch: function: 0x6e6c5030
2019-01-28 13:14:19.313 Status: dzVents: level: 0
2019-01-28 13:14:19.314 Status: dzVents: updateBarometer: function: 0x6e678218
2019-01-28 13:14:19.314 Status: dzVents: lastLevel: 0
2019-01-28 13:14:19.314 Status: dzVents: baseType: device
2019-01-28 13:14:19.314 Status: dzVents: setNightMode: function: 0x6e6b6900
2019-01-28 13:14:19.314 Status: dzVents: updateVoltage: function: 0x6e6bce88
2019-01-28 13:14:19.314 Status: dzVents: update: function: 0x6e68bd10
2019-01-28 13:14:19.314 Status: dzVents: dump: function: 0x6e66ef70
2019-01-28 13:14:19.314 Status: dzVents: nValue: 0
2019-01-28 13:14:19.314 Status: dzVents: isVariable: false
2019-01-28 13:14:19.314 Status: dzVents: updateGas: function: 0x6e675100
2019-01-28 13:14:19.314 Status: dzVents: updateP1: function: 0x6e69b658
2019-01-28 13:14:19.314 Status: dzVents: startPlaylist: function: 0x6e6502c0
2019-01-28 13:14:19.314 Status: dzVents: kodiPlay: function: 0x6e6c8680
2019-01-28 13:14:19.314 Status: dzVents: cancelQueuedCommands: function: 0x6e652650
2019-01-28 13:14:19.314 Status: dzVents: setDiscoMode: function: 0x6e6b6380
2019-01-28 13:14:19.314 Status: dzVents: play: function: 0x6e65a6e0
2019-01-28 13:14:19.314 Status: dzVents: kodiExecuteAddOn: function: 0x6e688240
2019-01-28 13:14:19.314 Status: dzVents: updateCounter: function: 0x6e650b58
2019-01-28 13:14:19.314 Status: dzVents: name: Testswitch
2019-01-28 13:14:19.314 Status: dzVents: updateTempHum: function: 0x6e6698f8
2019-01-28 13:14:19.314 Status: dzVents: updateVisibility: function: 0x6e6bae10
2019-01-28 13:14:19.314 Status: dzVents: updateUV: function: 0x6e66be98
2019-01-28 13:14:19.315 Status: dzVents: kodiSwitchOff: function: 0x6e6c7a90
2019-01-28 13:14:19.315 Status: dzVents: maxDimLevel: 100
2019-01-28 13:14:19.315 Status: dzVents: _state: Off
2019-01-28 13:14:19.315 Status: dzVents: updateTempBaro: function: 0x6e693bf8
2019-01-28 13:14:19.315 Status: dzVents: updateElectricity: function: 0x6e68c890
2019-01-28 13:14:19.315 Status: dzVents: hardwareID: 5
2019-01-28 13:14:19.315 Status: dzVents: open: function: 0x6e6c3118
2019-01-28 13:14:19.315 Status: dzVents: active: false
2019-01-28 13:14:19.315 Status: dzVents: hardwareId: 5
2019-01-28 13:14:19.315 Status: dzVents: unit: 1
2019-01-28 13:14:19.315 Status: dzVents: updateSoundLevel: function: 0x6e6a8708
2019-01-28 13:14:19.315 Status: dzVents: updateSoilMoisture: function: 0x6e61cbc8
2019-01-28 13:14:19.315 Status: dzVents: armAway: function: 0x6e6852c0
2019-01-28 13:14:19.315 Status: dzVents: setVolume: function: 0x6e63fea0
2019-01-28 13:14:19.315 Status: dzVents: _nValue: 0
2019-01-28 13:14:19.315 Status: dzVents: onkyoEISCPCommand: function: 0x6e63a360
2019-01-28 13:14:19.315 Status: dzVents: kodiStop: function: 0x6e6c9308
2019-01-28 13:14:19.315 Status: dzVents: playFavorites: function: 0x6e6abba8
2019-01-28 13:14:19.315 Status: dzVents: setRGB: function: 0x6e6b63c8
2019-01-28 13:14:19.316 Status: dzVents: kodiPlayFavorites: function: 0x6e6c1d90
2019-01-28 13:14:19.316 Status: dzVents: decreaseBrightness: function: 0x6e681a50
2019-01-28 13:14:19.316 Status: dzVents: isGroup: false
2019-01-28 13:14:19.316 Status: dzVents: close: function: 0x6e6c2b30
2019-01-28 13:14:19.316 Status: dzVents: setWhiteMode: function: 0x6e647908
2019-01-28 13:14:19.316 Status: dzVents: setState: function: 0x6e6830b0
2019-01-28 13:14:19.316 Status: dzVents: updateHumidity: function: 0x6e6797e0
2019-01-28 13:14:19.316 Status: dzVents: updatePressure: function: 0x6e678be0
2019-01-28 13:14:19.316 Status: dzVents: switchTypeValue: 0
2019-01-28 13:14:19.316 Status: dzVents: updateSetPoint: function: 0x6e6b8af8
2019-01-28 13:14:19.316 Status: dzVents: bState: false
2019-01-28 13:14:19.316 Status: dzVents: description:
2019-01-28 13:14:19.316 Status: dzVents: isScene: false
2019-01-28 13:14:19.316 Status: dzVents: id: 22
2019-01-28 13:14:19.316 Status: dzVents: usedByCamera: false
2019-01-28 13:14:19.316 Status: dzVents: updateLux: function: 0x6e63f640
2019-01-28 13:14:19.316 Status: dzVents: updateAirQuality: function: 0x6e67f5c0
2019-01-28 13:14:19.316 Status: dzVents: deviceId: 00014066
2019-01-28 13:14:19.316 Status: dzVents: deviceSubType: Switch
2019-01-28 13:14:19.316 Status: dzVents: kodiSetVolume: function: 0x6e6ca1f0
2019-01-28 13:14:19.316 Status: dzVents: rawData: table: 0x6e606058
2019-01-28 13:14:19.316 Status: dzVents: kodiPause: function: 0x6e6ca380
2019-01-28 13:14:19.317 Status: dzVents: updateWetness: function: 0x6e6a2f30
2019-01-28 13:14:19.317 Status: dzVents: updateDistance: function: 0x6e66f0b0
2019-01-28 13:14:19.317 Status: dzVents: icon: lightbulb
2019-01-28 13:14:19.317 Status: dzVents: isTimer: false
2019-01-28 13:14:19.317 Status: dzVents: hardwareTypeValue: 15
2019-01-28 13:14:19.317 Status: dzVents: updateTemperature: function: 0x6e64d390
2019-01-28 13:14:19.317 Status: dzVents: updatePercentage: function: 0x6e6807b0
2019-01-28 13:14:19.317 Status: dzVents: switchOff: function: 0x6e6becc0
2019-01-28 13:14:19.317 Status: dzVents: setKelvin: function: 0x6e6acba8
2019-01-28 13:14:19.317 Status: dzVents: updateMode: function: 0x6e6c4720
2019-01-28 13:14:19.317 Status: dzVents: updateCustomSensor: function: 0x6e685db8
2019-01-28 13:14:19.317 Status: dzVents: lastUpdate: table: 0x6e6ada60
2019-01-28 13:14:19.317 Status: dzVents: hardwareName: DummyHW
2019-01-28 13:14:19.317 Status: dzVents: updateTempHumBaro: function: 0x6e6904a0
2019-01-28 13:14:19.317 Status: dzVents: updateAlertSensor: function: 0x6e638f98
2019-01-28 13:14:19.317 Status: dzVents: updateWind: function: 0x6e6c1710
Maybe @waaren can shed a light on this?

Mark
Mark: Domoticz Beta on Raspberry Pi 4 running Debian Bookworm - Z-Stick 7 - RFXCom - P1 - MySensors - SolarEdge - Dahua - Philips Hue - Docker - Zigbee2mqtt (plugin) - Zwave-js-ui - dzVents - Nodered
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by waaren »

Freemann wrote: Monday 28 January 2019 12:29 Having some troubles on detecting if a script is triggered by a timerrule or device.
I cannot reproduce that behavior and I test on a PI3 with debian stretch and domoticz 4.10364 .
With the test script below I see the expected values for a script triggered by switch, sensor or timer.
I miss many lines in the output of your dump command. I f you log to an OS file you can see more than the max 100 lines in the GUI

Code: Select all

-- isDevice check

return {
    on =        {       timer = {"every minute"},
                     devices  = { 433,1477 }},  -- 433 is sensor / 1477 is switch
                 
        logging =   {  
                        level     =   domoticz.LOG_DEBUG,       -- change to LOG_ERROR after you tested  the script
                        marker    =   "isDevice check" 
                    },
                 
    execute = function(dz, item, info )
      
        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        local trigger   = item.name
        local state     = item.state
        
        if info.trigger then 
            trigger = info.trigger 
            state   = "N/A"    
        end
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isDevice        " .. tostring(item.isDevice ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isVariable      " .. tostring(item.isVariable ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isScene         " .. tostring(item.isScene))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isGroup         " .. tostring(item.isGroup))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isTimer         " .. tostring(item.isTimer))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isSecurity      " .. tostring(item.isSecurity))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isHTTPResponse  " .. tostring(item.isHTTPResponse))
  
    end             
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by waaren »

Doler wrote: Monday 28 January 2019 13:17 I also noticed something strange: using the following script:
This is what I expect as output from this script. What is the strange part for you ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doler
Posts: 142
Joined: Friday 31 July 2015 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Sint-Oedenrode, Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by Doler »

waaren wrote: Monday 28 January 2019 14:00
Doler wrote: Monday 28 January 2019 13:17 I also noticed something strange: using the following script:
This is what I expect as output from this script. What is the strange part for you ?
The strange part is what is returned from a device event: next to the dzVents return values (isDevice, isTimer...) I see a lot of device parameters and functions that I did not expect here.

Mark
Mark: Domoticz Beta on Raspberry Pi 4 running Debian Bookworm - Z-Stick 7 - RFXCom - P1 - MySensors - SolarEdge - Dahua - Philips Hue - Docker - Zigbee2mqtt (plugin) - Zwave-js-ui - dzVents - Nodered
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by Freemann »

And in my case I'm missing the isDevice parameter when the z-wave device is switch off.
It's not logged on the logging page, also the variables are not set.

So if the logging page is, for what reason, is not showing the line with 'isDevice()', the script is not trigger on "device.isDevice".

Very strange!
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by waaren »

Freemann wrote: Monday 28 January 2019 14:13 And in my case I'm missing the isDevice parameter when the z-wave device is switch off.
It's not logged on the logging page, also the variables are not set.

So if the logging page is, for what reason, is not showing the line with 'isDevice()', the script is not trigger on "device.isDevice".

Very strange!
Can you test with the script I posted (changing the device number to your Z-wave device) and post the relevant logfiles ? Maybe that will help in locating the problem.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by waaren »

Doler wrote: Monday 28 January 2019 14:08
waaren wrote: Monday 28 January 2019 14:00
Doler wrote: Monday 28 January 2019 13:17 I also noticed something strange: using the following script:
This is what I expect as output from this script. What is the strange part for you ?
The strange part is what is returned from a device event: next to the dzVents return values (isDevice, isTimer...) I see a lot of device parameters and functions that I did not expect here.

Mark
@Mark. This is because the device object (which is Lua table) contains not only the device attributes but also a lot of functions and (sub) tables.
With your for loop you see more or less the same as when you would use the dump() function. Difference is that the dump() function translate the function references to function names and for sub tables diplay the name and whats in the table.
If the trigger is a timer, the response table only contains attributes and no functions or subtables.

Hope this clarifies.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doler
Posts: 142
Joined: Friday 31 July 2015 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Sint-Oedenrode, Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by Doler »

waaren wrote: Monday 28 January 2019 14:27
Doler wrote: Monday 28 January 2019 14:08
waaren wrote: Monday 28 January 2019 14:00
This is what I expect as output from this script. What is the strange part for you ?
The strange part is what is returned from a device event: next to the dzVents return values (isDevice, isTimer...) I see a lot of device parameters and functions that I did not expect here.

Mark
@Mark. This is because the device object (which is Lua table) contains not only the device attributes but also a lot of functions and (sub) tables.
With your for loop you see more or less the same as when you would use the dump() function. Difference is that the dump() function translate the function references to function names and for sub tables diplay the name and whats in the table.
If the trigger is a timer, the response table only contains attributes and no functions or subtables.

Hope this clarifies.
Clear! Thanks for the explanation.

Mark
Mark: Domoticz Beta on Raspberry Pi 4 running Debian Bookworm - Z-Stick 7 - RFXCom - P1 - MySensors - SolarEdge - Dahua - Philips Hue - Docker - Zigbee2mqtt (plugin) - Zwave-js-ui - dzVents - Nodered
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by Freemann »

Was playing with you code and making it the same as possible.
So I after some runs, which showed all the is**** paramaters, I change the "On Device" trigger from "Badkamer verlichting" to 237 and now userVariable are changed when I Switch On and Off.

Here's the script;

Code: Select all

return {
	on = {
	    timer = {'every 15 minutes'},
		devices = {'Badkamer verlichting'}  -- line 4
		--devices = {237}                   -- line 5
	},
	        logging =   {  
                        level     =   domoticz.LOG_DEBUG,       -- change to LOG_ERROR after you tested  the script
                        marker    =   "isDevice check" 
                    },
	execute = function(domoticz, device, triggerInfo)
    	    
	    if(device.isDevice)then
            domoticz.variables('BadkVerwarmingOnTime').set(os.time())
    	    domoticz.variables('BadkVerwarmingOffTime').set(os.time())
        end
    
        device.dump()
            
    
        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            domoticz.log(tostring(str),level or domoticz.LOG_DEBUG)
        end
        
-        local trigger   = device.name
        local state     = device.state
        
        if triggerInfo.trigger then 
            trigger = triggerInfo.trigger 
            state   = "N/A"    
        end
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isDevice        " .. tostring(device.isDevice ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isVariable      " .. tostring(device.isVariable ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isScene         " .. tostring(device.isScene))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isGroup         " .. tostring(device.isGroup))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isTimer         " .. tostring(device.isTimer))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isSecurity      " .. tostring(device.isSecurity))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isHTTPResponse  " .. tostring(device.isHTTPResponse))

	end
}
So when line 4 is enabled, the script doesn't change the uservariables when the device is change to Off.
When line 5 is enabled the script is changing the uservariables when changing the device On or Off.

so;
Screenshot - 28_01_2019 , 15_27_06.png
Screenshot - 28_01_2019 , 15_27_06.png (1.38 KiB) Viewed 1346 times
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by waaren »

Freemann wrote: Monday 28 January 2019 15:28 Was playing with you code and making it the same as possible.
So I after some runs, which showed all the is**** paramaters, I change the "On Device" trigger from "Badkamer verlichting" to 237 and now userVariable are changed when I Switch On and Off.
OK could it be the case that you have 'Badkamer verlichting' more than one time in your devices / groups or scenes ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by Freemann »

That's not the case;
Screenshot - 28_01_2019 , 16_44_15.png
Screenshot - 28_01_2019 , 16_44_15.png (33.31 KiB) Viewed 1336 times
Tried to remove the space from the devicename, so I changed the name from "Badkamer verlichting" to "Badkamerverlichting" and that solved the problem.

So it looks like the device name is the problem and most likely its something to do with the space in the name?!
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by waaren »

Freemann wrote: Monday 28 January 2019 16:47 So it looks like the device name is the problem and most likely its something to do with the space in the name?!
Just tested with a unique name with a space in the name and still cannot reproduce. So must be something else.

script + output switchOff SwitchOn
Spoiler: show

Code: Select all

-- isDevice check

return {
    on =        {       timer = {"every minute"},
                     devices  = { 433,"isDevice Test" }},  -- 433 is sensor / isDevice Test switch
                 
        logging =   {  
                        level     =   domoticz.LOG_DEBUG,       -- change to LOG_ERROR after you tested  the script
                        marker    =   "isDevice check" 
                    },
                 
    execute = function(dz, item, info )
      
        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        local trigger   = item.name
        local state     = item.state
        
        if info.trigger then 
            trigger = info.trigger 
            state   = "N/A"    
        end
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isDevice        " .. tostring(item.isDevice ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isVariable      " .. tostring(item.isVariable ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isScene         " .. tostring(item.isScene))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isGroup         " .. tostring(item.isGroup))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isTimer         " .. tostring(item.isTimer))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isSecurity      " .. tostring(item.isSecurity))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isHTTPResponse  " .. tostring(item.isHTTPResponse))
  
    end             
}

Code: Select all

2019-01-28 17:59:34.912  Status: dzVents: Info:  isDevice check: ------ Start external script: dumper103.lua: Device: "isDevice Test (Virtual2)", Index: 1477
2019-01-28 17:59:34.913  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isDevice        true
2019-01-28 17:59:34.913  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isVariable      false
2019-01-28 17:59:34.913  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isScene         false
2019-01-28 17:59:34.913  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isGroup         false
2019-01-28 17:59:34.913  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isTimer         false
2019-01-28 17:59:34.914  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isSecurity      false
2019-01-28 17:59:34.914  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isHTTPResponse  false
2019-01-28 17:59:34.914  Status: dzVents: Info:  isDevice check: ------ Finished dumper103.lua

Code: Select all

2019-01-28 17:59:44.131  Status: dzVents: Info:  isDevice check: ------ Start external script: dumper103.lua: Device: "isDevice Test (Virtual2)", Index: 1477
2019-01-28 17:59:44.132  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isDevice        true
2019-01-28 17:59:44.132  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isVariable      false
2019-01-28 17:59:44.132  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isScene         false
2019-01-28 17:59:44.132  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isGroup         false
2019-01-28 17:59:44.132  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isTimer         false
2019-01-28 17:59:44.132  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isSecurity      false
2019-01-28 17:59:44.133  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isHTTPResponse  false
2019-01-28 17:59:44.133  Status: dzVents: Info:  isDevice check: ------ Finished dumper103.lua
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by Freemann »

OK, used your log script.
First tried with an ON/OFF cycle with device "237"
Then tried with an ON/OFF cycle with device "Badkamer verlichting"
Also waited for the 1 minute timed trigger.

The log shows that

Here the log;
Spoiler: show

Code: Select all

-------------------------------------------------------
- 237/ON, uservariables set
-------------------------------------------------------
2019-01-28 21:12:37.413 (Zwave) Current (Unknown)
2019-01-28 21:12:37.528 OpenZWave: Domoticz has send a Switch command! NodeID: 8 (0x08)
2019-01-28 21:12:37.537 (Zwave) Light/Switch (Badkamer verlichting)
2019-01-28 21:12:37.527 Status: User: Admin initiated a switch command (237/Badkamer verlichting/On)
2019-01-28 21:12:37.806 Status: dzVents: Info: isDevice check: ------ Start internal script: BadkamerTest: Device: "Badkamer verlichting (Zwave)", Index: 237
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: devices = {237}
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isDevice true
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isVariable false
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isScene false
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isGroup false
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isTimer false
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isSecurity false
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isHTTPResponse false
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: #######################################################################
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>''
2019-01-28 21:12:37.829 Status: dzVents: Debug: isDevice check: in test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:12:37.830 Status: dzVents: Debug: isDevice check: this line is after the .set()
2019-01-28 21:12:37.835 Status: dzVents: Info: isDevice check: ------ Finished BadkamerTest
2019-01-28 21:12:37.939 Status: Set UserVariable BadkVerwarmingOffTime = 1548706357
2019-01-28 21:12:37.940 Status: Set UserVariable BadkVerwarmingOnTime = 1548706357
-------------------------------------------------------
- 237/OFF, uservariables set
-------------------------------------------------------
2019-01-28 21:12:39.285 OpenZWave: Domoticz has send a Switch command! NodeID: 8 (0x08)
2019-01-28 21:12:39.289 (Zwave) Light/Switch (Badkamer verlichting)
2019-01-28 21:12:39.285 Status: User: Admin initiated a switch command (237/Badkamer verlichting/Off)
2019-01-28 21:12:39.555 Status: dzVents: Info: isDevice check: ------ Start internal script: BadkamerTest: Device: "Badkamer verlichting (Zwave)", Index: 237
2019-01-28 21:12:39.576 Status: dzVents: Debug: isDevice check: devices = {237}
2019-01-28 21:12:39.576 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isDevice true
2019-01-28 21:12:39.576 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isVariable false
2019-01-28 21:12:39.576 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isScene false
2019-01-28 21:12:39.576 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isGroup false
2019-01-28 21:12:39.576 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isTimer false
2019-01-28 21:12:39.576 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isSecurity false
2019-01-28 21:12:39.577 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isHTTPResponse false
2019-01-28 21:12:39.577 Status: dzVents: Debug: isDevice check: #######################################################################
2019-01-28 21:12:39.577 Status: dzVents: Debug: isDevice check: test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:12:39.577 Status: dzVents: Debug: isDevice check: next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>''
2019-01-28 21:12:39.577 Status: dzVents: Debug: isDevice check: in test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:12:39.577 Status: dzVents: Debug: isDevice check: this line is after the .set()
2019-01-28 21:12:39.582 Status: dzVents: Info: isDevice check: ------ Finished BadkamerTest
2019-01-28 21:12:39.709 Status: Set UserVariable BadkVerwarmingOffTime = 1548706359
2019-01-28 21:12:39.709 Status: Set UserVariable BadkVerwarmingOnTime = 1548706359
2019-01-28 21:12:40.714 OpenZWave: Domoticz has send a Switch command! NodeID: 6 (0x06)
2019-01-28 21:12:40.719 (Zwave) Usage (Badkamer Verwarming(Watt))
-------------------------------------------------------
- "Badkamer verlichting ON", uservariables set
-------------------------------------------------------
2019-01-28 21:12:50.820 OpenZWave: Domoticz has send a Switch command! NodeID: 8 (0x08)
2019-01-28 21:12:50.824 (Zwave) Light/Switch (Badkamer verlichting)
2019-01-28 21:12:50.819 Status: User: Admin initiated a switch command (237/Badkamer verlichting/On)
2019-01-28 21:12:51.141 Status: dzVents: Info: isDevice check: ------ Start internal script: BadkamerTest: Device: "Badkamer verlichting (Zwave)", Index: 237
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: devices = "Badkamer verlichting"
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isDevice true
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isVariable false
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isScene false
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isGroup false
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isTimer false
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isSecurity false
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isHTTPResponse false
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: #######################################################################
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>''
2019-01-28 21:12:51.163 Status: dzVents: Debug: isDevice check: in test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:12:51.164 Status: dzVents: Debug: isDevice check: this line is after the .set()
2019-01-28 21:12:51.169 Status: dzVents: Info: isDevice check: ------ Finished BadkamerTest
2019-01-28 21:12:51.325 Status: Set UserVariable BadkVerwarmingOffTime = 1548706371
2019-01-28 21:12:51.325 Status: Set UserVariable BadkVerwarmingOnTime = 1548706371
2019-01-28 21:12:52.289 OpenZWave: Domoticz has send a Switch command! NodeID: 8 (0x08)
-------------------------------------------------------
- "Badkamer verlichting Off", uservariables not set
-------------------------------------------------------
2019-01-28 21:12:52.293 (Zwave) Light/Switch (Badkamer verlichting)
2019-01-28 21:12:52.289 Status: User: Admin initiated a switch command (237/Badkamer verlichting/Off)
2019-01-28 21:12:52.462 Status: dzVents: Info: isDevice check: ------ Start internal script: BadkamerTest: Device: "Badkamer verlichting (Zwave)", Index: 237
2019-01-28 21:12:52.485 Status: dzVents: Debug: isDevice check: devices = "Badkamer verlichting"
2019-01-28 21:12:52.486 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isDevice true
2019-01-28 21:12:52.486 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isVariable false
2019-01-28 21:12:52.486 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isScene false
2019-01-28 21:12:52.486 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isGroup false
2019-01-28 21:12:52.488 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isTimer false
2019-01-28 21:12:52.489 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isSecurity false
2019-01-28 21:12:52.489 Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isHTTPResponse false
2019-01-28 21:12:52.489 Status: dzVents: Debug: isDevice check: #######################################################################
2019-01-28 21:12:52.489 Status: dzVents: Debug: isDevice check: test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:12:52.489 Status: dzVents: Debug: isDevice check: next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>''
2019-01-28 21:12:52.489 Status: dzVents: Debug: isDevice check: in test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:12:52.492 Status: dzVents: Debug: isDevice check: this line is after the .set()
2019-01-28 21:12:52.503 Status: dzVents: Info: isDevice check: ------ Finished BadkamerTest
2019-01-28 21:12:53.035 (Zwave) Current (Unknown)
-------------------------------------------------------
- Timed trigger, setting uservariables
-------------------------------------------------------
2019-01-28 21:13:00.523 Status: dzVents: Info: isDevice check: ------ Start internal script: BadkamerTest:, trigger: every minute
2019-01-28 21:13:00.544 Status: dzVents: Debug: isDevice check: devices = "Badkamer verlichting"
2019-01-28 21:13:00.544 Status: dzVents: Debug: isDevice check: triggered by every minute; state: N/A; isDevice false
2019-01-28 21:13:00.544 Status: dzVents: Debug: isDevice check: triggered by every minute; state: N/A; isVariable false
2019-01-28 21:13:00.544 Status: dzVents: Debug: isDevice check: triggered by every minute; state: N/A; isScene false
2019-01-28 21:13:00.544 Status: dzVents: Debug: isDevice check: triggered by every minute; state: N/A; isGroup false
2019-01-28 21:13:00.544 Status: dzVents: Debug: isDevice check: triggered by every minute; state: N/A; isTimer true
2019-01-28 21:13:00.545 Status: dzVents: Debug: isDevice check: triggered by every minute; state: N/A; isSecurity false
2019-01-28 21:13:00.545 Status: dzVents: Debug: isDevice check: triggered by every minute; state: N/A; isHTTPResponse false
2019-01-28 21:13:00.545 Status: dzVents: Debug: isDevice check: #######################################################################
2019-01-28 21:13:00.545 Status: dzVents: Debug: isDevice check: test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:13:00.545 Status: dzVents: Debug: isDevice check: next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>''
2019-01-28 21:13:00.545 Status: dzVents: Debug: isDevice check: in test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-28 21:13:00.546 Status: dzVents: Debug: isDevice check: this line is after the .set()
2019-01-28 21:13:00.551 Status: dzVents: Info: isDevice check: ------ Finished BadkamerTest
2019-01-28 21:13:02.149 (Zwave) General/kWh (kWh Meter)
2019-01-28 21:13:02.083 Status: Set UserVariable BadkVerwarmingOffTime = 1548706380
2019-01-28 21:13:02.083 Status: Set UserVariable BadkVerwarmingOnTime = 1548706380
here's the final script I used;
Spoiler: show

Code: Select all

-- isDevice check

return {
    on =        {       timer = {"every minute"},
                     devices  = { 
                         --237,
                         "Badkamer verlichting" 
                    }},  -- 433 is sensor / isDevice Test switch
                 
        logging =   {  
                        level     =   domoticz.LOG_DEBUG,       -- change to LOG_ERROR after you tested  the script
                        marker    =   "isDevice check" 
                    },
                 
    execute = function(dz, item, info )

        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        local trigger   = item.name
        local state     = item.state
        
        if info.trigger then 
            trigger = info.trigger 
            state   = "N/A"    
        end
        --logWrite("devices = {237}")
        logWrite('devices = "Badkamer verlichting"')
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isDevice        " .. tostring(item.isDevice ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isVariable      " .. tostring(item.isVariable ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isScene         " .. tostring(item.isScene))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isGroup         " .. tostring(item.isGroup))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isTimer         " .. tostring(item.isTimer))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isSecurity      " .. tostring(item.isSecurity))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isHTTPResponse  " .. tostring(item.isHTTPResponse))
        logWrite("#######################################################################")
        logWrite("test:: >> if(item.isDevice or item.isTimer)then >>")
        logWrite("next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>'' ")
        if(item.isDevice or item.isTimer)then
            logWrite("in test:: >> if(item.isDevice or item.isTimer)then >>")
                dz.variables("BadkVerwarmingOffTime").set(os.time())
                dz.variables("BadkVerwarmingOnTime").set(os.time())
            logWrite("this line is after the .set()")
        end
    
    end
}
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .isDevice not always avalaible in item

Post by waaren »

Freemann wrote: Monday 28 January 2019 21:21 Then tried with an ON/OFF cycle with device "Badkamer verlichting"
- "Badkamer verlichting Off", uservariables not set
Very strange domoticz dzVents on my system reacts different.
Spoiler: show
Script used:

Code: Select all

-- isDevice check

return {
    on =        {    devices  = { "isDevice Test" }},  -- 433 is sensor / isDevice Test switch
                 
        logging =   {  
                        level     =   domoticz.LOG_DEBUG,       -- change to LOG_ERROR after you tested  the script
                        marker    =   "isDevice check" 
                    },
                 
    execute = function(dz, item, info )
      
        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        local trigger   = item.name
        local state     = item.state
        
        if info.trigger then 
            trigger = info.trigger 
            state   = "N/A"    
        end
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isDevice        " .. tostring(item.isDevice ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isVariable      " .. tostring(item.isVariable ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isScene         " .. tostring(item.isScene))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isGroup         " .. tostring(item.isGroup))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isTimer         " .. tostring(item.isTimer))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isSecurity      " .. tostring(item.isSecurity))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isHTTPResponse  " .. tostring(item.isHTTPResponse))
        if item.isDevice then
            if item.state == "Off" then 
                logWrite("triggered by " .. trigger .. "; state: " .. state )
                logWrite("setting uservar BadkVerwarmingOnTime to " .. os.time())  
                dz.variables("BadkVerwarmingOnTime").set(os.time())
            else
                logWrite("triggered by " .. trigger .. "; state: " .. state )
                logWrite("setting uservar BadkVerwarmingOffTime to " .. os.time())  
                dz.variables("BadkVerwarmingOffTime").set(os.time())
            end
        end
  
    end             
}
relevant log

Code: Select all

2019-01-28 22:44:37.489  Status: dzVents: Info:  Handling events for: "isDevice Test", value: "On"
2019-01-28 22:44:37.489  Status: dzVents: Info:  isDevice check: ------ Start external script: dumper103.lua: Device: "isDevice Test (Virtual2)", Index: 1477
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isDevice        true
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isVariable      false
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isScene         false
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isGroup         false
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isTimer         false
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isSecurity      false
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On; isHTTPResponse  false
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: On
2019-01-28 22:44:37.490  Status: dzVents: Debug: isDevice check: setting uservar BadkVerwarmingOffTime to 1548711877
2019-01-28 22:44:37.492  Status: dzVents: Info:  isDevice check: ------ Finished dumper103.lua
2019-01-28 22:44:37.506  Status: Set UserVariable BadkVerwarmingOffTime = 1548711877


2019-01-28 22:44:48.657  Status: User: Admin initiated a switch command (1477/isDevice Test/Off)
2019-01-28 22:44:48.669  (Virtual2) Light/Switch (isDevice Test)
2019-01-28 22:44:48.918  Status: dzVents: Info:  Handling events for: "isDevice Test", value: "Off"
2019-01-28 22:44:48.919  Status: dzVents: Info:  isDevice check: ------ Start external script: dumper103.lua: Device: "isDevice Test (Virtual2)", Index: 1477
2019-01-28 22:44:48.919  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isDevice        true
2019-01-28 22:44:48.920  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isVariable      false
2019-01-28 22:44:48.923  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isScene         false
2019-01-28 22:44:48.923  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isGroup         false
2019-01-28 22:44:48.923  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isTimer         false
2019-01-28 22:44:48.923  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isSecurity      false
2019-01-28 22:44:48.923  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off; isHTTPResponse  false
2019-01-28 22:44:48.923  Status: dzVents: Debug: isDevice check: triggered by isDevice Test; state: Off
2019-01-28 22:44:48.923  Status: dzVents: Debug: isDevice check: setting uservar BadkVerwarmingOnTime to 1548711888
2019-01-28 22:44:48.925  Status: dzVents: Info:  isDevice check: ------ Finished dumper103.lua
2019-01-28 22:44:48.942  Status: Set UserVariable BadkVerwarmingOnTime = 1548711888
uservars set by isDevice test script
uservars set by isDevice test script
uservars.png (60.18 KiB) Viewed 1299 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Strange...

I now see three difference in my case with your's;
1. I'm using a Z-Wave device, yours is a virtual device, on which I switch from the Domoticz main dashboard view,
2. Not the same device name,
3. The length of the device name, mine is "Badkamer verlichting" (20 chars), your "isDevice Test"(13 chars)

I will try to test with a Virtual device and the same name as you use.
Maybe that will shine some light on it....

[edit]
Want to test with a "Virtual2" device, but how to create such a device?
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by waaren »

Freemann wrote: Tuesday 29 January 2019 9:55 Want to test with a "Virtual2" device, but how to create such a device?
virtual2 is the name of one my Dummy hardware :D
virtual (Dummy) hardware
virtual (Dummy) hardware
virtual.png (88.59 KiB) Viewed 1277 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Ah ok, had to look 3 times.....
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Spoiler: show
log:

Code: Select all

2019-01-30 08:38:04.143  OpenZWave: Domoticz has send a Switch command! NodeID: 8 (0x08)
2019-01-30 08:38:04.162  (Zwave) Light/Switch (Badkamer verlichting)
2019-01-30 08:38:04.186  (Zwave) General/Voltage (Voltage)
2019-01-30 08:38:04.497  Status: dzVents: Info:  isDevice check: ------ Start internal script: BadkamerTest: Device: "Badkamer verlichting (Zwave)", Index: 237
2019-01-30 08:38:04.517  Status: dzVents: Debug: isDevice check: devices = "Badkamer verlichting"
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isDevice        true
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isVariable      false
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isScene         false
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isGroup         false
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isTimer         false
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isSecurity      false
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: On; isHTTPResponse  false
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: #######################################################################
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>''
2019-01-30 08:38:04.518  Status: dzVents: Debug: isDevice check: in test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-30 08:38:04.519  Status: dzVents: Debug: isDevice check: this line is after the .set()
2019-01-30 08:38:04.524  Status: dzVents: Info:  isDevice check: ------ Finished BadkamerTest
2019-01-30 08:38:04.689  (Zwave) General/kWh (kWh Meter)
2019-01-30 08:38:04.740  Status: Notification: 1548833884
2019-01-30 08:38:05.187  (Zwave) Current (Unknown)
2019-01-30 08:38:05.204  Notification sent (gcm) => Success
2019-01-30 08:38:05.605  (Zwave) Usage (Unknown)
2019-01-30 08:38:05.606  (Zwave) General/kWh (kWh Meter)
2019-01-30 08:38:06.349  Notification sent (email) => Success
2019-01-30 08:38:06.604  (Zwave) General/Voltage (Voltage)
2019-01-30 08:38:06.744  Status: Set UserVariable BadkVerwarmingOffTime = 1548833884
2019-01-30 08:38:06.745  Status: Set UserVariable BadkVerwarmingOnTime = 1548833884
2019-01-30 08:38:07.603  (Zwave) Current (Unknown)



2019-01-30 08:38:17.664  Status: User: Admin initiated a switch command (237/Badkamer verlichting/Off)
2019-01-30 08:38:17.665  OpenZWave: Domoticz has send a Switch command! NodeID: 8 (0x08)
2019-01-30 08:38:17.674  (Zwave) Light/Switch (Badkamer verlichting)
2019-01-30 08:38:17.918  Status: dzVents: Info:  isDevice check: ------ Start internal script: BadkamerTest: Device: "Badkamer verlichting (Zwave)", Index: 237
2019-01-30 08:38:17.938  Status: dzVents: Debug: isDevice check: devices = "Badkamer verlichting"
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isDevice        true
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isVariable      false
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isScene         false
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isGroup         false
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isTimer         false
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isSecurity      false
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: triggered by Badkamer verlichting; state: Off; isHTTPResponse  false
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: #######################################################################
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>''
2019-01-30 08:38:17.939  Status: dzVents: Debug: isDevice check: in test:: >> if(item.isDevice or item.isTimer)then >>
2019-01-30 08:38:17.940  Status: dzVents: Debug: isDevice check: this line is after the .set()
2019-01-30 08:38:17.945  Status: dzVents: Info:  isDevice check: ------ Finished BadkamerTest
2019-01-30 08:38:18.108  Status: Notification: 1548833897
2019-01-30 08:38:18.586  Notification sent (gcm) => Success
2019-01-30 08:38:18.686  (Zwave) General/kWh (kWh Meter)
2019-01-30 08:38:19.113  OpenZWave: Domoticz has send a Switch command! NodeID: 6 (0x06)
2019-01-30 08:38:19.116  (Zwave) Usage (Badkamer Verwarming(Watt))
2019-01-30 08:38:19.137  (Zwave) General/kWh (Badkamer Verwarming(kWh))
2019-01-30 08:38:19.142  (Zwave) Light/Switch (Badkamer Verwarming)
2019-01-30 08:38:19.554  Notification sent (email) => Success
2019-01-30 08:38:19.605  (Zwave) Usage (Unknown)

script code:

Code: Select all

-- isDevice check

return {
    on =        {      
        --timer = {"every minute"},
                     devices  = { 
                         --237,
                         "Badkamer verlichting" 
                    }},  -- 433 is sensor / isDevice Test switch
                 
        logging =   {  
                        level     =   domoticz.LOG_DEBUG,       -- change to LOG_ERROR after you tested  the script
                        marker    =   "isDevice check" 
                    },
                 
    execute = function(dz, item, info )

        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        local trigger   = item.name
        local state     = item.state
        
        if info.trigger then 
            trigger = info.trigger 
            state   = "N/A"    
        end
        --logWrite("devices = {237}")
        logWrite('devices = "Badkamer verlichting"')
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isDevice        " .. tostring(item.isDevice ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isVariable      " .. tostring(item.isVariable ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isScene         " .. tostring(item.isScene))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isGroup         " .. tostring(item.isGroup))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isTimer         " .. tostring(item.isTimer))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isSecurity      " .. tostring(item.isSecurity))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isHTTPResponse  " .. tostring(item.isHTTPResponse))
        logWrite("#######################################################################")
        logWrite("test:: >> if(item.isDevice or item.isTimer)then >>")
        logWrite("next line shoud be ''in test:: >> if(item.isDevice or item.isTimer)then >>'' ")
        if(item.isDevice or item.isTimer)then
            logWrite("in test:: >> if(item.isDevice or item.isTimer)then >>")
                dz.variables("BadkVerwarmingOffTime").set(os.time()).afterSec(2)
                dz.variables("BadkVerwarmingOnTime").set(os.time()).afterSec(2)
                dz.notify(os.time())
            logWrite("this line is after the .set()")
        end
    
    end
}
So when using the Zwave device to switch its not setting the UserVariables after a Off Command, but it's send a Notification....
When using a dummy on both Off/On its setting the UserVariables and send a notification...

I'm lost here.....
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by waaren »

Freemann wrote: Wednesday 30 January 2019 8:58 So when using the Zwave device to switch its not setting the UserVariables after a Off Command, but it's send a Notification....
When using a dummy on both Off/On its setting the UserVariables and send a notification...

I'm lost here.....
What does the UserVariables tab show after a reload page ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest