How to add a Custom Widgets to Raspberry Pi Agent 2.0?


#1

Hi,

How to add a Custom Widgets for Raspberry Pi Agent 2.0 on the web dashboard? If I want to add a Value Display Widget, what is the code location and channel should I use?

Do I have another choice that add this widget into Raspberry Pi Agent 2.0 source code, I suppose the widget should automatic show up on the Cayenne web.

Thanks.


#2

Hi again @overheat1984
You need to change the agent code in order to send data on a custom channel so the widget will automatically popup as for an regular MQTT device.
For now custom widgets from UI is not supported.


#3

Hi,

Loud and clear! Thanks.

Do you know where can I find a example for add a Custom Widgets or Custom Sensor in to Raspberry Pi Agent 2.0?


#4

forgot to tag @jburhenn here :slight_smile:


#5

If you want to use custom widgets you might consider using the Cayenne-MQTT-Python library which is designed for custom widget usage.

However if you want to integrate it into the Pi agent you can do it using cayennemqtt.DataChannel.add. That function can be used to append items to a list of sensor data. For instance you could use the following to send temperature data on channel 1 inside the SensorsInfo function of sensors.py:

cayennemqtt.DataChannel.add(sensors_info, 1, type='temp', unit='c', value=23.0, name='Test Sensor')

The values you can use for the type and unit parameters are the same as the ones available for the other MQTT libraries.


#6

Hi,

Thank you! the Cayenne-MQTT-Python is a very good start point for me.
The Raspberry Pi Agent 2.0 looks more complex for someone very beginner like me.


#7

On a slightly different tack, I think… Is there a widget that will display a string?

In particular, the agent already supports returning the IP address (sys:net;ip), but I can’t display the whole response. If I try to display it as a variable, I can get the first two pieces (i.e., 10.200) but I can’t get the last two.


#8

Sorry, no text widgets at the moment, but it is coming.