lastUpdate nil value  [SOLVED]

Moderator: leecollings

Post Reply
jannnfe
Posts: 30
Joined: Tuesday 30 January 2018 0:27
Target OS: Linux
Domoticz version: Beta
Location: Germany
Contact:

lastUpdate nil value

Post by jannnfe »

Hello,
I just wanted to test the following code snippets from the dzVents Wiki https://www.domoticz.com/wiki/DzVents:_ ... _iterators in my system, but it does not work for me:

Code: Select all

   local deadDevices = domoticz.devices().filter(function(device)
      return (device.lastUpdate.minutesAgo > 60)
   end)
   deadDevices.forEach(function(zombie)
      -- do something
   end)
The log outputs:

Code: Select all

2018-10-07 21:59:00.119 Status: dzVents: Error (2.4.7): ManageBattery: ...ticz/scripts/dzVents/generated_scripts/ManageBattery.lua:22: attempt to index field 'lastUpdate' (a nil value)
Is this a bug? Is this a bug only in my system?
Thanks!
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: lastUpdate nil value

Post by waaren »

jannnfe wrote: Sunday 07 October 2018 22:03 I just wanted to test the following code snippets from the dzVents Wiki https://www.domoticz.com/wiki/DzVents:_ ... _iterators in my system, but it does not work for me:
....
Is this a bug? Is this a bug only in my system?
Seems to be something is not right here. If I execute this

Code: Select all

return { 
        on           = { timer        = {   "every minute"}},
              
        logging      =   {   level   =   domoticz.LOG_INFO,
                             marker  =   "testiteration" }, 
                        
    execute = function(domoticz)
        local myDevice
        local deadDevices = domoticz.devices().filter(function(myDevice)
            if myDevice.lastUpdate ~= nil then
                return (myDevice.lastUpdate.hoursAgo > 1 )   
            else
                 domoticz.log("Device ".. myDevice.name .. " (idx: " .. myDevice.idx ..   ") has no lastUpdate set !?!?",domoticz.LOG_ERROR)   
            end    
       end)
       deadDevices.forEach(function(zombie)
          domoticz.log("Device ".. zombie.name .. " is not updated during the last 60 minutes",domoticz.LOG_INFO)
       end)
    end
}
the log shows...

Code: Select all

2018-10-07 23:27:00.764  Status: dzVents: Info:  testiteration: ------ Start external script: testIteration.lua:, trigger: every minute
2018-10-07 23:27:00.767  Status: dzVents: Error (2.4.7): testiteration: Device  (idx: 0) has no lastUpdate set !?!?
2018-10-07 23:27:00.768  Status: dzVents: Error (2.4.7): testiteration: Device  (idx: 0) has no lastUpdate set !?!?
2018-10-07 23:27:00.768  Status: dzVents: Error (2.4.7): testiteration: Device  (idx: 0) has no lastUpdate set !?!?
2018-10-07 23:27:00.768  Status: dzVents: Error (2.4.7): testiteration: Device  (idx: 0) has no lastUpdate set !?!?
2018-10-07 23:27:00.768  Status: dzVents: Error (2.4.7): testiteration: Device  (idx: 0) has no lastUpdate set !?!?
2018-10-07 23:27:01.053  Status: dzVents: Info:  testiteration: Device km1 is not updated during the last 60 minutes
2018-10-07 23:27:01.053  Status: dzVents: Info:  testiteration: Device XMotion-1 is not updated during the last 60 minutes
2018-10-07 23:27:01.055  Status: dzVents: Info:  testiteration: Device XMotion-6 is not updated during the last 60 minutes
2018-10-07 23:27:01.056  Status: dzVents: Info:  testiteration: Device km3 is not updated during the last 60 minutes
2018-10-07 23:27:01.057  Status: dzVents: Info:  testiteration: Device Xiaomi Gateway Alarm Ringtone is not updated during the last 60 minutes
2018-10-07 23:27:01.057  Status: dzVents: Info:  testiteration: Device My_External_IP is not updated during the last 60 minutes
..........
2018-10-07 23:27:01.064  Status: dzVents: Info:  testiteration: ------ Finished testIteration.lua
So dzVents return some ghost devices. I checked the database but no ghost devices in deviceStatus table. I checked with a myDevice.dump() statement but that does only return empty fields.
Hope @dannybloe can answer / fix this one
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: lastUpdate nil value

Post by dannybloe »

Mm... interesting.. Perhaps you can do an attribute dump (device.dump()) for these devices and see what they are.

Reading from the code, devices that do not get lastUpdate information from Domoticz should be discarded (with a debug-level log message in the log).
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: lastUpdate nil value

Post by waaren »

dannybloe wrote: Monday 08 October 2018 6:50 Mm... interesting.. Perhaps you can do an attribute dump (device.dump()) for these devices and see what they are.

Reading from the code, devices that do not get lastUpdate information from Domoticz should be discarded (with a debug-level log message in the log).
@dannybloe, did do the attribute dump but everything empty
Spoiler: show

Code: Select all

[code]2018-10-08 07:27:00.692  Status: dzVents: > kodiSetVolume()
2018-10-08 07:27:00.692  Status: dzVents: > increaseBrightness()
2018-10-08 07:27:00.692  Status: dzVents: > open()
2018-10-08 07:27:00.692  Status: dzVents: > updateTempBaro()
2018-10-08 07:27:00.692  Status: dzVents: > kodiPause()
2018-10-08 07:27:00.692  Status: dzVents: > updateUV()
2018-10-08 07:27:00.692  Status: dzVents: > updateHumidity()
2018-10-08 07:27:00.692  Status: dzVents: > switchSelector()
2018-10-08 07:27:00.692  Status: dzVents: > updateMode()
2018-10-08 07:27:00.692  Status: dzVents: > kodiSwitchOff()
2018-10-08 07:27:00.692  Status: dzVents: > updateTempHum()
2018-10-08 07:27:00.692  Status: dzVents: > play()
2018-10-08 07:27:00.692  Status: dzVents: > decreaseBrightness()
2018-10-08 07:27:00.692  Status: dzVents: > updateSetPoint()
2018-10-08 07:27:00.692  Status: dzVents: > name:
2018-10-08 07:27:00.692  Status: dzVents: > updateDistance()
2018-10-08 07:27:00.692  Status: dzVents: > armHome()
2018-10-08 07:27:00.692  Status: dzVents: > setNightMode()
2018-10-08 07:27:00.693  Status: dzVents: > updatePercentage()
2018-10-08 07:27:00.693  Status: dzVents: > setVolume()
2018-10-08 07:27:00.693  Status: dzVents: > setRGB()
2018-10-08 07:27:00.693  Status: dzVents: > kodiStop()
2018-10-08 07:27:00.693  Status: dzVents: > updateElectricity()
2018-10-08 07:27:00.693  Status: dzVents: > setDiscoMode()
2018-10-08 07:27:00.693  Status: dzVents: > setKelvin()
2018-10-08 07:27:00.693  Status: dzVents: > _adapters:
2018-10-08 07:27:00.693  Status: dzVents: > updateWind()
2018-10-08 07:27:00.693  Status: dzVents: > updateSoilMoisture()
2018-10-08 07:27:00.693  Status: dzVents: > updateVoltage()
2018-10-08 07:27:00.693  Status: dzVents: > updateGas()
2018-10-08 07:27:00.693  Status: dzVents: > armAway()
2018-10-08 07:27:00.693  Status: dzVents: > updateBarometer()
2018-10-08 07:27:00.693  Status: dzVents: > updateRain()
2018-10-08 07:27:00.693  Status: dzVents: > updateWeight()
2018-10-08 07:27:00.693  Status: dzVents: > onkyoEISCPCommand()
2018-10-08 07:27:00.693  Status: dzVents: > startPlaylist()
2018-10-08 07:27:00.693  Status: dzVents: > updateSoundLevel()
2018-10-08 07:27:00.693  Status: dzVents: > updateAirQuality()
2018-10-08 07:27:00.693  Status: dzVents: > updateLux()
2018-10-08 07:27:00.694  Status: dzVents: > update()
2018-10-08 07:27:00.694  Status: dzVents: > disarm()
2018-10-08 07:27:00.694  Status: dzVents: > setWhiteMode()
2018-10-08 07:27:00.694  Status: dzVents: > _data:
2018-10-08 07:27:00.694  Status: dzVents: >     switchType: On/Off
2018-10-08 07:27:00.694  Status: dzVents: >     name:
2018-10-08 07:27:00.694  Status: dzVents: >     lastUpdate:
2018-10-08 07:27:00.694  Status: dzVents: >     switchTypeValue: 0
2018-10-08 07:27:00.694  Status: dzVents: >     signalLevel: 0
2018-10-08 07:27:00.694  Status: dzVents: >     lastLevel: 0
2018-10-08 07:27:00.694  Status: dzVents: >     id: 0
2018-10-08 07:27:00.694  Status: dzVents: >     timedOut: true
2018-10-08 07:27:00.694  Status: dzVents: >     subType: Unknown
2018-10-08 07:27:00.694  Status: dzVents: >     data:
2018-10-08 07:27:00.694  Status: dzVents: >         hardwareID: 0
2018-10-08 07:27:00.694  Status: dzVents: >         _state:
2018-10-08 07:27:00.694  Status: dzVents: >         _nValue: 0
2018-10-08 07:27:00.694  Status: dzVents: >     changed: false
2018-10-08 07:27:00.694  Status: dzVents: >     batteryLevel: 0
2018-10-08 07:27:00.694  Status: dzVents: >     rawData:
2018-10-08 07:27:00.695  Status: dzVents: >     description:
2018-10-08 07:27:00.695  Status: dzVents: >     deviceID:
2018-10-08 07:27:00.695  Status: dzVents: >     baseType: device
2018-10-08 07:27:00.695  Status: dzVents: >     deviceType: Interface Control
2018-10-08 07:27:00.695  Status: dzVents: > updateYouless()
2018-10-08 07:27:00.695  Status: dzVents: > kodiPlayPlaylist()
2018-10-08 07:27:00.695  Status: dzVents: > updateTemperature()
2018-10-08 07:27:00.695  Status: dzVents: > switchOff()
2018-10-08 07:27:00.695  Status: dzVents: > pause()
2018-10-08 07:27:00.695  Status: dzVents: > updateWetness()
2018-10-08 07:27:00.695  Status: dzVents: > kodiPlay()
2018-10-08 07:27:00.695  Status: dzVents: > updateAlertSensor()
2018-10-08 07:27:00.695  Status: dzVents: > updateVisibility()
2018-10-08 07:27:00.695  Status: dzVents: > switchOn()
2018-10-08 07:27:00.695  Status: dzVents: > kodiExecuteAddOn()
2018-10-08 07:27:00.695  Status: dzVents: > playFavorites()
2018-10-08 07:27:00.695  Status: dzVents: > kodiPlayFavorites()
2018-10-08 07:27:00.695  Status: dzVents: > updateCounter()
2018-10-08 07:27:00.695  Status: dzVents: > id: 0
2018-10-08 07:27:00.695  Status: dzVents: > idx: 0
2018-10-08 07:27:00.695  Status: dzVents: > updateWaterflow()
2018-10-08 07:27:00.696  Status: dzVents: > close()
2018-10-08 07:27:00.696  Status: dzVents: > toggleSwitch()
2018-10-08 07:27:00.696  Status: dzVents: > updateText()
2018-10-08 07:27:00.696  Status: dzVents: > updatePressure()
2018-10-08 07:27:00.696  Status: dzVents: > stop()
2018-10-08 07:27:00.696  Status: dzVents: > baseType: device
2018-10-08 07:27:00.696  Status: dzVents: > updateRadiation()
2018-10-08 07:27:00.696  Status: dzVents: > updateCustomSensor()
2018-10-08 07:27:00.696  Status: dzVents: > dimTo()
2018-10-08 07:27:00.696  Status: dzVents: > updateTempHumBaro()
2018-10-08 07:27:00.696  Status: dzVents: > updateP1()
2018-10-08 07:27:00.696  Status: dzVents: > dump()
[code]2018-10-08 07:27:00.692  Status: dzVents: > kodiSetVolume()
2018-10-08 07:27:00.692  Status: dzVents: > increaseBrightness()
2018-10-08 07:27:00.692  Status: dzVents: > open()
2018-10-08 07:27:00.692  Status: dzVents: > updateTempBaro()
2018-10-08 07:27:00.692  Status: dzVents: > kodiPause()
2018-10-08 07:27:00.692  Status: dzVents: > updateUV()
2018-10-08 07:27:00.692  Status: dzVents: > updateHumidity()
2018-10-08 07:27:00.692  Status: dzVents: > switchSelector()
2018-10-08 07:27:00.692  Status: dzVents: > updateMode()
2018-10-08 07:27:00.692  Status: dzVents: > kodiSwitchOff()
2018-10-08 07:27:00.692  Status: dzVents: > updateTempHum()
2018-10-08 07:27:00.692  Status: dzVents: > play()
2018-10-08 07:27:00.692  Status: dzVents: > decreaseBrightness()
2018-10-08 07:27:00.692  Status: dzVents: > updateSetPoint()
2018-10-08 07:27:00.692  Status: dzVents: > name:
2018-10-08 07:27:00.692  Status: dzVents: > updateDistance()
2018-10-08 07:27:00.692  Status: dzVents: > armHome()
2018-10-08 07:27:00.692  Status: dzVents: > setNightMode()
2018-10-08 07:27:00.693  Status: dzVents: > updatePercentage()
2018-10-08 07:27:00.693  Status: dzVents: > setVolume()
2018-10-08 07:27:00.693  Status: dzVents: > setRGB()
2018-10-08 07:27:00.693  Status: dzVents: > kodiStop()
2018-10-08 07:27:00.693  Status: dzVents: > updateElectricity()
2018-10-08 07:27:00.693  Status: dzVents: > setDiscoMode()
2018-10-08 07:27:00.693  Status: dzVents: > setKelvin()
2018-10-08 07:27:00.693  Status: dzVents: > _adapters:
2018-10-08 07:27:00.693  Status: dzVents: > updateWind()
2018-10-08 07:27:00.693  Status: dzVents: > updateSoilMoisture()
2018-10-08 07:27:00.693  Status: dzVents: > updateVoltage()
2018-10-08 07:27:00.693  Status: dzVents: > updateGas()
2018-10-08 07:27:00.693  Status: dzVents: > armAway()
2018-10-08 07:27:00.693  Status: dzVents: > updateBarometer()
2018-10-08 07:27:00.693  Status: dzVents: > updateRain()
2018-10-08 07:27:00.693  Status: dzVents: > updateWeight()
2018-10-08 07:27:00.693  Status: dzVents: > onkyoEISCPCommand()
2018-10-08 07:27:00.693  Status: dzVents: > startPlaylist()
2018-10-08 07:27:00.693  Status: dzVents: > updateSoundLevel()
2018-10-08 07:27:00.693  Status: dzVents: > updateAirQuality()
2018-10-08 07:27:00.693  Status: dzVents: > updateLux()
2018-10-08 07:27:00.694  Status: dzVents: > update()
2018-10-08 07:27:00.694  Status: dzVents: > disarm()
2018-10-08 07:27:00.694  Status: dzVents: > setWhiteMode()
2018-10-08 07:27:00.694  Status: dzVents: > _data:
2018-10-08 07:27:00.694  Status: dzVents: >     switchType: On/Off
2018-10-08 07:27:00.694  Status: dzVents: >     name:
2018-10-08 07:27:00.694  Status: dzVents: >     lastUpdate:
2018-10-08 07:27:00.694  Status: dzVents: >     switchTypeValue: 0
2018-10-08 07:27:00.694  Status: dzVents: >     signalLevel: 0
2018-10-08 07:27:00.694  Status: dzVents: >     lastLevel: 0
2018-10-08 07:27:00.694  Status: dzVents: >     id: 0
2018-10-08 07:27:00.694  Status: dzVents: >     timedOut: true
2018-10-08 07:27:00.694  Status: dzVents: >     subType: Unknown
2018-10-08 07:27:00.694  Status: dzVents: >     data:
2018-10-08 07:27:00.694  Status: dzVents: >         hardwareID: 0
2018-10-08 07:27:00.694  Status: dzVents: >         _state:
2018-10-08 07:27:00.694  Status: dzVents: >         _nValue: 0
2018-10-08 07:27:00.694  Status: dzVents: >     changed: false
2018-10-08 07:27:00.694  Status: dzVents: >     batteryLevel: 0
2018-10-08 07:27:00.694  Status: dzVents: >     rawData:
2018-10-08 07:27:00.695  Status: dzVents: >     description:
2018-10-08 07:27:00.695  Status: dzVents: >     deviceID:
2018-10-08 07:27:00.695  Status: dzVents: >     baseType: device
2018-10-08 07:27:00.695  Status: dzVents: >     deviceType: Interface Control
2018-10-08 07:27:00.695  Status: dzVents: > updateYouless()
2018-10-08 07:27:00.695  Status: dzVents: > kodiPlayPlaylist()
2018-10-08 07:27:00.695  Status: dzVents: > updateTemperature()
2018-10-08 07:27:00.695  Status: dzVents: > switchOff()
2018-10-08 07:27:00.695  Status: dzVents: > pause()
2018-10-08 07:27:00.695  Status: dzVents: > updateWetness()
2018-10-08 07:27:00.695  Status: dzVents: > kodiPlay()
2018-10-08 07:27:00.695  Status: dzVents: > updateAlertSensor()
2018-10-08 07:27:00.695  Status: dzVents: > updateVisibility()
2018-10-08 07:27:00.695  Status: dzVents: > switchOn()
2018-10-08 07:27:00.695  Status: dzVents: > kodiExecuteAddOn()
2018-10-08 07:27:00.695  Status: dzVents: > playFavorites()
2018-10-08 07:27:00.695  Status: dzVents: > kodiPlayFavorites()
2018-10-08 07:27:00.695  Status: dzVents: > updateCounter()
2018-10-08 07:27:00.695  Status: dzVents: > id: 0
2018-10-08 07:27:00.695  Status: dzVents: > idx: 0
2018-10-08 07:27:00.695  Status: dzVents: > updateWaterflow()
2018-10-08 07:27:00.696  Status: dzVents: > close()
2018-10-08 07:27:00.696  Status: dzVents: > toggleSwitch()
2018-10-08 07:27:00.696  Status: dzVents: > updateText()
2018-10-08 07:27:00.696  Status: dzVents: > updatePressure()
2018-10-08 07:27:00.696  Status: dzVents: > stop()
2018-10-08 07:27:00.696  Status: dzVents: > baseType: device
2018-10-08 07:27:00.696  Status: dzVents: > updateRadiation()
2018-10-08 07:27:00.696  Status: dzVents: > updateCustomSensor()
2018-10-08 07:27:00.696  Status: dzVents: > dimTo()
2018-10-08 07:27:00.696  Status: dzVents: > updateTempHumBaro()
2018-10-08 07:27:00.696  Status: dzVents: > updateP1()
2018-10-08 07:27:00.696  Status: dzVents: > dump()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: lastUpdate nil value

Post by dannybloe »

Yes, as you can see data.lastUpdate is indeed nil. Somehow though the device ends up in the collection anyway. I will have to look into that. In the mean time, just check the lastUpdate attribute.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
jannnfe
Posts: 30
Joined: Tuesday 30 January 2018 0:27
Target OS: Linux
Domoticz version: Beta
Location: Germany
Contact:

Re: lastUpdate nil value

Post by jannnfe »

@dannybloe sorry but what do you mean with just Check the lastUpdate attribute?
What Code i Can use in the meantime to archive the same result?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: lastUpdate nil value  [SOLVED]

Post by waaren »

jannnfe wrote: Wednesday 10 October 2018 11:07 @dannybloe sorry but what do you mean with just Check the lastUpdate attribute?
What Code i Can use in the meantime to archive the same result?
You can use my example
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: No registered users and 0 guests