Read the statement by Michael Teeuw here.
Simple display of API request; Here: SureFlap
-
Hello everyone,
I’m looking for a module template to display the response for a specific API call.
I’ve got a Petcare SureFlap and already set up a REST API for it.
link textI’m only trying to display the current location of my cat on the mirror. The look should be similar to MMM-FHEM.
The request url looks like that:
http://192.168.178.xxx:3001/households/xxxxxx/pets/xxxxxx/locationSo I’ll need the following config variables:
host
port
householdID
petID
updateInterval
Name of the pet as title because it isn’t included in this specific callThe response looks like this:
{"location":"Inside","pet_id":xxxxxx}The final module should display the pet’s name as title and the current location (preferrably with German translation) underneath it.
I hope that someone can point me in the right direction. I’ve already tried editing the existing MMM-FHEM because it looks just like what I want but I’m struggling with the extraction of values from the call.
-
@ferby09 is the response JSON text? if so,
var obj = JSON.parse(response_string)
to get an object.then obj.key has the value
obj.location in this case -
@sdetweil Yes, the response is JSON.
But a friend helped me doing a quick and dirty frontend workaround with XHR and css.
So this thread can be closed.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login