send MQTT message to Domoticz log with log level?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

send MQTT message to Domoticz log with log level?

Post 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.
Last edited by Domoberry on Monday 13 January 2025 12:27, edited 1 time in total.
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

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

Post 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' :) .
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Domoberry
Posts: 122
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

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

Post by Domoberry »

Thanks @Waltervl,
I'm afraid making changes to the Dz code is a bridge to far for me :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests