Set Used device in Update function

Python and python framework

Moderator: leecollings

Post Reply
lucasub
Posts: 15
Joined: Monday 28 March 2016 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Set Used device in Update function

Post 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
lucasub
Posts: 15
Joined: Monday 28 March 2016 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set Used device in Update function

Post 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
lucasub
Posts: 15
Joined: Monday 28 March 2016 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set Used device in Update function

Post by lucasub »

Nobody have solution?

Bye
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Set Used device in Update function

Post 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
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
lucasub
Posts: 15
Joined: Monday 28 March 2016 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set Used device in Update function

Post by lucasub »

Thank you very much for answer.

Bye
Luca
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Set Used device in Update function

Post by Dnpwwo »

Pushed a fix last night. Should be in the next beta.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest