Page 1 of 1

Plugins and Python 3.10

Posted: Saturday 12 March 2022 10:18
by meyland
Hi

Right now I'm running Domoticz version 2022.1 (build 14268) on Fedora 35 and Phyton 3.10.2. I have installed some plug-ins in my Domoticz environment and the most of them are working without problems. But two of them says "Python exception set prior to callback 'onMessage'", which results in no input from the plug-ins.
The two plug-ins are:
  • Domoticz-deCONZ
  • yamaha-av-receiver
I have, of course, checked for newer versions of the plug-ins

Can anyone give me at hint to a solution?

Re: Plugins and Python 3.10

Posted: Saturday 12 March 2022 11:38
by waltervl
Python 3.10 support in Domoticz beta is still experimental. Fedora is also not very common.
Can you post some more logging?

Re: Plugins and Python 3.10

Posted: Saturday 12 March 2022 13:10
by meyland
I would like to give more information, but the text "Python exception set prior to callback 'onMessage'" is the only message I get. Can you maybe tell me how I can enable more logging.

Re: Plugins and Python 3.10

Posted: Saturday 12 March 2022 14:41
by waltervl
Sometimes you can set extra debug logging on in the plugin (through menu setup - hardware).
What happens if you only update the plugin without changing anything through menu setup - hardware (it will/should restart).

Re: Plugins and Python 3.10

Posted: Tuesday 15 March 2022 21:13
by meyland
I have now tried to turn on debug info in the Yamaha Plug-in and there are a lot of info, but no extra info about the error, only the text "Python exception set prior to callback 'onMessage'". Before I upgraded my server to Fedora 35 (and Python 3.10) everything was working.

Re: Plugins and Python 3.10

Posted: Sunday 20 March 2022 14:30
by meyland
I've tried to do some debugging in det code. I've modified the function ProcessInbound in class CPluginProtocolLine (PluginProtocols.cpp, line 101), so I got som debug information:

Code: Select all

	void CPluginProtocolLine::ProcessInbound(const ReadEvent* Message)
	{
		CConnection* pConnection = Message->m_pConnection;    //pm
		CPlugin* pPlugin = pConnection->pPlugin;              //pm
      pPlugin->Log(LOG_ERROR, "(%s) entry", __func__);      //pm

		//
		//	Handles the cases where a read contains a partial message or multiple messages
		//
		std::vector<byte>	vData = m_sRetainedData;										// if there was some data left over from last time add it back in
		vData.insert(vData.end(), Message->m_Buffer.begin(), Message->m_Buffer.end());		// add the new data

		std::string		sData(vData.begin(), vData.end());
		int iPos = sData.find_first_of('\r');		//  Look for message terminator
      pPlugin->Log(LOG_ERROR, "(%s) iPos  : %d", __func__, iPos);  //pm
      pPlugin->Log(LOG_ERROR, "(%s) string: %s", __func__, sData.c_str());  //pm

		while (iPos != std::string::npos)
		{
			Message->m_pConnection->pPlugin->MessagePlugin(new onMessageCallback(Message->m_pConnection, std::vector<byte>(&sData[0], &sData[iPos])));

			if (sData[iPos + 1] == '\n') iPos++;				//  Handle \r\n
			sData = sData.substr(iPos + 1);
			iPos = sData.find_first_of('\r');
         pPlugin->Log(LOG_ERROR, "(%s) iPos  : %d", __func__, iPos);  //pm
         pPlugin->Log(LOG_ERROR, "(%s) string: %s", __func__, sData.c_str());  //pm
		}
      pPlugin->Log(LOG_ERROR, "(%s) string: %s", __func__, sData.c_str());  //pm

		m_sRetainedData.assign(sData.c_str(), sData.c_str() + sData.length()); // retain any residual for next time
      pPlugin->Log(LOG_ERROR, "(%s) exit", __func__);       //pm
	}
The Yamaha plugin sends these commands to the receiver when started:

Code: Select all

@MAIN:PWR=?
@MAIN:VOL=?
@MAIN:INP=?
@MAIN:MUTE=?
@MAIN:SOUNDPRG=?
@MAIN:STRAIGHT=?
and the modificed code gives this result:

Code: Select all

2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) entry
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) iPos  : 12
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) string: @MAIN:PWR=On

2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) iPos  : -1
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) string:
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) string:
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) exit
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) entry
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) iPos  : 15
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) string: @MAIN:VOL=-50.0
@MAIN:INP=TUNER
@MAIN:MUTE=Off
@MAIN:SOUNDPRG=2ch Stereo
@MAIN:STRAIGHT=Off

2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) iPos  : 15
2022-03-20 14:19:33.149  Error: AVR Yamaha: (ProcessInbound) string: @MAIN:INP=TUNER
@MAIN:MUTE=Off
@MAIN:SOUNDPRG=2ch Stereo
@MAIN:STRAIGHT=Off

2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) iPos  : 14
2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) string: @MAIN:MUTE=Off
@MAIN:SOUNDPRG=2ch Stereo
@MAIN:STRAIGHT=Off

2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) iPos  : 25
2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) string: @MAIN:SOUNDPRG=2ch Stereo
@MAIN:STRAIGHT=Off

2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) iPos  : 18
2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) string: @MAIN:STRAIGHT=Off

2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) iPos  : -1
2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) string:
2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) string:
2022-03-20 14:19:33.150  Error: AVR Yamaha: (ProcessInbound) exit
2022-03-20 14:19:33.150  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.162  Error: AVR Yamaha: Exception: 'SystemError'.  No traceback available.
2022-03-20 14:19:33.162  AVR Yamaha: (AVR Yamaha) Python exception set prior to callback 'onMessage'
2022-03-20 14:19:33.162  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.162  Error: AVR Yamaha: Exception: 'TypeError'.  No traceback available.
2022-03-20 14:19:33.162  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.162  Error: AVR Yamaha: Exception: 'SystemError'.  No traceback available.
2022-03-20 14:19:33.162  AVR Yamaha: (AVR Yamaha) Python exception set prior to callback 'onMessage'
2022-03-20 14:19:33.162  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'TypeError'.  No traceback available.
2022-03-20 14:19:33.163  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'SystemError'.  No traceback available.
2022-03-20 14:19:33.163  AVR Yamaha: (AVR Yamaha) Python exception set prior to callback 'onMessage'
2022-03-20 14:19:33.163  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'TypeError'.  No traceback available.
2022-03-20 14:19:33.163  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'SystemError'.  No traceback available.
2022-03-20 14:19:33.163  AVR Yamaha: (AVR Yamaha) Python exception set prior to callback 'onMessage'
2022-03-20 14:19:33.163  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'TypeError'.  No traceback available.
2022-03-20 14:19:33.163  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'SystemError'.  No traceback available.
2022-03-20 14:19:33.163  AVR Yamaha: (AVR Yamaha) Python exception set prior to callback 'onMessage'
2022-03-20 14:19:33.163  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'TypeError'.  No traceback available.
2022-03-20 14:19:33.163  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'SystemError'.  No traceback available.
2022-03-20 14:19:33.163  AVR Yamaha: (AVR Yamaha) Python exception set prior to callback 'onMessage'
2022-03-20 14:19:33.163  Error: AVR Yamaha: Call to function 'onMessage' failed, exception details:
2022-03-20 14:19:33.163  Error: AVR Yamaha: Exception: 'TypeError'.  No traceback available.
2022-03-20 14:19:37.234  Status: AVR Yamaha: Stop directive received.

Re: Plugins and Python 3.10

Posted: Monday 04 April 2022 12:10
by jzapater
I have the same problem with Domoticz-Tuya-Thermostat-Plugin

Any solution ?

Re: Plugins and Python 3.10

Posted: Friday 27 May 2022 19:35
by jzapater
Thanks, @dnpwwo.

Resolved in your commit 0c099e19745c6440dd86446509516ce2947eb9a5

Re: Plugins and Python 3.10

Posted: Wednesday 24 August 2022 13:46
by epierre
seems the Linky plugin has some issue also on 3.10, though through alternatives I am unable to force 3.8 as domoticz always use 3.10 and I don't know why (even with strace...)

Re: Plugins and Python 3.10

Posted: Thursday 01 September 2022 20:30
by Barberousse
epierre wrote: Wednesday 24 August 2022 13:46 seems the Linky plugin has some issue also on 3.10, though through alternatives I am unable to force 3.8 as domoticz always use 3.10 and I don't know why (even with strace...)
To be more specific, there are troubles with the Configuration object, giving the message "Error: (JSONtoPython) failed to add item '-1', to list for string." for each Domoticz.Configuration(Config) call.

I will check if I'm able to reproduce on a very simple test plugin.

Domoticz V2022.1 (build 14479)
Python 3.10.4
Ubuntu 22.10

Re: Plugins and Python 3.10

Posted: Monday 05 September 2022 15:13
by epierre
for me working since yesterday, updating toward the git !