Code device, javascript for updating value into xml file

Discussions about Z-Way software and Z-Wave technology in general
arpanetitaliasrl
Posts: 31
Joined: 18 Dec 2020 18:58

Code device, javascript for updating value into xml file

Post 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 3318 times
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

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

Post 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 \)
arpanetitaliasrl
Posts: 31
Joined: 18 Dec 2020 18:58

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

Post 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?
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

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

Post by PoltoS »

Sorry, I've not got your question
arpanetitaliasrl
Posts: 31
Joined: 18 Dec 2020 18:58

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

Post 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"
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

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

Post by PoltoS »

Toggle buttons are also logged in events. This should work out of the box
arpanetitaliasrl
Posts: 31
Joined: 18 Dec 2020 18:58

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

Post 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?
Last edited by arpanetitaliasrl on 01 Jan 2021 18:38, edited 1 time in total.
arpanetitaliasrl
Posts: 31
Joined: 18 Dec 2020 18:58

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

Post 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
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

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

Post by PoltoS »

Please check /var/log/z-way-server.log for more info
arpanetitaliasrl
Posts: 31
Joined: 18 Dec 2020 18:58

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

Post by arpanetitaliasrl »

Code: Select all

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