• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 749 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 Jul 25, 2021, 3:19 PM

    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 Jul 25, 2021, 3:23 PM Reply Quote 0
    • S Offline
      sdetweil @ferby09
      last edited by sdetweil Jul 25, 2021, 3:26 PM Jul 25, 2021, 3:23 PM

      @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 Jul 29, 2021, 5:05 PM Reply Quote 0
      • F Offline
        ferby09 @sdetweil
        last edited by ferby09 Jul 29, 2021, 5:06 PM Jul 29, 2021, 5:05 PM

        @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
        • 1 / 1
        1 / 1
        • First post
          1/3
          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