Devel : Is there a way to save data using javascript API?

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
Nander2
Posts: 8
Joined: 08 Nov 2016 12:37

Devel : Is there a way to save data using javascript API?

Post by Nander2 »

Hi everyone.

I wonder if there is a way to save data of a module and load it back at module startup.

I'm thinking about automatic leanring module (ex : the module change one of it parameters (ex: a table of integer [4,5,..]) save it and load it back when the z-way server start the module.). a sort of non volatile memory in short.

I think this could be done using the module Id to create a file and save data to it, but i wonder if there is a smarter way to do it (using the Z-way API for exemple). If this options should be use I also wonder where is the perfect location to save this file?

if somebody can answer any of this questions to give me a hint...

thanks
gsaw
Posts: 78
Joined: 22 Aug 2016 00:26

Re: Devel : Is there a way to save data using javascript API

Post by gsaw »

Yes, you can. Look at other modules. For logging for example.
Nander2
Posts: 8
Joined: 08 Nov 2016 12:37

Re: Devel : Is there a way to save data using javascript API

Post by Nander2 »

Ok thank.

I looked at DeviceHistory.
To save an object and load it i have to call :

Code: Select all

// to save object :
saveObject("history", self.history);
// to load object :
this.history = loadObject('history') || [];
Great!
Nander2
Posts: 8
Joined: 08 Nov 2016 12:37

Re: Devel : Is there a way to save data using javascript API

Post by Nander2 »

Hi everybody.

I'm working on an presence auto learning modules. it will permits to anticipate your presence to launch heating for exemple.

So for now i'm able to create and save presence data when the module is running. I tried to uninstall the module and install it back but the saved object is reload from the last install. So how to remove the saved object when the module is uninstalled (removed from active modules)?

Thanks.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Devel : Is there a way to save data using javascript API

Post by pz1 »

I have done that in the past as follows:
- stop Zway
- open /opt/z-way-server/automation/storage/configjson-xxxxxxxx.json
- delete the offending virtualDevice(s)

I do use Notepad++ with the JSTool plugin. A bit clumsy, but afaik the only possibility at the moment
Since 29-12-2016 I am no longer a moderator for this forum
Post Reply