Python Framework 'Error message': Reference Count not correct, expected

Python and python framework

Moderator: leecollings

Post Reply
pipiche
Posts: 2016
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Python Framework 'Error message': Reference Count not correct, expected

Post by pipiche »

Since recent version of Domoticz, I'm getting this error message when stoping my python plugin .

What does that mean ? what should I do to correct it ?

Code: Select all

52:02 rasp domoticz[31474]: 2021-09-01 09:52:02.250  Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - COSensor-EM_Smoke-000d6f0014f6b5d2-01' Reference Count not correct, expected 1 found 2.
Sep 01 09:52:02 rasp domoticz[31474]: 2021-09-01 09:52:02.250  Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.sensor_switch.aq3_SwitchAQ3-00158d0002b06615-01' Reference Count not correct, expected 1 found 2.
Sep 01 09:52:02 rasp domoticz[31474]: 2021-09-01 09:52:02.250  Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.sensor_switch.aq2_SwitchAQ2-00158d00023e7918-01' Reference Count not correct, expected 1 found 2.
Sep 01 09:52:02 rasp domoticz[31474]: 2021-09-01 09:52:02.250  Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Shutter switch with neutral_Venetian-00047400008aff8b-01' Reference Count not correct, expected 1 found 2.
Sep 01 09:52:02 rasp domoticz[31474]: 2021-09-01 09:52:02.250  Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Micromodule switch_Switch-00047400001f09a4-01' Reference Count not correct, expected 1 found 2.
Sep 01 09:52:02 rasp domoticz[31474]: 2021-09-01 09:52:02.250  Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Dimmer switch wo neutral_LvlControl-000474000082a54f-01' Reference Count not correct, expected 1 found 2.
Last edited by pipiche on Tuesday 14 September 2021 14:25, edited 1 time in total.
Zigbee for Domoticz plugin / RPI3B+ / Electrolama ZZH-P / 45 devices

If the plugin provides you value, you can support me with a donation Paypal.

Wiki is available here.

Zigbee for Domoticz FAQ
pipiche
Posts: 2016
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by pipiche »

Still having this message with a recent Domoticz version 2021.1 Build 13495 !

Anything I should worry ?


Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.743 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Zigate Status 9' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.743 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Zigate Notifications 9' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.743 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - TRADFRI Signal Repeater_Voltage-680ae2fffe7aca89-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.743 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - TRADFRI remote control_Ikea_Round_5b-90fd9ffffeea89e8-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.744 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.remote.b286opcn01_AqaraOppleMiddle-04cf8cdf3c77d06a-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.744 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.remote.b286opcn01_AqaraOppleMiddle-04cf8cdf3c77d06a-02' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.744 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.sensor_switch.aq2_SwitchAQ2-00158d00023e7918-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.744 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - COSensor-EM_Smoke-000d6f0014f6b5d2-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.744 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - TH01_Temp+Hum-00124b0022e9785a-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.744 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - TH01_Temp-00124b0022e9785a-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.744 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - TH01_Humi-00124b0022e9785a-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.744 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.remote.b486opcn01_AqaraOppleMiddle-04cf8cdf3c77c899-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.745 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.remote.b486opcn01_AqaraOppleMiddle-04cf8cdf3c77c899-02' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.745 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.remote.b486opcn01_AqaraOppleMiddle-04cf8cdf3c77c899-03' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.745 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - lumi.remote.b486opcn01_AqaraOppleMiddle-04cf8cdf3c77c899-04' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.745 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - ColorControlWW-90fd9ffffe86c7a1-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.745 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Zigate Group 0000' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.745 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Zigate Group 7c42' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.745 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - LXEK-1_ColorControlRGBWW-60a423fffe529d60-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.745 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Micromodule switch_Switch-00047400001f09a4-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.746 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Shutter switch with neutral_Venetian-00047400008aff8b-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.746 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Dimmer switch wo neutral_LvlControl-000474000082a54f-01' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.746 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Zigate Group fff6' Reference Count not correct, expected 1 found 2.
Sep 14 13:49:00 rasp domoticz[16008]: 2021-09-14 13:49:00.746 Error: ZiGate-V2: Stop: Device 'ZiGate-V2 - Zigate Group fff4' Reference Count not correct, expected 1 found 2.
Zigbee for Domoticz plugin / RPI3B+ / Electrolama ZZH-P / 45 devices

If the plugin provides you value, you can support me with a donation Paypal.

Wiki is available here.

Zigbee for Domoticz FAQ
Masure
Posts: 35
Joined: Sunday 22 April 2018 11:23
Target OS: Windows
Domoticz version:
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by Masure »

Same with one of my plugin, I'm subscribing ;)
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by EscApe »

Has this ever been solved? I have the same problem in 2023.2.
Spend hours trying to find the cause in my own plugin, but after creating a completely empty test-setup from official Docker image (now build 15503). I even get this error in a very simple test plugin (code below).

Code: Select all

"""
<plugin key="testthing" name="Python Plugin Tester">
	<description>
		<h2>Test Python plugin framework</h2><br/>
	</description>
</plugin>
"""

import DomoticzEx

class BasePlugin:

	def __init__(self):
		print("Initializing plugin tester")
		
	def onStart(self):
		if not "deviceA" in Devices:
			DomoticzEx.Unit("First Device", Unit=1, DeviceID="deviceA", TypeName="Switch", Used=1).Create()
		if not "deviceB" in Devices:
			DomoticzEx.Unit("Second Device", Unit=5, DeviceID="deviceB", TypeName="Switch", Used=1).Create()
		DomoticzEx.Log("<<<<< onstart completed >>>>>")
		
	def onStop(self):
		DomoticzEx.Log("<<<<<<onstop>>>>>>")
		for d in Devices:
			DomoticzEx.Status('>> ' + str(d))
		DomoticzEx.Log("<<<<<<onstop completed>>>>>>")

global _plugin
_plugin = BasePlugin()

def onStart():
	global _plugin
	_plugin.onStart()
	
def onStop():
	global _plugin
	_plugin.onStop()
pipiche
Posts: 2016
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by pipiche »

The problem is in the DomoticZ code not in the login itself.
Until we have someone able to find and fix the code, we will get this during the stop of the plugin
Zigbee for Domoticz plugin / RPI3B+ / Electrolama ZZH-P / 45 devices

If the plugin provides you value, you can support me with a donation Paypal.

Wiki is available here.

Zigbee for Domoticz FAQ
rezzalex
Posts: 49
Joined: Thursday 24 September 2020 14:30
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by rezzalex »

Hello,

does anyone know if there is an open ticket/issue in DZ Github ?
currently, is this error message caused something or anything?
Because I have trouble with one of my plugins and would like to get rid of this possibility
meal
Posts: 108
Joined: Monday 04 March 2019 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: France
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by meal »

Hello

I have the same issue with domoticz version 2023.2.

See my subject "Stop: Device 'XXX' Reference Count not correct, expected 1" posted on 27/11/2023 in the forum.

May be a missing decrementation of the pDevice reference count in the Cplugin::Start method.

@pipiche : did you investigate the point on your side.

BR
meal
User avatar
madpatrick
Posts: 667
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by madpatrick »

Version: 2023.2 (build 15457)
Build Hash: 25624ca14
Compile Date: 2023-07-22 10:39:06
dzVents Version: 3.1.8
Python Version: 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]


i've the same error in the logs now.
It started with 1 plugin, but now all plugins are giving this error.

Code: Select all

2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Status' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Line voltage' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Load percentage' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Battery charge level' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Model' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Serial Number' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Battery voltage' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Nominal battery voltage' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Battery date' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Date of last self test' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Reason for last transfer to battery' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Nominal UPS power output' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Time left on battery' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Number of transfers to battery' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Time on battery' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.217 Error: APC UPS: Stop: Device 'APC UPS - Cumulative time on battery' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Woonkamer Temp Toon' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Toon Thermostaat' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Toon - Auto Program' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Toon - Scene' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Keteldruk' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Toon - Program info' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'P1 Gas' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Toon - Electricity' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Toon - Generated Electricity' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'P1 Elektra' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Ketelstand' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'ModulationLevel' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Ketel Setpoint' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.421 Error: Toon: Stop: Device 'Toon - Luchtvochtigheid' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Mileage' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Doors' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Windows' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Remain mileage (fuel)' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Remain mileage (elec)' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Charging' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Charging time' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Battery Level' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Remote Services' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Car' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Mileage (Day)' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Driving' Reference Count not correct, expected 1 found 2.
2024-01-14 19:47:27.525 Error: BMW: Stop: Device 'BMW - Home' Reference Count not correct, expected 1 found 2.
Somebody any idea how to fix this ?
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
meal
Posts: 108
Joined: Monday 04 March 2019 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: France
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by meal »

Hello,

I had the same issue when running domoticz version 2023.2.

A couple of python plugins issues have been fixed in that version.

I do not have the issue since upgrading to domoticz version 2024.1

Try to upgrade to 2024.1 and first make a system backup prior to it.

BR
meal
User avatar
madpatrick
Posts: 667
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Python Framework 'Error message': Reference Count not correct, expected

Post by madpatrick »

meal wrote: Monday 15 January 2024 6:58 Hello,

I had the same issue when running domoticz version 2023.2.

A couple of python plugins issues have been fixed in that version.

I do not have the issue since upgrading to domoticz version 2024.1

Try to upgrade to 2024.1 and first make a system backup prior to it.

BR
Thanks.
I just upgraded to 2024.2 stable and i don't see there errors
Fingers crossed ;)
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest