Page 1 of 1

Custom Widget

Posted: 29 Mar 2016 22:45
by bogr
I'm trying to create a very simple custom module (like Dummy Device) that executes a configurable bash script. The returned value should be presented in a very simple widget. I've read How to create a widget, but it seem to be very outdated - paths are wrong, I can't find the "registerWidgetClass" when grepping the code etc. Is there any updated info on creating a widget?

Re: Custom Widget

Posted: 30 Mar 2016 09:38
by pz1
Are you aware of this: http://developer.z-wave.me/?uri=help ? It is the latest documentation.
I started at the time with the Local Weather module, which is relatively simple.

Re: Custom Widget

Posted: 30 Mar 2016 23:47
by bogr
yes, I have created my own modules which I can trigger so that is no problem, but in this case I want the module to show some info in addition, i.e. the result of running a bash script. For example in the same way a sensor shows the temperature or luminiscence value in the widget.

Re: Custom Widget

Posted: 31 Mar 2016 01:18
by pz1
I don't understand what you mean with "widget". IIRC the term is no longer used in the ZWay context. I earlier versions I think it meant what we now call virtualDevice.

Re: Custom Widget

Posted: 31 Mar 2016 10:04
by bogr
ok, sorry for the confusion. What I ment might be the virtual device, but the UI part of it. I.e when I for example create the Dummy Device, I want to be able to customize the UI so that it shows a value. In the same way all devices show their value in the little "UI-box" (whatever it's called) when you go to the "Room" and browse the devices. I know how and where to implement the backend logic behind the device, e.g. pressing the on or off button, but don't understand how the rendering of the UI is implemented and how to customize that. Don't know if I'm making myself any clearer :o

Re: Custom Widget

Posted: 31 Mar 2016 11:00
by pz1
I think I now got it. I guess your bash script is going to return a value, and you want to display that additional value on for example the Dummy Device element. (They call this the elements view, hence the term I use)
Multi.PNG
Multi.PNG (16.34 KiB) Viewed 8055 times
I fear you have to dive very deep into the code to change that.
At the moment the App Multi Sensor offers a surrogate solution. You can define there up to 10 vDevs that appear in a pop-up window if you click on the temperature value.
multi2.PNG
multi2.PNG (12.67 KiB) Viewed 8054 times
That being said, I think it would be nice if App builders had a bit more control over the element. For example the time stamp in the element represents the last time that ZWay retrieved the value, not the time when this value was measured on the Weather hut. I also think there is space in the element for one or two additional defined sensor values.
Please note that your module can also change the element icon on the fly. It is done in weather modules, I do that in App SolQoS.

Re: Custom Widget

Posted: 31 Mar 2016 15:11
by bogr
I fear you have to dive very deep into the code to change that.
Yes, that was my initial thought, but when I found the widget-wiki, I thought this was for implementing exactly what I wanted. I thought the views were template based, so it would be easily extended and customized, but apparently that's not the case.
Please note that your module can also change the element icon on the fly
Do you mean it can be changed in runtime depending on certain conditions? I haven't used the weather modules, but if that is the case it should be possible to replace the icon by a text-value, and in that way achieve what I want - i.e if you're talking about changes in runtime.

Re: Custom Widget

Posted: 31 Mar 2016 15:30
by pz1
bogr wrote:Do you mean it can be changed in runtime depending on certain conditions?
Yes, the icon below does change if one of my two solar power converters produces considerable less than the other. Depending on conditions one of these icons is displayed. I don't think it will work for text.
solQoS.PNG
solQoS.PNG (5.91 KiB) Viewed 8040 times

Re: Custom Widget

Posted: 31 Mar 2016 16:40
by bogr
ok, I see what you mean. I think I'll just create a copy of the MultiSensor and strip a lot of stuff and eventually turning it into a "SingleSensor", and then I should be set ;). Thanx for the tip.