Is it possible to read sensor data in a script?

39 views
Skip to first unread message

Jorge Adrián Muñoz Velasco

unread,
Apr 21, 2020, 8:08:50 PM4/21/20
to Google Apps Script Community
Particularly, I need to read the light or hearing sensor from a  Google Script linked to a FormApp.. Does anyone know of any APIs to read sensor data?
I was trying to implement this W3C code, but failed.

window.addEventListener("devicelight", function (event) {
  var luminosity = event.value;
  console.log(luminosity);
});
Ref: https://www.sitepoint.com/mobile-web-superpowers-ambient-light-api/

Alan Wells

unread,
Apr 21, 2020, 8:28:49 PM4/21/20
to Google Apps Script Community
FormApp is a Google service that runs on Google's servers.  FormApp will only run in a "gs" file. But

window.addEventListener

is a DOM method that can only run in the users browser from a HTML <script> tag.
A Google Form doesn't have any way to allow you to modify the HTML, CSS and JavaScript in the browser.
You can build your own input form using an Apps Script Web App, which would allow you to use addEventListener()

Taki Guan

unread,
Apr 22, 2020, 10:31:25 PM4/22/20
to Google Apps Script Community
Even use GAS Web App you need to confirm your device can be connected by Google Server.

Rubén Rivera

unread,
Apr 23, 2020, 12:43:29 PM4/23/20
to google-apps-sc...@googlegroups.com
Google Apps Script can't listen to any DOM event that occurs on a form respondent view. Some developers created a Chrome Extension that works together with the form but some others find this to be overkilling. 

Cheers


Hacia una Universidad comprometida con la Paz Territorial

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/cdf1c1b6-7a51-491c-91ff-ee1270d9decf%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages