Time compare how does it work?

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

Moderator: leecollings

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

Time compare how does it work?

Post by Freemann »

I'm trying to get the Time compare example working;

Code: Select all

1: domoticz.time.compare(myDevice.lastUpdate).seconds))
(The above line is from the DzVents docs and not failed)

Also tried;

Code: Select all

2: domoticz.log(domoticz.time.compare(domoticz.devices('Voordeur Sensor').lastUpdate).seconds)
3: domoticz.log(domoticz.time.compare(domoticz.devices('Voordeur Sensor').lastUpdate.secondsAgo).seconds)
Line 2: is resulting in the following error:

Code: Select all

2017-11-20 20:48:00.436 Error: dzVents: Error: LastMotion::: An error occured when calling event handler ScriptsDV-LastMotion
2017-11-20 20:48:00.436 Error: dzVents: Error: LastMotion::: ...domoticz/scripts/dzVents/../../dzVents/runtime/Utils.lua:74: attempt to concatenate local 'msg' (a nil value)
Any help is appreciated!

Edit;
Here's an device.dump();

Code: Select all

2017-11-20 22:43:00.269 dzVents: > kodiSetVolume()
2017-11-20 22:43:00.269 dzVents: > deviceType: Light/Switch
2017-11-20 22:43:00.269 dzVents: > setState()
2017-11-20 22:43:00.269 dzVents: > kodiStop()
2017-11-20 22:43:00.269 dzVents: > kodiSwitchOff()
2017-11-20 22:43:00.269 dzVents: > updateWaterflow()
2017-11-20 22:43:00.269 dzVents: > updateVoltage()
2017-11-20 22:43:00.269 dzVents: > updateVisibility()
2017-11-20 22:43:00.269 dzVents: > _state: Off
2017-11-20 22:43:00.269 dzVents: > updateUV()
2017-11-20 22:43:00.269 dzVents: > updateText()
2017-11-20 22:43:00.269 dzVents: > updateBarometer()
2017-11-20 22:43:00.269 dzVents: > lastUpdate:
2017-11-20 22:43:00.269 dzVents: > ruleIsOnDay()
2017-11-20 22:43:00.269 dzVents: > msAgo: 19801158
2017-11-20 22:43:00.269 dzVents: > isUTC: false
2017-11-20 22:43:00.269 dzVents: > secondsSinceMidnight: 61979
2017-11-20 22:43:00.269 dzVents: > hoursAgo: 5
2017-11-20 22:43:00.269 dzVents: > yday: 324
2017-11-20 22:43:00.269 dzVents: > wday: 2
2017-11-20 22:43:00.269 dzVents: > rawDate: 2017-11-20
2017-11-20 22:43:00.269 dzVents: > milliSeconds: 0
2017-11-20 22:43:00.269 dzVents: > isdst: false
2017-11-20 22:43:00.269 dzVents: > compare()
2017-11-20 22:43:00.269 dzVents: > ruleMatchesTime()
2017-11-20 22:43:00.270 dzVents: > month: 11
2017-11-20 22:43:00.270 dzVents: > ruleIsAtNight()
2017-11-20 22:43:00.270 dzVents: > utils:
2017-11-20 22:43:00.270 dzVents: > LOG_INFO: 3
2017-11-20 22:43:00.270 dzVents: > urlEncode()
2017-11-20 22:43:00.270 dzVents: > LOG_ERROR: 1
2017-11-20 22:43:00.270 dzVents: > LOG_FORCE: 0.5
2017-11-20 22:43:00.270 dzVents: > osExecute()
2017-11-20 22:43:00.270 dzVents: > LOG_DEBUG: 4
2017-11-20 22:43:00.270 dzVents: > log()
2017-11-20 22:43:00.270 dzVents: > print()
2017-11-20 22:43:00.270 dzVents: > LOG_MODULE_EXEC_INFO: 2
2017-11-20 22:43:00.270 dzVents: > fileExists()
2017-11-20 22:43:00.270 dzVents: > secondsAgo: 19801
2017-11-20 22:43:00.270 dzVents: > ruleMatchesMinuteSpecification()
2017-11-20 22:43:00.270 dzVents: > ruleIsAfterSunset()
2017-11-20 22:43:00.270 dzVents: > ruleMatchesBetweenRange()
2017-11-20 22:43:00.270 dzVents: > dDate: 1511194379
2017-11-20 22:43:00.270 dzVents: > sec: 59
2017-11-20 22:43:00.270 dzVents: > current:
2017-11-20 22:43:00.270 dzVents: > min: 43
2017-11-20 22:43:00.270 dzVents: > day: 20
2017-11-20 22:43:00.270 dzVents: > hour: 22
2017-11-20 22:43:00.270 dzVents: > month: 11
2017-11-20 22:43:00.270 dzVents: > sec: 0
2017-11-20 22:43:00.270 dzVents: > year: 2017
2017-11-20 22:43:00.270 dzVents: > isdst: false
2017-11-20 22:43:00.270 dzVents: > wday: 2
2017-11-20 22:43:00.270 dzVents: > yday: 324
2017-11-20 22:43:00.270 dzVents: > year: 2017
2017-11-20 22:43:00.270 dzVents: > ruleMatchesTimeRange()
2017-11-20 22:43:00.270 dzVents: > ruleMatchesHourSpecification()
2017-11-20 22:43:00.270 dzVents: > ruleIsAfterSunrise()
2017-11-20 22:43:00.270 dzVents: > matchesRule()
2017-11-20 22:43:00.271 dzVents: > raw: 2017-11-20 17:12:59
2017-11-20 22:43:00.271 dzVents: > day: 20
2017-11-20 22:43:00.271 dzVents: > daysAgo: 0
2017-11-20 22:43:00.271 dzVents: > ruleIsAtDayTime()
2017-11-20 22:43:00.271 dzVents: > hour: 17
2017-11-20 22:43:00.271 dzVents: > ruleIsBeforeSunset()
2017-11-20 22:43:00.271 dzVents: > ruleIsAtSunrise()
2017-11-20 22:43:00.271 dzVents: > getISO()
2017-11-20 22:43:00.271 dzVents: > isToday: true
2017-11-20 22:43:00.271 dzVents: > ruleIsAtSunset()
2017-11-20 22:43:00.271 dzVents: > ruleIsBeforeSunrise()
2017-11-20 22:43:00.271 dzVents: > minutesAgo: 330
2017-11-20 22:43:00.271 dzVents: > dayAbbrOfWeek: mon
2017-11-20 22:43:00.271 dzVents: > min: 12
2017-11-20 22:43:00.271 dzVents: > rawTime: 17:12:59
2017-11-20 22:43:00.271 dzVents: > updateSoundLevel()
2017-11-20 22:43:00.271 dzVents: > updateTempHumBaro()
2017-11-20 22:43:00.271 dzVents: > baseType: device
2017-11-20 22:43:00.271 dzVents: > id: 782
2017-11-20 22:43:00.271 dzVents: > _nValue: 0
2017-11-20 22:43:00.271 dzVents: > updateCustomSensor()
2017-11-20 22:43:00.271 dzVents: > updateSetPoint()
2017-11-20 22:43:00.271 dzVents: > updateRadiation()
2017-11-20 22:43:00.271 dzVents: > updateCounter()
2017-11-20 22:43:00.271 dzVents: > changed: false
2017-11-20 22:43:00.271 dzVents: > name: Voordeur Sensor
2017-11-20 22:43:00.271 dzVents: > updatePressure()
2017-11-20 22:43:00.271 dzVents: > unit: 1
2017-11-20 22:43:00.271 dzVents: > deviceId: 00006600
2017-11-20 22:43:00.271 dzVents: > updateLux()
2017-11-20 22:43:00.271 dzVents: > lastLevel: 0
2017-11-20 22:43:00.271 dzVents: > icon: lightbulb
2017-11-20 22:43:00.271 dzVents: > dimTo()
2017-11-20 22:43:00.271 dzVents: > updateRain()
2017-11-20 22:43:00.271 dzVents: > updateAirQuality()
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
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Time compare how does it work?

Post by dannybloe »

I just replied to another post that I made a mistake in the docs about compare. It is not .seconds/.minutes/.milliseconds but .secs/.mins/.ms. Sorry about that.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: Time compare how does it work?

Post by Freemann »

Working like a charm!!

Thanks! :mrgreen:
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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest