Retrieving a device property?

Moderator: leecollings

Post Reply
jpmd
Posts: 13
Joined: Tuesday 25 April 2023 19:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Retrieving a device property?

Post by jpmd »

I like to retrieve a specific device property. Can somebody tell me how to do that?

You get all device properties if you use the following statements in dzevents:

Code: Select all

allProperties = dz. devices(<your device name>)
dz log (allProperties , dz. LOG_INFO)
Result in the logfile is:

{["updateBarometer"]=function, ["disarm"]=function, ["setDiscoMode"]=function, ["inActive"]=true, ["fullDump"]=function, ["setColorBrightness"]=function, ["updateHistory"]=function, ["updateCounter"]=function, ["maxDimLevel"]=100, ["bState"]=false, ["sValue"]="Closed", ["nValue"]=0, ["updateVisibility"]=function, ["usedByCamera"]=false, ["active"]=false, ["increaseBrightness"]=function, ["hardwareId"]=10, ["hardwareType"]="Zigbee2MQTT", ["protectionOff"]=function, ["kodiPlayPlaylist"]=function, ["updateWind"]=function, ["baseType"]="device", ["play"]=function, ["setIcon"]=function, ["updateWaterflow"]=function, ["_state"]="Closed", ["dump"]=function, ["updateTemperature"]=function, ["updateDistance"]=function, ["lastUpdate"]={["rawTime"]="09:36:21", ["addMinutes"]=function, ["ruleIsOnDate"]=function, ["isToday"]=true, ["min"]=36, ["hour"]=9, ["ruleMatchesBetweenRange"]=function, ["compare"]=function, ["getISO"]=function, ["addSeconds"]=function, ["ruleMatchesTimeRange"]=function, ["minutesAgo"]=116, ["sec"]=21, ["dateToTimestamp"]=function, ["addDays"]=function, ["ruleMatchesHourSpecification"]=function, ["month"]=8, ["milliseconds"]=0, ["ruleMatchesMinuteSpecification"]=function, ["dayName"]="Sunday", ["ruleIsAtAstronomicalMoment"]=function, ["timestampToDate"]=function, ["utils"]={["centerPad"]=function, ["LOG_MODULE_EXEC_INFO"]=2, ["LOG_FORCE"]=5, ["splitLine"]=function, ["dumpSelection"]=function, ["hasLines"]=function, ["LOG_ERROR"]=1, ["toBase64"]=function, ["toXML"]=function, ["fromJSON"]=function, ["urlEncode"]=function, ["fromBase64"]=function, ["LOG_DEBUG"]=4, ["humidityStatus"]=function, ["hsbToRGB"]=function, ["dumpTable"]=function, ["osCommand"]=function, ["cameraExists"]=function, ["isXML"]=function, ["numDecimals"]=function, ["toStr"]=function, ["LOG_WARNING"]=3, ["LOG_INFO"]=3, ["variableExists"]=function, ["hardwareExists"]=function, ["groupExists"]=function, ["sceneExists"]=function, ["deviceExists"]=function, ["leadingZeros"]=function, ["osExecute"]=function, ["round"]=function, ["leftPad"]=function, ["log"]=function, ["stringToSeconds"]=function, ["containsWord"]=function, ["toJSON"]=function, ["setLogMarker"]=function, ["fileExists"]=function, ["fromLines"]=function, ["cloneTable"]=function, ["inTable"]=function, ["fuzzyLookup"]=function, ["print"]=function, ["toCelsius"]=function, ["isJSON"]=function, ["urlDecode"]=function, ["rgbToHSB"]=function, ["stringSplit"]=function, ["rightPad"]=function, ["fromXML"]=function, ["DZVERSION"]="3 1 8"}, ["rawDateTime"]="2023-08-06 09:36:21", ["daysAgo"]=0, ["day"]=6, ["dateToDate"]=function, ["raw"]="2023-08-06 09:36:21", ["ruleIsInWeek"]=function, ["ruleIsBeforeAstrologicalMoment"]=function, ["minutes"]=36, ["rawDate"]="2023-08-06", ["monthName"]="August", ["ruleIsAfterAstrologicalMoment"]=function, ["ruleMatchesTime"]=function, ["minutesnow"]=576, ["makeTime"]=function, ["minutesSinceMidnight"]=576, ["monthAbbrName"]="aug", ["addHours"]=function, ["containsWholeWord"]=function, ["ruleIsOnDay"]=function, ["ruleIsAtAstronomicalRange"]=function, ["dDate"]=1691307381, ["localeMonths"]=function, ["week"]=31, ["current"]={["month"]=8, ["isdst"]=true, ["hour"]=11, ["min"]=32, ["day"]=6, ["year"]=2023, ["sec"]=37, ["wday"]=1, ["yday"]=218}, ["msAgo"]=6976209, ["seconds"]=21, ["secondsAgo"]=6976, ["isUTC"]=false, ["time"]="09:36", ["isdst"]=true, ["secondsSinceMidnight"]=34581, ["dayAbbrOfWeek"]="sun", ["matchesRule"]=function, ["milliSeconds"]=0, ["hoursAgo"]=1, ["millisecondsAgo"]=6976209, ["year"]=2023, ["wday"]=1, ["toUTC"]=function, ["yday"]=218}, ["changed"]=false, ["Image"]="Alarm", ["switchOff"]=function, ["kodiExecuteAddOn"]=function, ["rename"]=function, ["customImage"]=13, ["level"]=0, ["unit"]=1, ["updateWetness"]=function, ["setHex"]=function, ["kodiSetVolume"]=function, ["updateHumidity"]=function, ["setLevel"]=function, ["setWhiteMode"]=function, ["idx"]=6286, ["kodiStop"]=function, ["updateAirQuality"]=function, ["description"]="", ["updateTempBaro"]=function, ["setKelvin"]=function, ["updateText"]=function, ["armHome"]=function, ["_nValue"]=0, ["updateTempHumBaro"]=function, ["setDescription"]=function, ["updatePercentage"]=function, ["switchTypeValue"]=2, ["volumeDown"]=function, ["update"]=function, ["updateUV"]=function, ["state"]="Closed", ["setNightMode"]=function, ["deviceId"]="0xec1bbdfffeac6abd", ["updateSoundLevel"]=function, ["updateP1"]=function, ["setMode"]=function, ["startPlaylist"]=function, ["isVariable"]=false, ["hardwareName"]="Zigbee", ["switchOn"]=function, ["toggleSwitch"]=function, ["stop"]=function, ["cancelQueuedCommands"]=function, ["hardwareID"]=10, ["kodiPlay"]=function, ["deviceSubType"]="Switch", ["lastLevel"]=0, ["protected"]=false, ["switchType"]="Contact", ["updateTempHum"]=function, ["armAway"]=function, ["name"]="Keukenla", ["isGroup"]=false, ["playFavorites"]=function, ["switchSelector"]=function, ["setHue"]=function, ["kodiPause"]=function, ["dumpSelection"]=function, ["levelVal"]=0, ["isScene"]=false, ["icon"]="contact", ["pause"]=function, ["dimTo"]=function, ["open"]=function, ["updateGas"]=function, ["updateLux"]=function, ["updateYouless"]=function, ["updateCustomSensor"]=function, ["isHTTPResponse"]=false, ["updateElectricity"]=function, ["quietOff"]=function, ["reset"]=function, ["deviceType"]="Light/Switch", ["setVolume"]=function, ["kodiSwitchOff"]=function, ["quietOn"]=function, ["setValues"]=function, ["close"]=function, ["kodiPlayFavorites"]=function, ["id"]=6286, ["protectionOn"]=function, ["batteryLevel"]=100, ["updateVoltage"]=function, ["updateQuiet"]=function, ["updateMode"]=function, ["_adapters"]={"Switch device adapter"}, ["isTimer"]=false, ["rawData"]={"0"}, ["decreaseBrightness"]=function, ["updateRain"]=function, ["updateSoilMoisture"]=function, ["activate"]=function, ["isSecurity"]=false, ["onkyoEISCPCommand"]=function, ["isHardware"]=false, ["getColor"]=function, ["updateAlertSensor"]=function, ["hardwareTypeValue"]=94, ["updateWeight"]=function, ["isDevice
2023-08-06 11:32:37 327 Status: dzVents: Info: mySolar: "]=true, ["incrementCounter"]=function, ["volumeUp"]=function, ["signalLevel"]=4, ["_data"]={["iconNumber"]=0, ["switchTypeValue"]=2, ["data"]={["hardwareID"]=10, ["customImage"]=13, ["protected"]=false, ["unit"]=1, ["hardwareName"]="Zigbee", ["hardwareType"]="Zigbee2MQTT", ["maxDimLevel"]=100, ["_state"]="Closed", ["levelVal"]=0, ["usedByCamera"]=false, ["icon"]="contact", ["_nValue"]=0, ["hardwareTypeValue"]=94, ["Image"]="Alarm"}, ["changed"]=false, ["image"]="", ["subType"]="Switch", ["lastLevel"]=0, ["description"]="", ["protected"]=false, ["switchType"]="Contact", ["signalLevel"]=4, ["batteryLevel"]=100, ["deviceType"]="Light/Switch", ["deviceID"]="0xec1bbdfffeac6abd", ["lastUpdate"]="2023-08-06 09:36:21", ["id"]=6286, ["rawData"]={"0"}, ["name"]="Keukenla", ["timedOut"]=true, ["baseType"]="device"}, ["setRGB"]=function, ["updateRadiation"]=function, ["setHotWater"]=function, ["setColor"]=function, ["updatePressure"]=function, ["updateSetPoint"]=function, ["timedOut"]=true, ["setState"]=function}

I like to retrieve a single property for example: "minutesAgo". (Value: 116).

Can somebody tell me how to do this?????
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Retrieving a device property?

Post by waltervl »

Go to the dzvents documentation and decide what property you want: https://www.domoticz.com/wiki/DzVents:_ ... ll_devices
Also for specific devices specific functions are created (scroll down in the wiki page). These are functions to read and to set properties (starting with Set or update)

For example if you want to read the batteryLevel of a device use

Code: Select all

BatterLevelofDevice = dz.devices(<your device name>).batteryLevel
If you want to update a barometer with new values use:

Code: Select all

dz.devices(<your device name>).updateBarometer(pressure, forecast)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jpmd
Posts: 13
Joined: Tuesday 25 April 2023 19:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Retrieving a device property?

Post by jpmd »

That's exactly where I was looking for.
Thanks a lot
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests