[Solved] Devices created from python plugin do not work as expected

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!
Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
Ewaldharmsen
Posts: 52
Joined: Tuesday 07 February 2017 16:00
Target OS: Linux
Domoticz version:
Contact:

[Solved] Devices created from python plugin do not work as expected

Post by Ewaldharmsen » Saturday 10 November 2018 12:35

Domoticz Version: 4.10181
Platform: RPI3

Description:
I have created a python plugin.
In there I create 3 devices with

Code: Select all

Domoticz.Device(Name="Control", Unit=1, TypeName="Selector Switch", Switchtype=18, Image=2, Options=OPTIONS1, Used=1).Create()
Domoticz.Device(Name="Volume", Unit=2, Type=244, Subtype=73, Switchtype=7, Image=8, Used=1).Create()
Domoticz.Device(Name="Title", Unit=3, Type=243, Subtype=19, Used=1).Create()
The devices show up as expected. However I have problems with them:
Unit 1: If I click on the switch, I get the message "Turned on", but the switch remains off.
Unit 2: When I move the slider it seems to work, showing the percentage as expected.
However when I do a refresh the value is not stored, and it turns out the slider is still off.
When I update the device with code like so:

Code: Select all

Devices[2].Update(50, str(50))
I get this in the log of Domoticz:
2018-11-10 11:10:16.979 (Chromecast) Update Chromecast - Volume: 52 - '52'
However, the slider is still off
Unit3: This one works. I can update the text with UpdateDevice(3,0,"Somestring"), and is shows like that in Domoticz.


I checked it with an example plugin, the Kodi one, but that plugin has the same problem. It feels the devices are somehow in readonly mode. When I try to change them, the last seen value doesn't update either.

Anybody a clue?
Last edited by Ewaldharmsen on Sunday 18 November 2018 12:09, edited 1 time in total.

Ewaldharmsen
Posts: 52
Joined: Tuesday 07 February 2017 16:00
Target OS: Linux
Domoticz version:
Contact:

Re: Devices created from python plugin do not work as expected

Post by Ewaldharmsen » Monday 12 November 2018 12:16


mvzut
Posts: 429
Joined: Thursday 12 November 2015 11:55
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Devices created from python plugin do not work as expected

Post by mvzut » Monday 12 November 2018 13:48

I noticed this too in my own plugin, but I actually liked that behavior, because my switch is intended for monitoring purposes only, not for setting by the user.
When I first saw it behaves like this, I figured that this is probably intended, i.e. that you have to capture each device click in your plugin (using the onCommand function) and perform the appropriate action there (even if it is as simple as flipping a switch). I may obviously be wrong, but in a way it sounds kind of logical doesn’t it? Hopefully others can shed more light on this.

P.S. When I update a value from within the plugin, I also noticed it is not (always) updated in the UI, so I added a Device[unit].Refresh() which seems to help, although I’m still not 100% sure if it is really needed.
Raspberry Pi 3 - RFXtrx433 - Aeon Z-Stick gen5 - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - Xiaomi Gateway - Sonos - IP cameras - Wall mounted tablet + Imperihome - MANY switches/sensors

Ewaldharmsen
Posts: 52
Joined: Tuesday 07 February 2017 16:00
Target OS: Linux
Domoticz version:
Contact:

Re: Devices created from python plugin do not work as expected

Post by Ewaldharmsen » Sunday 18 November 2018 12:08

Thanks, I have solved the problem, I found that with a dimmer device the volume needs to be the string value.

Post Reply

Who is online

Users browsing this forum: hennykarreman and 0 guests