Page 1 of 1

Device Notification on/off setting just like timers (active)

Posted: Thursday 18 March 2021 12:11
by marmachine
Hi,

I have the following usecase;
When i leave home i activate the "away" switch.
When "away" i want to receive notifications of motion- and doorsensors for example.

My request is:
What i would like to do is to toggle notification settings for specific devices to 'ON' (or active) just like i can with timers for each device.
When i am home, i don't need to be notified when there is movement in the house, especially not over and over again, day or night, so i'd like to turn OFF notification settings then and/or activate a second setting that would send notifications with different settings. (low priority)

I don't see this option in the JSON/API, this is where/how i would like to control the notification setting.

Thanks!

Re: Device Notification on/off setting just like timers (active)

Posted: Thursday 18 March 2021 12:58
by waaren
marmachine wrote: Thursday 18 March 2021 12:11 When "away" i want to receive notifications of motion- and doorsensors for example.
I don't see this option in the JSON/API, this is where/how i would like to control the notification setting.
There is no active = true or active = false type of setting for notifications.

One way to workaround this would be to set the target notification system to one you do not use. In my case that would be kodi.

The 'deactivate' call would then look look like

Code: Select all

http://<domoticz ip:domoticz:port>/json.htm?devidx=54&idx=17&param=updatenotification&tmsg=&tpriority=1&tsendalways=false&tsystems=kodi&ttype=7&tvalue=0&twhen=0&type=command

The 'reactivate' call would then look look like

Code: Select all

http://<domoticz ip:domoticz:port>/json.htm?devidx=54&idx=17&param=updatenotification&tmsg=&tpriority=1&tsendalways=false&tsystems=email;fcm;http&ttype=7&tvalue=0&twhen=0&type=command

Re: Device Notification on/off setting just like timers (active)

Posted: Friday 23 April 2021 11:27
by marmachine
Excellent, thank you Waaren!

Re: Device Notification on/off setting just like timers (active)

Posted: Wednesday 20 November 2024 16:27
by furtifc
Hello everyone,

I am French and sorry in advance if the translation is not quite correct.
I allow myself to raise this subject because despite several tests on two different machines under raspberry the workaround to disable a notification given by "waaren" does not work or no longer works.

Here is the Domoticz version:
Version: 2024.7
dzVents Version: 3.1.8
Python Version: 3.9.2

If you have an idea I am a taker.
Thank you and have a good day.

Re: Device Notification on/off setting just like timers (active)

Posted: Wednesday 20 November 2024 17:06
by waltervl
furtifc wrote: Wednesday 20 November 2024 16:27 Hello everyone,

I am French and sorry in advance if the translation is not quite correct.
I allow myself to raise this subject because despite several tests on two different machines under raspberry the workaround to disable a notification given by "waaren" does not work or no longer works.
So what is not working? You do not see the notification system on the selected device switch to for example only Kodi?

See also the wiki for all the know notification API calls: https://wiki.domoticz.com/Domoticz_API/ ... ifications

Re: Device Notification on/off setting just like timers (active)

Posted: Wednesday 20 November 2024 17:50
by furtifc
Thank you for your answer, Yes that's exactly it, the notification on the selected device does not only go to kodi.

If I run the command line below via my browser on my PC here is the answer:

Code: Select all

https://192.168.1.14:443/json.htm?devidx=820&idx=30&param=updatenotification&tmsg=&tpriority=1&tsendalways=false&tsystems=kodi&ttype=7&tvalue=0&twhen=0&type=command
http://laudouard.hd.free.fr:25041/share ... pture1.JPG

I have the same error message with the function: Add device notification, while the order : Get device notifications it's ok.

Re: Device Notification on/off setting just like timers (active)

Posted: Wednesday 20 November 2024 18:04
by waltervl
A less complex API call like below is working (change deviceIDX)?

Code: Select all

IP:Port/json.htm?idx=<deviceIDX>&param=getnotificationtypes&type=command

Re: Device Notification on/off setting just like timers (active)

Posted: Wednesday 20 November 2024 18:21
by furtifc
Yes it works. Screenshot on the link below

http://laudouard.hd.free.fr:25041/share ... pture2.JPG

Can you reproduce this malfunction at your level, am I the only one?
Thank you.

Re: Device Notification on/off setting just like timers (active)

Posted: Wednesday 20 November 2024 18:57
by waltervl
Yes, I have the same issue with the documented API call.

But the good news is that the API has changed and now also is able to really enable and disable the notification with parameter tactive=false|true
The API you can use is for example to switch off and set only http as notification system.

Code: Select all

/json.htm?devidx=<devID>&idx=<ID>&param=updatenotification&taction=&tactive=false&tmsg=&tpriority=0&tsendalways=false&tsystems=http&ttype=7&tvalue=0&twhen=0&type=command

Re: Device Notification on/off setting just like timers (active)

Posted: Wednesday 20 November 2024 19:04
by waltervl
I changed the wiki so it now is documented correctly:

Code: Select all

/json.htm?devidx=<DeviceID>&idx=<notificationID>&param=updatenotification&taction=<action command>&tactive=<true/false>&tmsg=<msgText>&tpriority=<pri>&tsendalways=<true/false>&tsystems=<list of notification subsystems>&ttype=<notificationType>&tvalue=0&twhen=0&type=command
Added is
taction=<action command>
tactive=<true/false>

Re: Device Notification on/off setting just like timers (active)

Posted: Wednesday 20 November 2024 19:53
by furtifc
Too strong! It's perfect! It works very well and it's a feature that was missing.
Thank you very much for your responsiveness and availability.

Re: Device Notification on/off setting just like timers (active)

Posted: Thursday 21 November 2024 19:44
by furtifc
Hello,
I add a clarification, this command line does not support spaces in the message section: &tmsg=<msgText>

Via the pc browser it's ok, but not from the command of a domoticz switch it's no. If we replace the spaces with a _ it works.

example:
&tmsg=Opening balcony door& = error
&tmsg=Opening_balcony_door& = OK

Re: Device Notification on/off setting just like timers (active)

Posted: Thursday 21 November 2024 22:56
by waltervl
You probably have to urlencode the message as indicated in the wiki.
&tmsg=Opening balcony door& = error
Will be
&tmsg=Opening%20balcony%20door%26%20%3D%20error

Re: Device Notification on/off setting just like timers (active)

Posted: Friday 22 November 2024 10:37
by furtifc
Hello,
Thanks for your feedback, it works well with the %20 on the spaces.

On the other hand, the disadvantage of the true or false of the notification via an Update device notifications is that the idx of the notification changes, strangely it is not systematically but sometimes the idx changes while the only modification of the command is the true or false. In script mode it poses a problem.

Re: Device Notification on/off setting just like timers (active)

Posted: Friday 22 November 2024 10:56
by furtifc
The workaround by adding and removing the notification doesn't seem to work for me.

Same error message as at the beginning of the upgrade command.

Here is the tested command:

Code: Select all

http://<domoticz ip:domoticz:port>/json.htm?idx=93&param=addnotification&tmsg=test&tpriority=0&tsendalways=true&tsystems=fcm;http&ttype=7&tvalue=0&twhen=0&type=command

Re: Device Notification on/off setting just like timers (active)

Posted: Friday 03 January 2025 11:05
by funky0go
Same issue here. Add device notification doesn't work. My goal is to disable notifications temporarily for a few switches. As mentioned by user furtifc the notification idx changes once updated which is kinda awkward having to query the device each time to get the new notification idx.

Code: Select all

# Add device notification
pi@domoticz:~ $ curl -sk 'https://admin:passwd@localhost:443/json.htm?idx=2&param=addnotification&tmsg=test&tpriority=0&tsendalways=true&tsystems=fcm;http&ttype=7&tvalue=0&twhen=0&type=command'
{
	"status" : "ERR"
}

# Update device notifications
pi@domoticz:~ $ curl -sk 'https://admin:passwd@localhost:443/json.htm?devidx=2&idx=1&param=updatenotification&tactive=true&tmsg=test&tpriority=0&tsendalways=true&tsystems=kodi;email&ttype=7&tvalue=0&twhen=0&type=command'
{
	"status" : "OK",
	"title" : "UpdateNotification"
}
pi@domoticz:~ $ curl -sk 'https://admin:passwd@localhost:443/json.htm?type=command&param=getnotifications&idx=2'|grep idx
			"idx" : 3
I was able to work around simply because I use Custom HTTP/Action notiffication to send xmpp as described on Wiki. I updated the script to query a switch in order to toggle alarming.

Code: Select all

#!/bin/sh 

ALARM=`curl -sk 'https://admin:passwd@localhost:443/json.htm?type=command&param=getdevices&rid=4'|grep Status|cut -d'"' -f4`
if [ "$ALARM" = "On" ];then
	echo "$4" | sudo /usr/bin/sendxmpp -t -u $1 -o $2 $3
fi

I'm running Version: 2024.7
Build Hash: b317cfab1
Compile Date: 2024-07-13 16:59:31