#PRIORITY not set in settings>Notifications>CustomHTTP/Action

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
edgarhildering
Posts: 38
Joined: Thursday 11 June 2015 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

#PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by edgarhildering »

Version: 2025.2
Build Hash: e63981b18
Compile Date: 2025-10-13 11:42:57
dzVents Version: 3.1.8
Python Version: 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0]
Platform: Linux 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux

Description: a priority in the SendNotification string is not reflected in the #PRIORITY field of the customHTTP/Action settings.
commandArray[#commandArray+1] = {['SendNotification'] = '#Alert: testswitch turned off#4###http'}
I use a script to pick up the fields and send them to my ntfy-server, like this:
script://.../ntfy.sh --user #FIELD2 --topic #FIELD1 --server #TO --org "#FIELD4 #PRIORITY" --message "#MESSAGE" --prio 3
The priority is combined with #FIELD4. The expected result is "HZN 4", however this is the result:
Screenshot from 2025-12-19 14-53-46.png
Screenshot from 2025-12-19 14-53-46.png (24.63 KiB) Viewed 117 times
AFAIK the messge for SendNotification is build up as follows:
subject#message#priority#sound#extradata#subsystem
In case I'm wrong, let me know how to do it.
kind regards, --Edgar
RaspberryPi running Domoticz 2025.2
PIRs + lightswitches
thermometers + heating control
hygrometers + dehumifiers
TUYA switches
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by waltervl »

I am not a Domoticz lua script user but is seems I miss a subject field in your command

Code: Select all

commandArray[#commandArray+1] = {['SendNotification'] = '#Alert: testswitch turned off#4###http'}

Code: Select all

   commandArray['SendNotification']='subject#body#priority#sound#extradata#subsystem' 
          -- Subject is .. the subject
          -- Body is the content of the message
          -- priority is a number from 0 (low) to 4 (emergency)
          -- sound is the sound you want to use if you use pushover
          -- extradata can be used by some of the notification.
          -- subsystem is one or more of: clickatell;email;fcm;http;kodi;lms;prowl;pushalot;pushbullet;pushover;pushsafer;telegram
So perhaps it should be something like

Code: Select all

commandArray[#commandArray+1] = {['SendNotification'] = 'Domoticz Alert#Alert: testswitch turned off#4###http'}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edgarhildering
Posts: 38
Joined: Thursday 11 June 2015 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by edgarhildering »

Hi and thanks for the reply. I kept the subject empty. Even when I define a notification on a switch
  • you can't set a subject, but you can set a message
  • the result is exactly the same: #PRIORITY in the report as above, instead of the selected priority. (in my case: Emergency)
--Edgar
RaspberryPi running Domoticz 2025.2
PIRs + lightswitches
thermometers + heating control
hygrometers + dehumifiers
TUYA switches
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by waltervl »

I dont know if #Priority is meant for this way.
Perhaps check in discussion viewtopic.php?p=304181&hilit=ntfy#p304181 how they handle notifications priority over ntfy.sh

with commandArray[#commandArray+1] = {['SendNotification'] = 'Subject#Alert: testswitch turned off#4###http'} you send something to the Domoticz http custom notification action. There you should be able to use it. https://wiki.domoticz.com/Notifications

Edit: Now I get it...... in the first topic the script definition is used in the URL/Action field of the HTTP notification.

But did you try it with a subject added in the lua command? Does it give the same result?
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
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by waltervl »

When I look in dzvents for the notify function the field subject is not an optional field...

notify(subject, message [,priority][,sound][,extra][,subsystem][,delay]):
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edgarhildering
Posts: 38
Joined: Thursday 11 June 2015 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by edgarhildering »

ok, i've added a subject to my notification:
commandArray[#commandArray+1] = {['SendNotification'] = 'MySubject#Alert: testswitch turned off#4###http'}
Unfortunately, there's no difference. And even when I send a test message from the customHTTP/action (test button), I don't see any priority.
The 'Hello' message is the result of turning the switch on. The Alert message is from the commandArray-call above (subject added). The test message is from the test button.
Screenshot from 2025-12-19 16-32-43.png
Screenshot from 2025-12-19 16-32-43.png (69.59 KiB) Viewed 91 times
RaspberryPi running Domoticz 2025.2
PIRs + lightswitches
thermometers + heating control
hygrometers + dehumifiers
TUYA switches
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by waltervl »

Perhaps check in discussion viewtopic.php?p=304181&hilit=ntfy#p304181 how they handle notifications priority over ntfy.sh
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edgarhildering
Posts: 38
Joined: Thursday 11 June 2015 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by edgarhildering »

It is not about using the priority in ntfy. That works fine. See my script where I use --prio 3. It is about getting the priority from Domoticz...
RaspberryPi running Domoticz 2025.2
PIRs + lightswitches
thermometers + heating control
hygrometers + dehumifiers
TUYA switches
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by waltervl »

When I test this with my telegram bot in the HTTP action field and try to send the priority I get a nice 0 returned as that is the default priority

Code: Select all

https://api.telegram.org/bot6xxxxxx:sbgwrbvgwevgfbbbbbbb/sendMessage?chat_id=#TO&text=#PRIORITY
When using below I get the text: 0Text in field4

Code: Select all

&text=#PRIORITY#FIELD4
But when I put quotes around it in the action field I get no response at all...

Code: Select all

&text="#PRIORITY#FIELD4"
So perhaps try

Code: Select all

script://.../ntfy.sh --user #FIELD2 --topic #FIELD1 --server #TO --org #FIELD4#PRIORITY --message #MESSAGE --prio 3
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edgarhildering
Posts: 38
Joined: Thursday 11 June 2015 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by edgarhildering »

I did try #FIELD4#PRIORITY, no success...
RaspberryPi running Domoticz 2025.2
PIRs + lightswitches
thermometers + heating control
hygrometers + dehumifiers
TUYA switches
edgarhildering
Posts: 38
Joined: Thursday 11 June 2015 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by edgarhildering »

I've done some "finger exercises" with double quotes (with quotes, without quotes, escaped quotes, etc.). No matter what I try, I can't get #PRIORITY to be entered as a parameter. The #SUBJECT parameter does work: I receive the subject in this key and can also use it in the call to ntfy.

Regarding Telegram: I see that I can't call a script there and that 'FIELDS' aren't available either; lucky you that it works for Telegram.

I'm waiting for the next release of Domoticz and will test it again then... Any suggestion is welcome in the mean time...

--Edgar
RaspberryPi running Domoticz 2025.2
PIRs + lightswitches
thermometers + heating control
hygrometers + dehumifiers
TUYA switches
User avatar
madpatrick
Posts: 758
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.2
Location: Netherlands
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by madpatrick »

Maybe this can be an option for you.

viewtopic.php?p=273355#p273355

This a script which reads out the log and send a message.
i've adjusted myself to send messages by Prowl

for example

Code: Select all

 
 local SCRIPT_VAR    = 'ErrorLogCallback'
local SCRIPT_NAME   = 'ErrorLog'
local LOG_LEVEL     = domoticz.LOG_STATUS   -- zet op LOG_ERROR bij productie

return {
    on = {
        httpResponses = { SCRIPT_VAR },
        timer = { "every hour" },
        -- devices = { 290 },
    },

    logging = {
        level = LOG_LEVEL,
        marker = SCRIPT_NAME
    },

    data = {
        lastlogtime = { initial = 0 }
    },

    execute = function(dz, item)

        --------------------------------------------------------------------
        -- Zoeken naar foutmeldingen in Domoticz log
        --------------------------------------------------------------------
        local searchTerms = { "Error", "Warning", "Failure" }

        local ignoreStrings = {
            "CheckAuthToken", "dzVents: Info:", "dzVents: !Info:", "dzVents: Debug:",
            "transport", "http", "Discarding device", "CConnection_connect",
            "PARSE", "KeyError", "nan"
        }

        local function isRelevant(str)
            if not str or str == "" then return false end
            for _, ignore in ipairs(ignoreStrings) do
                if str:find(ignore) then return false end
            end
            for _, term in ipairs(searchTerms) do
                if str:find(term) then return true end
            end
            return false
        end

        --------------------------------------------------------------------
        -- Log opvragen (lastlogtime direct vastzetten!)
        --------------------------------------------------------------------
        local function requestLog()
            local baseUrl = dz.settings['Domoticz url']
            local previousTime = dz.data.lastlogtime
            local now = os.time()

            local url = string.format(
                "%s/json.htm?type=command&param=getlog&lastlogtime=%d&loglevel=4",
                baseUrl,
                previousTime
            )

            dz.openURL({ url = url, callback = SCRIPT_VAR })

            -- BELANGRIJK: direct opslaan → crash-/restart-safe
            dz.data.lastlogtime = now
        end

        --------------------------------------------------------------------
        -- Extract recente logregels
        --------------------------------------------------------------------
        local function findLogMessage(json)
            if json and json.result and type(json.result) == "table" then
                for i = #json.result, 1, -1 do
                    local msg = json.result[i].message
                    if isRelevant(msg) then return msg end
                end
            end
            return nil
        end

        --------------------------------------------------------------------
        -- Timestamp loskoppelen van de rest
        --------------------------------------------------------------------
        local function splitAfterTimestamp(msg)
            local prefix, suffix = msg:match(
                "^(%d%d%d%d%-%d%d%-%d%d %d%d:%d%d:%d%d[^\n]-:%s)(.+)"
            )
            if prefix and suffix then return prefix, suffix end
            return msg, ""
        end

        --------------------------------------------------------------------
        -- Schoonmaken van foutmeldingen (zonder interpretatie)
        --------------------------------------------------------------------
        local function prettyMessage(msg)
            if not msg or msg == "" then return "" end

            local ts, rest = msg:match(
                "^(%d%d%d%d%-%d%d%-%d%d %d%d:%d%d:%d%d.-:%s)(.+)"
            )
            ts = ts or ""
            rest = rest or msg

            rest = rest:gsub('b"[^"]*"', "[data]")
            rest = rest:gsub("{[^}]*}", "[details]")
            rest = rest:gsub("%s+", " "):gsub("^%s*(.-)%s*$", "%1")

            return ts .. rest
        end

        --------------------------------------------------------------------
        -- Fallback parsing als JSON stukgelopen is
        --------------------------------------------------------------------
        local function manualParseFromRaw(raw)
            if not raw or raw == "" then return nil end
            if not (raw:find('"LastLogTime"') or raw:find('"GetLog"')) then return nil end

            local lastRelevant = nil
            for line in raw:gmatch("[^\r\n]+") do
                if line:find('"message"') then
                    local msg = line:match('"message"%s*:%s*"(.*)"%s*,?%s*$')
                    if msg and isRelevant(msg) then
                        lastRelevant = msg
                    end
                end
            end
            return lastRelevant
        end

        --------------------------------------------------------------------
        -- HOOFDLOGICA
        --------------------------------------------------------------------
        if item.isDevice or item.isTimer then
            requestLog()

        elseif item.isHTTPResponse then

            if not item.ok then
                dz.log(
                    "HTTP fout bij ophalen log. Statuscode: " ..
                    tostring(item.statusCode),
                    dz.LOG_ERROR
                )
                return
            end

            if item.json then
                local found = findLogMessage(item.json)

                if found then
                    local p1, p2 = splitAfterTimestamp(found)
                    local pretty = prettyMessage(p1 .. p2)

                    dz.log("Relevante foutmelding gevonden: " .. pretty, dz.LOG_FORCE)
                    dz.notify("Domoticz Foutmelding", pretty, dz.PRIORITY_HIGH)
                end

            else
                local rawData = item.data or ""

                if rawData:find("<!DOCTYPE html>") then
                    dz.log(
                        "HTML response (loginpagina). Voeg 127.0.0.1 toe aan 'Lokale Netwerken'.",
                        dz.LOG_ERROR
                    )
                    return
                end

                local manualMsg = manualParseFromRaw(rawData)
                if manualMsg then
                    local pretty = prettyMessage(manualMsg)
                    dz.log("Relevante foutmelding (fallback): " .. pretty, dz.LOG_FORCE)
                    dz.notify("Domoticz Foutmelding", pretty, dz.PRIORITY_HIGH)
                else
                    dz.log("HTTP response bevat geen geldige JSON.", dz.LOG_ERROR)
                end
            end
        end
    end
}

 
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by waltervl »

edgarhildering wrote: Friday 19 December 2025 20:39 I've done some "finger exercises" with double quotes (with quotes, without quotes, escaped quotes, etc.). No matter what I try, I can't get #PRIORITY to be entered as a parameter. The #SUBJECT parameter does work: I receive the subject in this key and can also use it in the call to ntfy.

Regarding Telegram: I see that I can't call a script there and that 'FIELDS' aren't available either; lucky you that it works for Telegram.

I'm waiting for the next release of Domoticz and will test it again then... Any suggestion is welcome in the mean time...

--Edgar
As said, if you create a telegram bot you can also use it with http command.
I used it with latest stable 2025.2 I do not think a lot in this has changed recently. My test proofed the http notification changes #PRIORITY into a number and uses that in the http command. So it also should work for you.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edgarhildering
Posts: 38
Joined: Thursday 11 June 2015 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by edgarhildering »

The initial problem (passing the priority) hasn't worked yet. Here's an update.
waltervl wrote: Saturday 20 December 2025 0:07 My test proofed the http notification changes #PRIORITY into a number and uses that in the http command. So it also should work for you.
  • It turns out the priority is indeed passed correctly when an http(s) call is used. I haven't been able to do this for a script call (script://).
  • After some searching, I found a way to access the message server without using a script. It works like this:

Code: Select all

https://<message-server-address>/<topic>/publish?<key=value>&<key=value>...
  • Unfortunately, the priorities of Domoticz and NTFY are not compatible; see the table below.

Code: Select all

domoticz prio | Domoticz code | NTFY equivalent |
--------------+---------------+-----------------+
   very low   |   -2          |   1             |
   low        |   -1          |   2             |
   normal     |    0          |   3             |
   high       |    1          |   4             |
   emergency  |    2          |   5             |
So, you can't use the domoticz code without some tricks. The NTFY server returns an error if the key 'priority=' is provided with an illegal value.
I'm still investigating how to use NGINX to change the value of the domoticz parameter (provided as domprio=...) to its NTFY equivalent and then add it to the URL. But at least I can get some messages now!
RaspberryPi running Domoticz 2025.2
PIRs + lightswitches
thermometers + heating control
hygrometers + dehumifiers
TUYA switches
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: #PRIORITY not set in settings>Notifications>CustomHTTP/Action

Post by waltervl »

You are right, the notify by script section in the source does not have a #PRIORITY translation like the http part has. So you could make a GitHub issue to get this corrected.
https://github.com/domoticz/domoticz/bl ... onHTTP.cpp
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], heggink and 1 guest