I am using a Sparkfun 8266 Thing board with a PIR sensor. I am using the CayenneMQTT8266 library. I can configure a custom widget to display the results of a virtualWrite, but I cannot get a trigger to function from that virtualWrite value. If I instead use a luxWrite the trigger will work, but then I can’t get rid of the unit display (“lux”).
i.e. virtualWrite(2, digitalRead(4)); → displays correctly but will not trigger
luxWrite(2, digitalRead(4)); → will display and trigger
trigger is configured as sensor above 0
I noticed that there are virtualWrite overloads that allow you to set Type and Unit
e.g. Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
Is there an equivalent for a digital sensor Type?
Yes, just 0/1 values, I just want to be able to add a digital sensor (PIR via digitalRead of GPIO) using MQTT to the Dashboard that would also trigger a response.
If I add a custom widget manually it doesn’t respond to the state change.
If I use the widget that Cayenne creates automatically when a virtualWrite is added in the code then it displays the value change but won’t trigger on the change. And this widget indicates that it is an analogSensor.
If I use the widget that Cayenne creates automatically when a luxWrite is added in the code then it displays the value change and also triggers on the change. This widget is also an analogSensor and I set the trigger up identically to #2. Not sure what is magic about the luxWrite.
I was just wondering if there was a method to create a digitalSensor via adding a virtualWrite in the code.