Maker API CORS error?

I'm requesting all devices. Could it be that the LIFX driver is waiting on each device? I want a request to get the current status rather than repolling all devices. Ideally the Hubitat should tracking the status so such a request would be relatively current and wouldn't need a new poll.

Hubitat does track the current states. But I don't know what the driver is doing, as its custom code. Does the driver expose a lot of capabilities or states?

Does requesting one or a few devices act slow? There are separate endpoints for getting individual data. It may not be practical for requesting all data about all devices in one request. You may have to request the less detail device list and poll each device, or use the capability endpoint to only request specific capabilities.

I need to experiment more. I did try asking for the devices without the status but it didn't include the capabilities. If it did that would be fine for the first call and then I can get the status later. I may build on that as a work-around but, for the moment, I'll live with a two minute startup price.

So, if you only need switch and level, why not make 2 requests to get those via /attribute/switch and /attribute/level for all devices. Do you need all the other attributes?

Yes that was what I thought about and then ... well, I couldn't stop myself. So the first call I only get the device list and then ask for capabilities of new devices.

I found that asking for information about a single device isn't the same format as asking about them all but i worked around it for now. I think. I'll know for sure when I add another new device.

I've been beating my head against the wall all night, and came across this thread. I know this is an old thread, but in case you haven't figured it out, or someone else runs into the same brick wall, the secret handshake is:

This allowed my serverless .html file to call Maker API urls.

1 Like

Thanks! I'll need to experiment -- does this turn CORS on for all addresses?

(Too bad I'm trying to shift to https for PWAs which means that this a partial solution)

Not sure. I'm just calling HE from a static html file, and I was getting this error in the Chrome developer console:

image

so I tried using null in the Maker API Allowed Hosts field. My guess is the Maker API is just looking for a match with what is in the Origin header in the request, i.e. it's matching the string "null" literally.

image

I don't know all that much about how CORS is implemented, but it's been a pain in my rear for several years now on various projects.

FWIW, I'm using a static html file. But I also tried running it on IIS Express. The error message in Chrome was similar except that it had from origin 'localhost:nnnn' has been blocked. But adding localhost:nnnn (I forget what port it was using) to the Maker API config didn't fix the problem.

I didn't investigate any further as I have no need to run my html file on a web server anyhow.

Does anyone currently have a reliable way to get by the CORS blocking? I've got the latest Firefox running in Windows and I'm seeing all of the same blocking meaages as other users. My goal was to write a tool entirely in javascript, HTML and CSS without the need to bring up a local web server