+Index: domoticz-2020.2/hardware/plugins/DelayedLink.h
+===================================================================
+--- domoticz-2020.2.orig/hardware/plugins/DelayedLink.h
++++ domoticz-2020.2/hardware/plugins/DelayedLink.h
+@@ -14,6 +14,16 @@
+ #include <frameobject.h>
+ #include "../../main/Helper.h"
+
++#ifndef _Py_DEC_REFTOTAL
++ /* _Py_DEC_REFTOTAL macro has been removed from Python 3.9 by:
++ https://github.com/python/cpython/commit/49932fec62c616ec88da52642339d83ae719e924 */
++# ifdef Py_REF_DEBUG
++# define _Py_DEC_REFTOTAL _Py_RefTotal--
++# else
++# define _Py_DEC_REFTOTAL
++# endif
++#endif
++
+ #if PY_VERSION_HEX >= 0x030800f0
+ static inline void
+ py3__Py_DECREF(const char *filename, int lineno, PyObject *op)
+Index: domoticz-2020.2/CMakeLists.txt
+===================================================================
+--- domoticz-2020.2.orig/CMakeLists.txt
++++ domoticz-2020.2/CMakeLists.txt
+@@ -744,7 +744,7 @@ else()
+ message(STATUS "Not found telldus-core (telldus-core.h), not adding tellstick support")
+ endif (TELLDUSCORE_INCLUDE)
+
+-target_link_libraries(domoticz ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${CURL_LIBRARIES} pthread ${MQTT_LIBRARIES} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS} ${TELLDUS_LIBRARIES})
++target_link_libraries(domoticz ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${CURL_LIBRARIES} pthread ${PYTHON_LIBRARIES} ${MQTT_LIBRARIES} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS} ${TELLDUS_LIBRARIES})
+
+ IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ target_link_libraries(domoticz -lresolv)