Python Plugin / Managed Counter device

Python and python framework

Moderator: leecollings

Post Reply
User avatar
breizhcat
Posts: 16
Joined: Tuesday 07 July 2020 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: France
Contact:

Python Plugin / Managed Counter device

Post by breizhcat »

Hello!

I'm trying to implement my own plugin. To achieve my needs, I would like to have a managed counter.
It works fine but I'm currently not able to add a divider when I create my device.

Code: Select all

            
Domoticz.Device(Name= 'Device Name', Unit=DEVICE_ODOMETER, Type=243, Subtype=33, Switchtype=3,
                           Options={'AddjValue2': 1000, 'ValueQuantity': 'Kilometers', 'ValueUnits': 'Km', 'AddDBLogEntry' : 'true', 'DisableLogAutoUpdate' : 'true'},                                                                           
                           Image=Images[IMAGE_DEVICE_ODO].ID, Description='Distance driven', Used=1).Create() 
My device is well created. Quantity and units are loaded, history is loaded but ... the divider (AddjValue2 it seems) is not loaded.

Is there a way to create a device with the correct divider value?

Thanks for your help.

Have a good day.
Last edited by breizhcat on Tuesday 22 June 2021 22:30, edited 1 time in total.
pipiche
Posts: 2005
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Re: Python Plugin / Managed Counter device

Post by pipiche »

removing the comment as it doesn't address the question
Last edited by pipiche on Tuesday 22 June 2021 11:51, edited 1 time in total.
azonneveld
Posts: 159
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Re: Python Plugin / Managed Counter device

Post by azonneveld »

Not an answer to your question, but please change "Distance drived" to "Distance driven"
rpi4 - zigbee2mqtt - roborock - espeasy - rfxcom - homewizard p1 - otgw - homebridge - surveillance station - egardia - goodwe - open weather map - wol - BBQ detection - rsync backup
User avatar
breizhcat
Posts: 16
Joined: Tuesday 07 July 2020 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: France
Contact:

Re: Python Plugin / Managed Counter device

Post by breizhcat »

azonneveld wrote: Tuesday 22 June 2021 11:30 Not an answer to your question, but please change "Distance drived" to "Distance driven"
Yes ! Thanks :)
RedEarth
Posts: 23
Joined: Monday 31 October 2016 11:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin / Managed Counter device

Post by RedEarth »

breizhcat wrote: Tuesday 22 June 2021 9:46 Hello!

I'm trying to implement my own plugin. To achieve my needs, I would like to have a managed counter.
It works fine but I'm currently not able to add a divider when I create my device.

Code: Select all

            
Domoticz.Device(Name= 'Device Name', Unit=DEVICE_ODOMETER, Type=243, Subtype=33, Switchtype=3,
                           Options={'AddjValue2': 1000, 'ValueQuantity': 'Kilometers', 'ValueUnits': 'Km', 'AddDBLogEntry' : 'true', 'DisableLogAutoUpdate' : 'true'},                                                                           
                           Image=Images[IMAGE_DEVICE_ODO].ID, Description='Distance driven', Used=1).Create() 
My device is well created. Quantity and units are loaded, history is loaded but ... the divider (AddjValue2 it seems) is not loaded.

Is there a way to create a device with the correct divider value?

Thanks for your help.

Have a good day.
Did you ever find a solution to this? I've encountered the same problem with a plugin that I'm trying to create that requires managed counter devices with Counter Divider set to 1000 but it's ignoring AddjValue2 for me too...

Code: Select all

           Domoticz.Device(Name="elecUnitCost", Unit=self.elecUnitCost, Type=243, Subtype=33, Switchtype=3, Options={'AddjValue2': 1000, 'ValueQuantity': 'cost', 'ValueUnits': 'p/kWh'}, Used=1).Create()
I'm not sure whether or not this syntax is correct for specifying the device options?
User avatar
waltervl
Posts: 5720
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin / Managed Counter device

Post by waltervl »

Are you sure you want to use a managed counter in your plugin? As it has no build in history function so you also have to program it yourself....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
RedEarth
Posts: 23
Joined: Monday 31 October 2016 11:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin / Managed Counter device

Post by RedEarth »

waltervl wrote: Sunday 01 January 2023 14:00 Are you sure you want to use a managed counter in your plugin? As it has no build in history function so you also have to program it yourself....
Yes the API I'm using effectively presents the smart meter data as 'history' (i.e. a list of values with accompanying timestamps), the newest available data is always at least 24 hours old, so managed counter seems to be the best fit.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest