Page 1 of 1

Set Used device in Update function

Posted: Saturday 28 September 2019 12:39
by lucasub
Hello, I try to set Used flag to 0 or 1 in Update() function but not working.
Device is always in state of Create() device.

I try this in my script:

Devices[Unit].Update(Name=name, TypeName=TypeName, Description=description, nValue=value, sValue=sValue, Used=0) but device is always visible in switch tab.

Thank you for answer

Luca

Re: Set Used device in Update function

Posted: Sunday 29 September 2019 21:27
by lucasub
I checked better the problem:

When create new devices with Used=1 or Used=0 they work well with right Used state.
Example:
Domoticz.Device(Name=name, Unit=Unit, TypeName=dtype, Description=description, DeviceID=DeviceID, Used=1).Create()
all devices created are visible on the TABS

if:
Domoticz.Device(Name=name, Unit=Unit, TypeName=dtype, Description=description, DeviceID=DeviceID, Used=0).Create()
all devices created are not visible on TABS

So, when CREATE() devices, Used work well

When devices created are not visible (Used=0), I can put visible from UPDATE() with Used=1:
Example:
Devices[Unit].Update(Name=name, TypeName=dtype, Description=description, nValue=value, sValue=sValue, Used=1)

But when devices visible, with Used=0, the devices stay visible
Example:
Devices[Unit].Update(Name=name, TypeName=dtype, Description=description, nValue=value, sValue=sValue, Used=0)

So I think thare is BUG on UPDATE device function.

Another question: on plugin is neccesary to import Domoticz class (import Domoticz). Where I can find this package?

Thank you
Luca

Re: Set Used device in Update function

Posted: Tuesday 01 October 2019 20:38
by lucasub
Nobody have solution?

Bye

Re: Set Used device in Update function

Posted: Wednesday 02 October 2019 2:02
by Dnpwwo
There appears to be a bug but not in the Device.Update function it is in the Device.Refresh function that is responsible for load data from the database.

The Used field is not loaded so defaults to '0' which means that when you try and update it to '0' the Device.Update treats the field as unchanged (and so correctly ignores it).

I will see if I can find time to push a fix.

The Domoticz library is exposed to the plugin by Domoticz itself at run time so you will not be able to 'find' it. Some people have created 'fake' ones for testing (although I'm not sure how functional they are) that Google knows about

Re: Set Used device in Update function

Posted: Wednesday 02 October 2019 9:25
by lucasub
Thank you very much for answer.

Bye
Luca

Re: Set Used device in Update function

Posted: Thursday 03 October 2019 3:28
by Dnpwwo
Pushed a fix last night. Should be in the next beta.