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
Problem adding own module
Re: Problem adding own module
Make sure the class name in your module is same as folder name.
Re: Problem adding own module
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.
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.
Re: Problem adding own module
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.
But better test 2.3.0-rc6 - it has custom icons implemented - you can upload icons and used them in devices.
Re: Problem adding own module
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
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
Re: Problem adding own module
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?
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?
Re: Problem adding own module
The app based on the same UI as browser will be updated once we release v2.3.0.