Page 1 of 1

send MQTT message to Domoticz log with log level?

Posted: Saturday 11 January 2025 15:02
by Domoberry
Hi Forum,
To send a message to the Domotic log originating from mqtt, a mqtt message to the 'domoticz/in' topic like

Code: Select all

{"command": "addlogmessage", "message": "A message to the log (ends up by default in status-log)"}
does the job as mentioned in https://wiki.domoticz.com/MQTT#Log_message.

Is it also possible to spoecify the log level when doing this? I tried variants like:

Code: Select all

{"command": "addlogmessage", "message": "A message to the log (does not end up in error-log)", "level": "LOG_ERROR" }
but that does not give the result hoped for.

Re: send MQTT message to Domoticz log with log level?

Posted: Saturday 11 January 2025 16:21
by waltervl
I dont know exactly but the fact "level: status" is working I would expect "level: error" will also work. The same as "level: info" but that perhaps also is the default log level so can be omitted.

Edit: MQTT messages normally, but not always, follow the API convention so also see the API wiki https://wiki.domoticz.com/Domoticz_API/ ... moticz_log

Re: send MQTT message to Domoticz log with log level?

Posted: Monday 13 January 2025 12:59
by Domoberry
Thanks for your reply!
(As the code examples in my initial post might be confusing, I changed the text somewhat to better clarify.)

Yes, the mentioned API definition was my guiding document, e.g. if one uses (Postman to 'get') this url:

Code: Select all

http://<your_ip_address>:<your_port>/json.htm?type=command&param=addlogmessage&message="this message ends up in the error log"&level=4
A line appears also in the error log. Levels 1 and 2 behave also as expected.

Yet using this mqtt message does not result in a message in the error log, it appears in the status log (as does a message with level: 1 or 2):

Code: Select all

{"command": "addlogmessage", "message": "A message to the log (does not end up in error-log)", "level": 4 }
A line ends up in the status log.
(I also tried {... , "level": "error" } which has the same result)

The Wiki on MQTT (https://wiki.domoticz.com/MQTT#Log_message) does not mention the option to specify the 'level', so it seems to work as documented, so this is certainly not a 'bug' :) .

Re: send MQTT message to Domoticz log with log level?

Posted: Monday 13 January 2025 13:56
by waltervl
Looking at the code the log level is always STATUS and cannot be changed. So log level change for MQTT is not implemented. If you want you can change the code and build it yourself.

https://github.com/domoticz/domoticz/bl ... T.cpp#L492

Re: send MQTT message to Domoticz log with log level?

Posted: Monday 13 January 2025 16:44
by Domoberry
Thanks @Waltervl,
I'm afraid making changes to the Dz code is a bridge to far for me :-)