Turning devices on and off?
-
Hi all,
Were a long time user of CATNET and are switching over to Mango and its going relatively smooth. But I was wondering how to make a settable point that acts like an on-off switch for a device.
I would also like to make an interface screen where I can see my system and have the switches as little buttons on the screen. See the picture for what Im looking to make. In this particular setup, you can turn on the fan by clicking on it. I want to do something similar with Mango.
Any help?
Thanks,
Jonathan
Attachment: download link
-
Hi Jonathan,
Here is a service side script that should allow you to do what you want:
var s = ""; if (!value) s += "<img style='cursor:pointer;' src='graphics/Drinks/drink_empty.png' onclick='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\", \"true\");return true;'/>"; else if (value) s += "<img style='cursor:pointer;' src='graphics/Drinks/drink.png' onclick='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\", \"false\");return false;'/>"; return s;
Add a server side script your graphic view using a biniary point that you want to turn on and off. Create two images that you want to use and install them in the graphics folder. Then modify the image URL in the script to point to your images "graphics/Drinks/drink_empty.png"
Hopefully this is what you are asking about.
Joel.
-
Joel,
Could you elaborate a little, I'm trying to do a multistate button (on, off, disabled, etc. ) but this is the first step for me.
The state of a device is received by mango using http receiver, but I can't figure out how to send user requests (button that was pressed) from mango to a server or a device.
-
The problem here is that http receiver data points are not settable so you can't do this directly. One method that might work for you is to create a virtual point that you display on your dashboard with the button, then use a http publisher to push the data where you need it to go.
Hope that helps,
Joel. -
Joel,
On the example above, where can I find the point.id and pointComponent.id on a particular point?
-
Sorry, I have no idea and not really sure what you mean. What do you need to know this?
Joel. -
I assumed the point.id and the pointComponent.id has to be changed to their actual value.
-
No, not at all. This is script is to be used in a server side script on a graphic view. In the script you select the Datapoint you want to use from the drop down list.