MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Simple display of API request; Here: SureFlap

    Scheduled Pinned Locked Moved Requests
    3 Posts 2 Posters 1.0k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F Offline
      ferby09
      last edited by

      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 text

      I’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/location
      

      So 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 call

      The 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.

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @ferby09
        last edited by sdetweil

        @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

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        F 1 Reply Last reply Reply Quote 0
        • F Offline
          ferby09 @sdetweil
          last edited by ferby09

          @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.

          1 Reply Last reply Reply Quote 0

          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
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy