How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

For Z-Wave related questions in Domoticz

Moderator: leecollings

Post Reply
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by Bikey »

Hi,

I have bought a Neo Coolcam Siren/Alarm NAS-AB01Z (see Z-Wave info here)
It is supported by Domoticz/OpenZwave so when included you have a switch that can be activated to sound the alarm.

Now depending on a configuration parameter the device will sound an alarm sound or a less obtrusive doorbell chime. I would like to use this device to alternatively work either as a doorbell, or in other situations as an alarm.

So would anybody know how I could change the configuration within a (python/LUA) script before activating the switch, so I can dynamically choose to activate the alarm or the doorbell chime?
User avatar
philchillbill
Posts: 396
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by philchillbill »

I wrote the following test script in perl to loop through all the possible doorbell sounds for this device and play them with a gap of 10 seconds between each melody. You should be able to copy the ideas from it to another language if you don't like perl. The main thing is that the value passed to your NEO has to be uri-encoded AND mime-64 encoded so you cannot just pass 1-10 as a regular integer or as plaintext. The '&valuelist=6_' is the parameter setting for 'doorbell music index' as evident from the hardware tab in your Domoticz.

You can learn how to do this by opening the hardware tab for your z-wave device while you have developer tools enabled in your browser (usually ctrl-U will open this). Look under the 'network' tab at what is actually sent out by Domoticz when you click on the "Apply configuration for this device" button after changing something. The JSON string passed to your controller by Domoticz will be shown there and if you stare long enough at it you start imagining the encodings applied :mrgreen:

Code: Select all

#!/usr/bin/perl

# Runs through 10 possible Doorbell sounds with the Neo Coolcam siren

use LWP::UserAgent;
use JSON::XS;
use URI::Escape;
use MIME::Base64;
no warnings 'uninitialized';

$domo_url='192.168.178.12:8080';
$idx_zwave=10;
$idx_siren=269;

$ua=LWP::UserAgent->new; $ua->timeout(5);

sub sirenAlert {
 $melody=shift; 
 $melody64=encode_base64($melody);
 $u_melody64=uri_escape($melody64);
 $switch_url='http://'.$domo_url.'/json.htm?type=command&param=applyzwavenodeconfig&idx='.$idx_zwave.'&valuelist=6_'.$u_melody64;
 $r=$ua->put($switch_url);
 sleep 1;
 $switch_url='http://'.$domo_url.'/json.htm?type=command&param=switchlight&idx='.$idx_siren.'&switchcmd=On'; 
 $r=$ua->put($switch_url);
}


foreach $i (1..10) {
 &sirenAlert($i);
 sleep 1;
 $nodes=$ua->get('http://'.$domo_url.'/json.htm?type=openzwavenodes&idx=08');
 $res=$nodes->decoded_content;
 $data=decode_json $res;
 $music=${$$data{result}}[9]->{config}[5]->{value};
 print "Siren sound confirmed read back as: $music\n\n";
 sleep 10;
}

print "Finished.\n";
sleep 10;
Last edited by philchillbill on Monday 24 July 2017 19:46, edited 1 time in total.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by Bikey »

Thanks!
I'm not really a programmer, so what I understand from this code is that to change parameter 7 (Default Siren On mode) to "1" or "2" I would have to call this URL:

Code: Select all

http://Domo_URL/json.htm?type=command&param=applyzwavenodeconfig&idx=36&valuelist=7_2

Where: the "36" is the decimal "ZWave NodeId" from my device.

Is the coding I use for the parameter "valuelist=7_2" correct?

** EDIT **
Tried your script, it does ring the doorbell, but does not change the tune, I guess I'm using the wrong Zwave-Id. Where can I find that?
User avatar
philchillbill
Posts: 396
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by philchillbill »

The 7_2 is incorrect. Here's a list of all the encodings you may need for values from 1-10 and also for Low, Middle and High for the volume if playing with that. From it, we learn you should use 7_Mg%3D%3D to set a 2 for parameter 7.

Low --> TG93
Middle --> TWlkZGxl
High --> SGlnaA%3D%3D
1 --> MQ%3D%3D
2 --> Mg%3D%3D
3 --> Mw%3D%3D
4 --> NA%3D%3D
5 --> NQ%3D%3D
6 --> Ng%3D%3D
7 --> Nw%3D%3D
8 --> OA%3D%3D
9 --> OQ%3D%3D
10 --> MTA%3D

Note these are case-sensitive !
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by Bikey »

Thanks for you quick reply!

I'm not sure why do you mention the alarm volume. Isn't that set with another command (parameter 4)? Or is that just to be complete?

Furhtermore, where can I find the proper Zwave-Idx to use?
User avatar
philchillbill
Posts: 396
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by philchillbill »

You can see that id in the debug mode in your browser as per my post. It's not the regular idx of a device (that's the one that rings the bell, not the one to configure it). And yes, just mentioning volume to be complete.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by Bikey »

Thanks al lot for your help, I now got it working!

The encoding showed to be a little bit different for "1" and "2" then you described as I learned from the debug-info, but this is how it is working for me:

Configure as Alarm

Code: Select all

http://domo_url:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=23&valuelist=7_QWxhcm0gbXVzaWM%3D
Configure as Doorbell:

Code: Select all

http://domo_url:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=23&valuelist=7_RG9vciBiZWxsIG11c2lj
So what I have done, is to configure a group and then have these as "on" command and "off" command respectively. Furthermore, I have added the Neo Sirene switch as one of the devices in the group, with an "on delay" of 1 second.

So normally the siren is configured as doorbell, but when the Alarm Group is activated, the device is configured as alarm and then activated after 1 second. If the Alarm Group is switched off, it is reset to the default doorbell-configuration.
User avatar
philchillbill
Posts: 396
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by philchillbill »

Aha. I thought you had figured out you needed to encode a '2' (I'm away from home so wasn't looking at my actual configuration). You are not actually sending a 1 or a 2 here: The string 'QWxhcm0gbXVzaWM' corresponds to 'Alarm music' whereas 'RG9vciBiZWxsIG11c2lj' is 'Door bell music'. The "%3D" is a linefeed character at the end.

You can check these strings at https://www.base64decode.org/ and at https://www.urlencoder.org/
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by Bikey »

philchillbill wrote:Aha. I thought you had figured out you needed to encode a '2' (I'm away from home so wasn't looking at my actual configuration). You are not actually sending a 1 or a 2 here: The string 'QWxhcm0gbXVzaWM' corresponds to 'Alarm music' whereas 'RG9vciBiZWxsIG11c2lj' is 'Door bell music'. The "%3D" is a linefeed character at the end.
Yes, the value that must be sent to the ZWave device needs to be a "1" or "2".
However if you look at the query string as being sent from the browser, it looks like the Domoticz API needs to get the values from the valuelists as can be seen in the interface.
So "Alarm music" => 0 and "Door bell music" => 1

I'm not sure what happens if you send an (encoded) "0" instead of "Alarm music", it looks like no error checking is done.
lost
Posts: 616
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by lost »

When I got my Aeon Siren, I also lacked the possibility to change chime/level easily (+ didn't know at the time the "applyzwavenodeconfig" API). I thus used another option: Put a loudspeaker on the PI & make a python service that gets triggered on external sensors/virtual sensors (triggered by cameras if a defined image capture nb in a 10s time slice is reached ) movement statuses changes and "espeak" a phrase saying where some movement occured. To avoid this being too much verbose when I'm out on purpose, it's only speaking for sensors that didn't triggered since over 5mn.

Well, I could have made it simpler even if in the end I immediately know where too look for, usually, the neighbors cats intrusions!
dbgnu76
Posts: 2
Joined: Wednesday 06 December 2017 21:59
Target OS: Windows
Domoticz version:
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by dbgnu76 »

Hi !

I think i need some help here, i have also Coolcam Siren.

i have tryed this :

Code: Select all

http://127.0.0.1:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=30&valuelist=7_QWxhcm0gbXVzaWM%3D

Code: Select all

http://127.0.0.1:8080/json.htm?type=command&param=applyzwavenodeconfig&idx=30&valuelist=7_QWxhcm0gbXVzaWM=
And im getting this answer from browser:
status "OK"
title "ApplyZWaveNodeConfig"

But nothing changes in param ??
The param is showing "Door bell music" and not Alarm music as i wanted in the link config above !

/D
thibaut
Posts: 3
Joined: Monday 04 December 2017 18:25
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by thibaut »

Hi dbgnu76,
dbgnu76 wrote: Wednesday 06 December 2017 22:07 And im getting this answer from browser:
status "OK"
title "ApplyZWaveNodeConfig"

But nothing changes in param ??
This is exactly what you should get. The new parameters may not appear right away on the device page, you may need to hit "Request current stored values from device" and wait for next wake up.

By the way, thanks to all for the useful information in this thread. It's not entirely trivial, so let me give the pieces I have been stitching together to get it working within the dzVents LUA framework:

1- one needs to encode the value in base64. I did not find functions in Domoticz to do that (in LUA, there are some in C++). I found several on the web, here's one that is readable and has a clear copyright statement (updated for recent LUA and cut down to only the relevent pieces):

Code: Select all

--[[
Origin: https://github.com/toastdriven/lua-base64/blob/master/base64.lua
BSD license, Copyright (c) 2012, Daniel Lindsley
Full license at the end
Trivial changes: cut only relevant bits, update math.mod to math.fmod.
No copyright claimed for those changes.
--]]

local index_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'


function to_binary(integer)
    local remaining = tonumber(integer)
    local bin_bits = ''

    for i = 7, 0, -1 do
        local current_power = math.pow(2, i)

        if remaining >= current_power then
            bin_bits = bin_bits .. '1'
            remaining = remaining - current_power
        else
            bin_bits = bin_bits .. '0'
        end
    end

    return bin_bits
end

function from_binary(bin_bits)
    return tonumber(bin_bits, 2)
end


function to_base64(to_encode)
    local bit_pattern = ''
    local encoded = ''
    local trailing = ''

    for i = 1, string.len(to_encode) do
        bit_pattern = bit_pattern .. to_binary(string.byte(string.sub(to_encode, i, i)))
    end

    -- Check the number of bytes. If it's not evenly divisible by three,
    -- zero-pad the ending & append on the correct number of ``=``s.
    if math.fmod(string.len(bit_pattern), 3) == 2 then
        trailing = '=='
        bit_pattern = bit_pattern .. '0000000000000000'
    elseif math.fmod(string.len(bit_pattern), 3) == 1 then
        trailing = '='
        bit_pattern = bit_pattern .. '00000000'
    end

    for i = 1, string.len(bit_pattern), 6 do
        local byte = string.sub(bit_pattern, i, i+5)
        local offset = tonumber(from_binary(byte))
        encoded = encoded .. string.sub(index_table, offset+1, offset+1)
    end

    return string.sub(encoded, 1, -1 - string.len(trailing)) .. trailing
end

--[[
Copyright (c) 2012, Daniel Lindsley
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.
* Neither the name of the base64 nor the names of its contributors may be
  used to endorse or promote products derived from this software without
  specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--]]


2- one needs to URL encode the result. dzVents provides a method to do that (domoticz.urlEncode());

3- one needs to call Domoticz' JSON interface through an HTTP request. I think dzVents provides OpenURL for that but I did not manage to make sure it works for my purpose. Instead I call curl, which allows me to check this "status OK" line in the reply.

All in all, here comes a LUA function to reconfigure a device from a dzVents callback:

Code: Select all

-- No copyright claimed.
function applyzwavenodeconfig(domoticz, deviceidx, parameteridx, value)
	local server = domoticz.settings['Domoticz url'] -- something like "http://127.0.0.1:8080"
	local encoded_value = domoticz.urlEncode(to_base64(value))
	local url = server .. '/json.htm?type=command&param=applyzwavenodeconfig&idx=' .. tostring(deviceidx) .. '&valuelist=' .. tostring(parameteridx) .. '_' .. encoded_value .. '_'

	domoticz.log('Opening URL: '..url)
	local handle = io.popen('curl "'..url..'"')
	local result = handle:read("*a")
	handle:close()
	domoticz.log(result)
end
Parameters:
  • domoticz (Domoticz object): the domoticz instance provided by the dzVents framework to the callback
  • deviceidx (integer): the Z-Wave node ID, to be found in the Z-Wave configuration panel (not the Domoticz device ID)
  • parameteridx (integer): the index for the parameter to change, to be found in the Z-Wave configuration page for the device
  • value (string): the value to apply.
For instance, dbgnu76 would call it as

Code: Select all

applyzwavenodeconfig(domoticz, 30, 7, "Alarm music")
jsiegmund
Posts: 33
Joined: Sunday 14 May 2017 21:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by jsiegmund »

Kicking this up a little bit. Wondering how the experience is after doing this. I also have a siren which I also use for my alarm. There's two things I do NOT want:
1) it shouldn't take ages before the doorbell starts ringing after someone presses it.
2) the alarm should not get stuck in doorbell mode so that when a burglar comes in he only gets annoyed by a ringing doorbell.

So when reconfiguring the siren, does either one apply?
TheCondor
Posts: 78
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by TheCondor »

Hi, thanks for sharing. The suggested commands works fine for me but i need to enabled log-debug and search for the correct IDX of the siren/doorbell because it's totally different to the one in domotics and openzwave....
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by McJohn »

Why is this URL (to set the Siren function on of the Neo Coolcam) perfectly working in a browser
http://182.168.178.231:8080/json.htm?ty ... bXVzaWM%3D

:feedback: "status" : "OK",
"title" : "ApplyZWaveNodeConfig"

But within a Scene the exact same URL gives errors and won't work:
2018-10-16 20:13:17.617 Error: Error opening url: http://182.168.178.231:8080/json.htm?ty ... bXVzaWM%3D

What's going wrong here?
Thanks for the help!
Screen Shot 2018-10-16 at 20.12.44.png
Screen Shot 2018-10-16 at 20.12.44.png (98.87 KiB) Viewed 4156 times
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by McJohn »

No one has a solution for this error?
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by McJohn »

Solved!

After the change with the local network number in the settings/system/"Local Networks (no username/password) field", the Siren_Doorbell group works perfectly
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by Nautilus »

McJohn wrote: Tuesday 23 October 2018 17:06 Solved!

After the change with the local network number in the settings/system/"Local Networks (no username/password) field", the Siren_Doorbell group works perfectly
Good to hear! :) Username / password was something that crossed my mind but as you said it was working on the browser I deemed it to be an unlikely reason. But it is true that you need to set the ip of the local host as allowed as well if you want to avoid the authentication.
frankwijers
Posts: 12
Joined: Tuesday 03 December 2019 8:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: How to reconfigure a Zwave device (Neo Coolcam Siren) with a script?

Post by frankwijers »

Can somebody assist me with this one?
I bought one of these sirens a while back and I also want to double it as a doorbell. Unfortunately, I cannot get it to work like the previous posts above me. I keep getting the "ERR" message in my browser and cannot figure out what I'm doing wrong. I suspect I'm using the wrong idx, but I'm not sure which one I need. These are my devices in Domoticz:
2021-02-01_12-27-31.png
2021-02-01_12-27-31.png (19 KiB) Viewed 1828 times
2021-02-01_12-24-19.png
2021-02-01_12-24-19.png (38.28 KiB) Viewed 1828 times
Which id do I need to use?


EDIT: I figured it out. Apparently, Domoticz gives the device another IDX that is not visible anywhere (in my case it was idx 38).
Got it working and I'm able to switch it with the group configuration.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest