Custom Widget

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
bogr
Posts: 190
Joined: 16 Nov 2015 22:46

Custom Widget

Post 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?
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Custom Widget

Post 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.
bogr
Posts: 190
Joined: 16 Nov 2015 22:46

Re: Custom Widget

Post 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.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Custom Widget

Post 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.
bogr
Posts: 190
Joined: 16 Nov 2015 22:46

Re: Custom Widget

Post 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
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Custom Widget

Post 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 8017 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 8016 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.
bogr
Posts: 190
Joined: 16 Nov 2015 22:46

Re: Custom Widget

Post 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.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Custom Widget

Post 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 8002 times
bogr
Posts: 190
Joined: 16 Nov 2015 22:46

Re: Custom Widget

Post 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.
Post Reply