Problem adding own module

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
hribaro1
Posts: 23
Joined: 06 Oct 2015 13:52

Problem adding own module

Post by hribaro1 »

I have a problem how to add my own module. I copy the files to new directory in automation/module folder and everything seems ok until I press save button. At this I get a message "Something went wrong".

I am pretty sure it is not a coding problem. The same happens if I copy for example AutoLock module and just rename it to AutoLock1. Original AutoLock work, but with AutoLock1 I get the same message "Something went wrong" when I want to use and Save app.

Is there something I am missing, do we have to register a new model somwhere or something similar.

Thanks
Robert
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Problem adding own module

Post by PoltoS »

Make sure the class name in your module is same as folder name.
hribaro1
Posts: 23
Joined: 06 Oct 2015 13:52

Re: Problem adding own module

Post by hribaro1 »

Thank you for your reply. That was indeed the problem.

I made a simple module to change the icon. I have a module.json file where we define device and url and than simple index.js file which includes this:

function Icon (id, controller) {
Icon.super_.call(this, id, controller);
}
inherits(Icon, AutomationModule);
_module = Icon;

Icon.prototype.init = function (config) {
Icon.super_.prototype.init.call(this, config);
var self = this,
icon = this.config.url,
id = this.config.device;
this.vDev = this.controller.devices.get(id);
this.vDev.set("metrics:icon", icon);
};


The module is working fine and the icon changes. For url we can define either icon description like battery, energy, switch,.. or url to the icon accessible over internet.

I have on small issue though. If I reboot than not in all cases icon stays as it was changed with this module. Typically with physical devices this would work but with virtual devices like, Codedevice icon would be changed back as it was before.
My intention was that if module is executed at startup it would always keep the icon as it was defined in this module.
Thank you in advance for your comments.
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Problem adding own module

Post by PoltoS »

You are executing .set on module init, but are you sure the vDev is already created (means Code Device is already here)? You have to track new devices creation and do compare new device ID against the config. And do that on start (if device is already here) and on creation of that device.

But better test 2.3.0-rc6 - it has custom icons implemented - you can upload icons and used them in devices.
hribaro1
Posts: 23
Joined: 06 Oct 2015 13:52

Re: Problem adding own module

Post by hribaro1 »

Thanks.
That is exactly what I was also thinking about setting the icon and maybe the vDev is not created yet.
Will test immediatelly the new version 2.3.0-rc6
hribaro1
Posts: 23
Joined: 06 Oct 2015 13:52

Re: Problem adding own module

Post by hribaro1 »

Tried the ne veesion 2.3.0 -rc6.
Icon customifation is very good and works.

Issue is it only works with web browsers.
Is it planned also that ZWay Control app will be updated with this functionslity?
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Problem adding own module

Post by PoltoS »

The app based on the same UI as browser will be updated once we release v2.3.0.
Post Reply