Widget finetuning


#1

I have several widgets at my dashboard. Three of them are triggered by the same type of command in Arduino IDE: Cayenne.virtualWrite(3, luxState); Cayenne.virtualWrite(4, timeState); Cayenne.virtualWrite(5, lightState);
Two of (time State and lightState) are visible as a 2State widget (green background). When I look into the settings the only presentation variable I can change is ‘Choose display’, where I choose ‘Value’.
I want the third widget (luxState) displaid like wise, but here in the settings I am asked to choose an icon and the number of decimals. When I remove this widget and wait until it appears automatically triggered by the program, nothing changes.
The state of luxState is represented accurately when I choose 0 decimals, but the appearance is just a digit on a White background.
How can I fix this?


#2

Hello,
Could you make a screenshot?

Thank you!


#3

Sure,




#4

I think the data type that Cayenne detects for LuxState is different. Can you delete the widget and add it manually to the corresponding Virutal Port and choose the type that fits best for you ? (2 state widget ? )


#5

I think this is because the Cayenne.virtualWrite() is expecting 4 parameters - channel, data, data type, and unit type.

For some examples:

Digital 2-state value 1 on channel 5:
Cayenne.virtualWrite(5, 1, "digital_sensor", "d");
Generic analog value 17.222 on channel 6:
Cayenne.virtualWrite(6, 17.222, "analog_sensor", "null");
Proximity data in centimeters of 50cm on channel 7:
Cayenne.virtualWrite(7, 50, "prox", "cm");

The confusing part is that you need a list of valid data types to build these statements and the list at https://mydevices.com/cayenne/docs/#bring-your-own-thing-api-supported-data-types is out of date or incorrect in some places.

I’m going to make an up to date reference and post it to The Library category, then I’ll link it back here later today.


#6

Thanks.
One question: is the Virtual Port the same as the Channel? I use exactly
the same commands for sending the 0/1: Cayenne.virtualWrite(channel,
variableValue).


#7

I just removed the widget (and Reset Dashboard, otherwise the new widget wouldn’t accept the channel) and choose 2State and display Value and all was fine!
Thanks again.


#8

Hello Sir,
What do you mean by channel? Virtual Pin is a pin that you make it as virtual. There are 26 pins in arduino. The command looks better in this format:

Cayenne.virtualWrite(vPin, value)

where vPin is the number of the virtual Pin. After you specify it, you have to adjust the dashboard widget with the same number of the Virtual Pin. :slight_smile:


#9

I don’t use Arduino Uno, but esp8266-12e v3.
In the example for the CayenneMQTTESP8266.h library one speaks about ‘channel’ where you talk about Virtual Pin. Because it is working, I presume both VirtualPin and Channel ar synonymous.


#10

Yes, they are the same : )


#11

Thanks


#12

Glad you got this figured out @theovanderkrogt! And thanks for helping @ognqn.chikov :slight_smile:

@theovanderkrogt We’d love to see your project submitted to the ‘Projects Made with Cayenne’ category :slight_smile:

Cheers ,

-Benny


#13

If I am satisfied with my project I’ll do so.
Greetings


#14

As promised, here is v1.0 of my completed table. I’ll likely add a few more examples/notes in the future, but this should be useful to get started with the various data types, or if you have data in a format not enumerated by our data / unit types list: