Page 1 of 1

Logging to domoticz log from Python script.

Posted: Thursday 21 February 2019 16:44
by hkemal
Hello all,

I have a python script which sorts the pictures uploaded from the smartphones in a specific folder structure.
The script ran before on a Synology and now it runs on the same Raspi as the Domoticz.

Before on Synology when an error occurred the script would send me an email. I got this running on the Raspi using the Domoticz JSON Api.
I would like the script to log this error to the domoticz log as well, but I can not get it to work.

This example doesn't work, why?

1. Create test_log.py in the shell
import domoticz
domoticz.log('Hello World')

2. Run python 3 test_log.py brings "No object log in module".

What am I doing wrong?

Regards
Kemal

Re: Logging to domoticz log from Python script.

Posted: Sunday 10 March 2019 14:51
by Samael
You can not run script that use Domoticz outside of Domoticz.
Press Settings -> Advanced -> Events. Choose Python, name it, edit it and test.

https://www.domoticz.com/wiki/Scripts#Python_scripts

Re: Logging to domoticz log from Python script.

Posted: Sunday 10 March 2019 15:46
by zak45
hkemal wrote: Thursday 21 February 2019 16:44 1. Create test_log.py in the shell
import domoticz
domoticz.log('Hello World')

2. Run python 3 test_log.py brings "No object log in module".

What am I doing wrong?

Regards
Kemal
if I remember, had read that log should be Log.