Python Plugin Device Update not working correct

Python and python framework

Moderator: leecollings

Post Reply
Jiriki
Posts: 4
Joined: Tuesday 14 January 2014 17:53
Target OS: Linux
Domoticz version: 3.5877
Location: Sweden
Contact:

Python Plugin Device Update not working correct

Post by Jiriki »

Hi, I don't now where to put feedback on Python plugin errors so I do it here.
While trying to make a plugin for FHT80b I notised an error, I think.
I'm creating devices with hi numbers from the hex addresses I get from FHT80b like 0x4e20=20000, creation works without any problem and the device is shows up as expected.
It is when I try to update the device, Devices[20000].Update(0, "Test"), peculiar things happens, the update goes through but a new device with id=32 is create instead of updating the correct device. It seems that the index precision is lost somewhere. Only one byte is used and 0x20=32.
I hope this in some ay can help you debug/correct the pugin.
/Mats
Edit: I'm using Domoticz Version: 3.6496, Build Hash: bffa02c, Compile Date: 2017-01-26 11:46:58, on a Odroid with Ubuntu 16.04
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: Python Plugin Device Update not working correct

Post by Dnpwwo »

@Jiriki,

I've had a look at this and it is a Domoticz restriction unfortunately.

Wherever possible I reuse existing functionality and the update code in Domoticz does two things:
  • Only accepts a single unsigned character for the Unit number (as you have guessed) so 255 is the maximum
  • Creates new devices if it doesn't find the one being updated (which you have seen)
I suspect that this is a part of the RFXcom heritage in the program.
Writing my own update code would be possible but I suspect that this problem would just start to appear in other parts of the system so its not a good idea. I will update the wiki to make this clear and add a check in the create code.

Thanks for reporting.

Dnpwwo
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
Jiriki
Posts: 4
Joined: Tuesday 14 January 2014 17:53
Target OS: Linux
Domoticz version: 3.5877
Location: Sweden
Contact:

Re: Python Plugin Device Update not working correct

Post by Jiriki »

Thanks for the answer, have done a workaround that works for me but there will be much harder to do a more general plugin for FHT/FS20 as they allow IDs from 0 to 65,535. Fore a more general solution some kind of persistent translation table need to be stored somewhere, are there such a place?
/Mats
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: Python Plugin Device Update not working correct

Post by Dnpwwo »

@Jiriki,

You could follow the OpenZWave pattern and write the config/mapping to a local file. The framework doesn't have functionality for that but there is nothing to stop you using standard Python file handling for it and serialising some data in JSON or XML using standard imports.

I suspect Python will put it in the domoticz folder by default but I could expose the plugin home folder to the plugin pretty easily to help store it more locally.

Would that help?
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
Jiriki
Posts: 4
Joined: Tuesday 14 January 2014 17:53
Target OS: Linux
Domoticz version: 3.5877
Location: Sweden
Contact:

Re: Python Plugin Device Update not working correct

Post by Jiriki »

Sorry about the length of this post

The history of this is that I left Domoticz for openHAB a few yers ago because I was not able to connect to FHT and I was not willing to write a plugin for FHT80b i C++ but now when I got the possibility to write one in Python it's anothe case.

I'm just in the beginning of this plugin, just worked with it for a few days but hopefully it will be something that others can continue on, my goal for now is to get the temperatur and be able to set the temperatur, it could be extended to handle FS20 equipment but I do not have such hardware.

Three things:

1) Yes, I would like to have a path to the plugin directory to be able to save a translation table.

2)
I must admit that I'm unclear of how devices are handled inside Domoticz but as the GUI has columns for both battery status and signal strength I assume it is possible to set those values so if you are willing to do another change making it possible to set those values it would also be appreciated as the FHT80b thermostats returns the following values:
- Actual temperature
- Current setpoint
- Battery status
- Signal strength(this is from a CC1101 transceiver with culfw software)

3)
Domotizs crashes after a few hours, the GUI reports Domoticz offline or a blank page, I have not had time look in to this. (After lates crash some devices still could be found from Python code but not shown in GUI)
a) Could be because this is a Domoticz beta I compiled from last source)
b) Something in the Python plugin system
c) Something in my Python code .....

/Mats
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: Python Plugin Device Update not working correct

Post by Dnpwwo »

@Jiriki,

1) The latest beta has some new entries in the Parameters dictionary and "HomeFolder" is one of them.

2) The latest beta has SignalLevel and BatteryLevel parameters available on the Device.Update

3) If you want to send me a copy of your plugin I can give you some feedback
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
Jiriki
Posts: 4
Joined: Tuesday 14 January 2014 17:53
Target OS: Linux
Domoticz version: 3.5877
Location: Sweden
Contact:

Re: Python Plugin Device Update not working correct

Post by Jiriki »

Thank you for that.
I have had so little time this weekend for the plugin but still working on it.

You will get a copy as soon as everything is in place but it will take some weeks.
joho500
Posts: 1
Joined: Saturday 02 December 2017 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python Plugin Device Update not working correct

Post by joho500 »

hi Jiriki, did you make any progress on this? I would like to use Domoticz too, but I also have a lot of FHT and FS20 devices I want to keep using.

Cheers,
Joost
Post Reply

Who is online

Users browsing this forum: akamming and 1 guest