DZvents unble to update text sensor with local value Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Kranendijk
Posts: 60
Joined: Wednesday 29 May 2019 14:39
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Zwolle
Contact:

DZvents unble to update text sensor with local value

Post by Kranendijk »

All,

I want to extract the numbers only from my "Weerstation" device's BMP280 so I have only the numbers and feed that to a local variable to have it in a new Text device called "Barometer". Reason? I need the numbers to be fed to an OLED. Numbers only.

To accomplish this I have created a DZvents time script "Barometer ding" which first does a device dump, then sets the barometer value into a local and then (according to the device dump) set this local value into the "Barometer" device so I can use it later on. I confirm there is data in the local by sending it to the Domoticz log.

Although I think I am doing all fine, Domoticz tells me there's something wrong as I cannot update the "Barometer" device. Tried custom sensor, baometer sensor, all the same. What am I missing here?

The script:

Code: Select all

return {
          on   = { timer    = { "every 1 minutes"}},
  execute = function(dz)
        dz.devices('Barometer').dump()
        local BAROMETER = dz.devices('Luchtdruk').barometer
        dz.log(' ### Luchtdruk ' .. BAROMETER .. ' ### ')
        dz.devices('Barometer').updateCustomSensor("BAROMETER")
  end
}
And the log:

Code: Select all

2020-02-16 18:44:00.394 Status: dzVents: > name: Barometer
2020-02-16 18:44:00.394 Status: dzVents: > rawData:
2020-02-16 18:44:00.394 Status: dzVents: > 1: Hello World
2020-02-16 18:44:00.394 Status: dzVents: > timedOut: false
2020-02-16 18:44:00.395 Status: dzVents: > lastUpdate: 2020-02-16 17:48:39
2020-02-16 18:44:00.395 Status: dzVents: > description:
2020-02-16 18:44:00.395 Status: dzVents: > deviceType: General
2020-02-16 18:44:00.395 Status: dzVents: > subType: Text
2020-02-16 18:44:00.395 Status: dzVents: > deviceID: 00082204
2020-02-16 18:44:00.395 Status: dzVents: > signalLevel: 12
2020-02-16 18:44:00.395 Status: dzVents: > baseType: device
2020-02-16 18:44:00.395 Status: dzVents: > kodiStop()
2020-02-16 18:44:00.395 Status: dzVents: > updateMode()
2020-02-16 18:44:00.395 Status: dzVents: > updateWind()
2020-02-16 18:44:00.395 Status: dzVents: > unit: 1
2020-02-16 18:44:00.395 Status: dzVents: > updateAlertSensor()
2020-02-16 18:44:00.395 Status: dzVents: > nValue: 0
2020-02-16 18:44:00.395 Status: dzVents: > updateYouless()
2020-02-16 18:44:00.395 Status: dzVents: > disarm()
2020-02-16 18:44:00.395 Status: dzVents: > cancelQueuedCommands()
2020-02-16 18:44:00.395 Status: dzVents: > open()
2020-02-16 18:44:00.395 Status: dzVents: > updateVoltage()
2020-02-16 18:44:00.395 Status: dzVents: > volumeUp()
2020-02-16 18:44:00.395 Status: dzVents: > updateVisibility()
2020-02-16 18:44:00.395 Status: dzVents: > play()
2020-02-16 18:44:00.395 Status: dzVents: > updateUV()
2020-02-16 18:44:00.395 Status: dzVents: > updateTempHumBaro()
2020-02-16 18:44:00.395 Status: dzVents: > setHotWater()
2020-02-16 18:44:00.395 Status: dzVents: > switchSelector()
2020-02-16 18:44:00.395 Status: dzVents: > armAway()
2020-02-16 18:44:00.395 Status: dzVents: > updateWaterflow()
2020-02-16 18:44:00.395 Status: dzVents: > toggleSwitch()
2020-02-16 18:44:00.395 Status: dzVents: > updateTempHum()
2020-02-16 18:44:00.395 Status: dzVents: > armHome()
2020-02-16 18:44:00.395 Status: dzVents: > switchOff()
2020-02-16 18:44:00.395 Status: dzVents: > close()
2020-02-16 18:44:00.395 Status: dzVents: > state: Hello World
2020-02-16 18:44:00.395 Status: dzVents: > setDescription()
2020-02-16 18:44:00.395 Status: dzVents: > isVariable: false
2020-02-16 18:44:00.395 Status: dzVents: > changed: false
2020-02-16 18:44:00.395 Status: dzVents: > update()
2020-02-16 18:44:00.395 Status: dzVents: > updateP1()
2020-02-16 18:44:00.395 Status: dzVents: > playFavorites()
2020-02-16 18:44:00.395 Status: dzVents: > volumeDown()
2020-02-16 18:44:00.395 Status: dzVents: > updateText()
2020-02-16 18:44:00.395 Status: dzVents: > updateSoilMoisture()
2020-02-16 18:44:00.395 Status: dzVents: > switchTypeValue: 0
2020-02-16 18:44:00.396 Status: dzVents: > isSecurity: false
2020-02-16 18:44:00.396 Status: dzVents: > icon: text
2020-02-16 18:44:00.396 Status: dzVents: > setKelvin()
2020-02-16 18:44:00.396 Status: dzVents: > _nValue: 0
2020-02-16 18:44:00.396 Status: dzVents: > deviceSubType: Text
2020-02-16 18:44:00.396 Status: dzVents: > bState: false
2020-02-16 18:44:00.396 Status: dzVents: > updateRadiation()
2020-02-16 18:44:00.396 Status: dzVents: > updateTempBaro()
2020-02-16 18:44:00.396 Status: dzVents: > updateCounter()
2020-02-16 18:44:00.396 Status: dzVents: > updateWeight()
2020-02-16 18:44:00.396 Status: dzVents: > description:
2020-02-16 18:44:00.396 Status: dzVents: > setState()
2020-02-16 18:44:00.396 Status: dzVents: > isDevice: true
2020-02-16 18:44:00.396 Status: dzVents: > decreaseBrightness()
2020-02-16 18:44:00.396 Status: dzVents: > setDiscoMode()
2020-02-16 18:44:00.396 Status: dzVents: > increaseBrightness()
2020-02-16 18:44:00.396 Status: dzVents: > dump()
2020-02-16 18:44:00.396 Status: dzVents: > updateWetness()
2020-02-16 18:44:00.396 Status: dzVents: > deviceId: 00082204
2020-02-16 18:44:00.396 Status: dzVents: > switchType: On/Off
2020-02-16 18:44:00.396 Status: dzVents: > kodiExecuteAddOn()
2020-02-16 18:44:00.396 Status: dzVents: > setColor()
2020-02-16 18:44:00.396 Status: dzVents: > updateSoundLevel()
2020-02-16 18:44:00.396 Status: dzVents: > updateRain()
2020-02-16 18:44:00.396 Status: dzVents: > getColor()
2020-02-16 18:44:00.396 Status: dzVents: > setWhiteMode()
2020-02-16 18:44:00.396 Status: dzVents: > startPlaylist()
2020-02-16 18:44:00.396 Status: dzVents: > hardwareID: 16
2020-02-16 18:44:00.396 Status: dzVents: > onkyoEISCPCommand()
2020-02-16 18:44:00.396 Status: dzVents: > text: Hello World
2020-02-16 18:44:00.396 Status: dzVents: > updatePercentage()
2020-02-16 18:44:00.396 Status: dzVents: > updateSetPoint()
2020-02-16 18:44:00.396 Status: dzVents: > name: Barometer
2020-02-16 18:44:00.396 Status: dzVents: > kodiPause()
2020-02-16 18:44:00.396 Status: dzVents: > hardwareTypeValue: 15
2020-02-16 18:44:00.396 Status: dzVents: > hardwareType: Dummy (Does nothing, use for virtual switches only)
2020-02-16 18:44:00.396 Status: dzVents: > updateLux()
2020-02-16 18:44:00.396 Status: dzVents: > timedOut: false
2020-02-16 18:44:00.396 Status: dzVents: > isGroup: false
2020-02-16 18:44:00.396 Status: dzVents: > updateElectricity()
2020-02-16 18:44:00.396 Status: dzVents: > stop()
2020-02-16 18:44:00.396 Status: dzVents: > isHTTPResponse: false
2020-02-16 18:44:00.396 Status: dzVents: > updateBarometer()
2020-02-16 18:44:00.397 Status: dzVents: > protected: false
2020-02-16 18:44:00.397 Status: dzVents: > deviceType: General
2020-02-16 18:44:00.397 Status: dzVents: > updateHumidity()
2020-02-16 18:44:00.397 Status: dzVents: > updateTemperature()
2020-02-16 18:44:00.397 Status: dzVents: > updateCustomSensor()
2020-02-16 18:44:00.397 Status: dzVents: > signalLevel: 12
2020-02-16 18:44:00.397 Status: dzVents: > switchOn()
2020-02-16 18:44:00.398 Status: dzVents: Info: ### Luchtdruk 995 ###
2020-02-16 18:44:00.398 Status: dzVents: Error (2.4.19): Method updateCustomSensor is not available for device "Barometer" (deviceType=General, deviceSubType=Text). If you believe this is not correct, please report.
2020-02-16 18:44:00.398 Status: dzVents: Info: ------ Finished Barometer ding
xury
Posts: 48
Joined: Monday 10 December 2018 23:32
Target OS: Linux
Domoticz version:
Location: Poland
Contact:

Re: DZvents unble to update text sensor with local value

Post by xury »

You have to send two arguments separated by comma to custom sensor.
Make sure it's really custom sensor.
Take a look my working example:

Code: Select all

return  {
   on = {
    timer = { 'every minute' },
    devices = { 'Stan_kotla' }
    },
    execute = function(domoticz, item)
	if (item.isTimer) then
		if (domoticz.devices('Stan_kotla').nValue == 3) then 
			domoticz.devices('Stankot').updateCustomSensor(1,1)
		
	    	elseif
			(domoticz.devices('Stan_kotla').nValue == 1) then  
			domoticz.devices('Stankot').updateCustomSensor(0,0)
		
	    end
Kranendijk
Posts: 60
Joined: Wednesday 29 May 2019 14:39
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Zwolle
Contact:

Re: DZvents unble to update text sensor with local value

Post by Kranendijk »

That did the trick, thanks!

This is what I needed to change:
dz.devices('Barometer').updateCustomSensor(BAROMETER,1)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest