Page 1 of 2

Code device, javascript for updating value into xml file

Posted: 29 Dec 2020 20:53
by arpanetitaliasrl
Hello,
I've just installed a code device app into my zwave.me installation.
I need a toggle button which when clicked, it change values from off to on into .xml file
So the code I put into web settings page of code device module is:

Code: Select all

http.request({url: "http://127.0.0.1:8083/opendoor.xml",method: "POST", data: "value:"on"})
but I get

Code: Select all

Error during perform command execution: SyntaxError: Unexpected identifier
then my opendoor.xml file content here:

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<value>off</value>
Cattura.JPG
Cattura.JPG (54.74 KiB) Viewed 574 times

Re: Code device, javascript for updating value into xml file

Posted: 30 Dec 2020 00:32
by PoltoS
1. There is a syntax error:
data: "value:"on"

2. You can not write a file like that with Z-Way web server

3. why not to use code device with system("echo '<?xml version=\"1.0\" encoding=\"utf-8\" ?><value>off</value>' > /some/folder/opendoor.xml") ?

Don't forget to add the command to .syscommands (without escape \)

Re: Code device, javascript for updating value into xml file

Posted: 30 Dec 2020 01:36
by arpanetitaliasrl
Thank you so much PoltoS, it works! Great!Now the system is much more powerful because I can talk to external python scripts :D :D

Last question please:
How can I write the status change after that command on webserver log page at the same time?

Re: Code device, javascript for updating value into xml file

Posted: 30 Dec 2020 05:44
by PoltoS
Sorry, I've not got your question

Re: Code device, javascript for updating value into xml file

Posted: 30 Dec 2020 14:41
by arpanetitaliasrl
Sorry I did not explain myself clearly.

I mean, is it possibile to have on the web page /smarthome/#/events
the status change log entry when clicking the toggle button?
for example like HTTP device does:
"12/30/2020 - 11:14 - HTTP device is ON/OFF"

Re: Code device, javascript for updating value into xml file

Posted: 01 Jan 2021 04:59
by PoltoS
Toggle buttons are also logged in events. This should work out of the box

Re: Code device, javascript for updating value into xml file

Posted: 01 Jan 2021 13:32
by arpanetitaliasrl
I have installed zway on a raspberry model 3 with raspi-os lite. Brand new installation, just code device installed as application and no log
What configuration can I check? Or I should use the zway bundled image?

Re: Code device, javascript for updating value into xml file

Posted: 01 Jan 2021 18:38
by arpanetitaliasrl
PoltoS wrote:
01 Jan 2021 04:59
Toggle buttons are also logged in events. This should work out of the box
Yes toggle button inside code device

Re: Code device, javascript for updating value into xml file

Posted: 02 Jan 2021 01:47
by PoltoS
Please check /var/log/z-way-server.log for more info

Re: Code device, javascript for updating value into xml file

Posted: 02 Jan 2021 01:54
by arpanetitaliasrl

Code: Select all

[core] ---  Code_Device_toggleButton_19 performCommand processing: {"0":"on","1":{}}
This is /var/log/z-way-server.log entry