Black Lives Matter - Action and Equality.
0

Reading a dashboard toggle
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Reading a dashboard toggle

by jdoscher on Mon Sep 14, 2015 4:06 pm

I've created an IO feed and associated a toggle on/off switch to it on my dashboard. I'd like to be able to read the state of the toggle, but it doesn't seem to have its value changed when I switch it on/off. I have successfully changed the value of the feed to 1 or 0 via python, but changing it there doesn't change the state of the toggle. I would like to be able to both read the state of the toggle as well as change its state via python.

Thanks!
Jay

jdoscher
 
Posts: 122
Joined: Tue Jul 22, 2008 12:36 pm

Re: Reading a dashboard toggle

by jwcooper on Mon Sep 14, 2015 4:28 pm

The toggle on the dashboard is associated to the feed? And the ON/OFF values are set to 1 and 0? The default values for the toggle are "ON" and "OFF. If you have the defaults yet, you'll need to edit the block to what you are expecting and sending from the feed.

If you click the button, it does nothing for you?

An easy way to test this is to setup a line chart with the same feed. Set the toggle to 1 and 0 respectively, and click the button, it should update the line chart immediately.

jwcooper
 
Posts: 677
Joined: Tue May 01, 2012 9:08 pm

Re: Reading a dashboard toggle

by jdoscher on Mon Sep 14, 2015 5:36 pm

Using the simple python test script, here's some sample output from the toggle switch- note that the value doesn't change in the python output. Doing the line graph example you showed, it does a blank chart, but sets the min/max to -1/1 and does not plot a line or show any values.

Retrieved value from Test has attributes: Data(created_epoch=1442260563.13872, created_at=u'2015-09-14T19:56:03.138Z', updated_at=u'2015-09-14T21:31:42.433Z', value=u'0', completed_at=u'2015-09-14T21:31:42.433Z', feed_id=1579, expiration=None, position=None, id=5208405)
Latest value from Test: 0

There is no option in the toggle to set a value for the toggle settings- only to associate it with a feed. Here's a screenshot of the options I had after selecting a toggle and associating it with my feed:
Image

jdoscher
 
Posts: 122
Joined: Tue Jul 22, 2008 12:36 pm

Re: Reading a dashboard toggle

by jwcooper on Mon Sep 14, 2015 5:46 pm

Can you choose the feed again for this block? You can click EDIT in CHOOOSE FEEDS, and then REMOVE and CHOOSE again, and then save the block. For some reason, the database doesn't show this block as being associated to a feed.

jwcooper
 
Posts: 677
Joined: Tue May 01, 2012 9:08 pm

Re: Reading a dashboard toggle

by jdoscher on Mon Sep 14, 2015 6:40 pm

I found it, I had a feed with the word "sunset" and another created automatically called "susnet". :)

jdoscher
 
Posts: 122
Joined: Tue Jul 22, 2008 12:36 pm

Please be positive and constructive with your questions and comments.