Logging to domoticz log from Python script.

Python and python framework

Moderator: leecollings

Post Reply
hkemal
Posts: 13
Joined: Wednesday 16 January 2019 14:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Logging to domoticz log from Python script.

Post 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
Samael
Posts: 27
Joined: Saturday 12 January 2019 11:48
Target OS: Windows
Domoticz version: 4.9701
Contact:

Re: Logging to domoticz log from Python script.

Post 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
zak45
Posts: 953
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Logging to domoticz log from Python script.

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest