Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. English
    3. ioBroker general
    4. Simple API Use SOLVED

    NEWS

    • Monatsrückblick - April 2025

    • Minor js-controller 7.0.7 Update in latest repo

    • Save The Date: ioBroker@Smart Living Forum Solingen, 14.06.

    Simple API Use SOLVED

    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      ap2017 last edited by ap2017

      I would like to get motion notification from MotionEye via Simple Api using method GET
      http: // IP_ioBroker: 8087/ set / javascript.0.Pi-detection? Value = true
      I added Pi-detection user.data.0 Boolean variable. Is there special setting needed for Simple APi adapter?

      efede08a-c2bd-4e7e-bb7f-b9af09c07367-image.png

      UncleSam 1 Reply Last reply Reply Quote 0
      • UncleSam
        UncleSam Developer @ap2017 last edited by UncleSam

        @ap2017 What are you trying to do and what is your issue?

        The URL you are providing contains a lot of spaces (which is wrong).

        Also you say user.data.0 (which doesn't exist) and then try to use javascript.0. IDs must match exactly the IDs in ioBroker. Simply use the "copy" button next to the state ID to get the full ID in the correct format.

        A 1 Reply Last reply Reply Quote 0
        • A
          ap2017 @UncleSam last edited by

          @UncleSam Thank you for quick response and good comments. My actual URL does not have extra spaces:
          http://iobrokerIP:8087/set/javascript.0.Pi-detection?Value=true

          I created PI-detection variable in javascript.0 folder and monitoring value of this variable in response to motion detection from MotionEye, but so far I am getting nothing. My MotionEye Web Hook URL is http://iobrokerIP:8087/set/javascript.0.Pi-detection?Value=true with HTTP method set as GET

          paul53 UncleSam 2 Replies Last reply Reply Quote 0
          • paul53
            paul53 @ap2017 last edited by paul53

            @ap2017
            Link is wrong (Value --> value).
            http://iobrokerip:8087/set/javascript.0.Pi-detection?value=true

            1 Reply Last reply Reply Quote 1
            • UncleSam
              UncleSam Developer @ap2017 last edited by

              @ap2017 Thanks for the clarifications.

              What happens if you open the URL in your browser? Do you get a JSON response similar to the following or an error message?

              {"id":"javascript.0.Pi-detection","value":true}
              

              How do you know that you are "getting nothing"?

              A 1 Reply Last reply Reply Quote 0
              • A
                ap2017 @UncleSam last edited by

                @UncleSam In browser I am getting error message
                "error: datapoint "javascript.0.Pi-detection" not found"
                I monitor variable PI-detection as Boolean widget in VIS

                UncleSam 1 Reply Last reply Reply Quote 0
                • UncleSam
                  UncleSam Developer @ap2017 last edited by

                  @ap2017 Can you please share a screenshot of your object tree in ioBroker where we can see the mentioned state (and its parents)?

                  A 1 Reply Last reply Reply Quote 0
                  • A
                    ap2017 @UncleSam last edited by

                    @UncleSam Here the screenshot. Do I need to have subfolder variables in my URL?

                    478101c6-03ea-4770-aca9-b414a5870a93-image.png

                    paul53 UncleSam 2 Replies Last reply Reply Quote 0
                    • paul53
                      paul53 @ap2017 last edited by paul53

                      @ap2017
                      URL: http://iobrokerip:8087/set/javascript.0.variables.PI-detection?value=true

                      1 Reply Last reply Reply Quote 0
                      • UncleSam
                        UncleSam Developer @ap2017 last edited by

                        @ap2017 So, did you copy the state ID the way I asked you to?

                        Because it seems to me that the name should be javascript.0.variables.PI-detection

                        A 2 Replies Last reply Reply Quote 0
                        • A
                          ap2017 @UncleSam last edited by ap2017

                          @UncleSam Thank you, with subfolder "variables" added I am getting browser response
                          {"id":"javascript.0.variables.PI-detection","value":true,"val":true}

                          Now I need to figure out how MotionEye notification work, since I PI-detection does not change in response to motion

                          1 Reply Last reply Reply Quote 0
                          • A
                            ap2017 @UncleSam last edited by

                            @UncleSam Everything works now. I did not realized that I have to reset the web hook variable after motion is detected.

                            T 1 Reply Last reply Reply Quote 1
                            • T
                              tehMilcho @ap2017 last edited by

                              Hey there,

                              i got the same Error but little different problem. I have copyed the Object-Path with the little button.

                              so i build this URL:
                              http://SERVER:8087/set/0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1?value=false&prettyPrint

                              The Url works fine in any browser but when i try to use it in my code i get:

                              "error: no value found for "0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1". Use /set/id?value=1 or /set/id?value=1&wait=1000"

                              I will use it in a Lua Script that runs on the "Fibaro Home center lite". When i rebuild the URL to "toggle" it works fine.. i have no clue whats the issue .. because it makes no sense for me.

                              Lua Code:

                              local value = fibaro.getValue(52, "value")
                              local url
                              
                              -- Deside if value should be true or false
                              if (fibaro.getValue(52, "value") == true) then
                              url = 'http://SERVER:8087/set/0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1?value=true&prettyPrint'
                              elseif (fibaro.getValue(52, "value") == false) then
                              url = 'SERVER/set/0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1?value=false&prettyPrint'
                              else 
                              print ("No Match")
                              end
                              
                              print(url)
                              
                              local selfhttp = net.HTTPClient()
                              
                              local headers = {
                                      ["Accept"] = "application/json",
                                      ["Content-Type"] = 'application/json',
                                      ["Cache-Control"] = "no-cache"
                                  }
                              
                              selfhttp:request(url, {
                                options={
                                  method = 'GET',
                                  headers = headers,
                                  timeout = 5000
                                },
                               success = function(response) 
                                          print(response.status)
                                          print(response.data)
                                  end,
                                  error = function(message)
                                          print("error:", message)
                                  end
                              })
                               
                              

                              anyone knows something? i think i had the same issue by try to use something like this in Android App - Tasker, but then give out and used toggle.

                              1 Reply Last reply Reply Quote 0
                              • M
                                MCU last edited by

                                @tehmilcho sagte in Simple API Use SOLVED:

                                http://SERVER:8087/set/0_userdata.0.VirtualDevices.hc3lite.FlurPIR-1?value=true&prettyPrint

                                Try to encode the URL

                                let encodedUrl = encodeURIComponent(url);
                                
                                T 1 Reply Last reply Reply Quote 0
                                • T
                                  tehMilcho @MCU last edited by

                                  @mcu said in Simple API Use SOLVED:

                                  let encodedUrl = encodeURIComponent(url);

                                  the Lua Script in Fibaro seems not happy about it:

                                  [24.11.2023] [22:43:48] [ERROR] [SCENE29]: (load):15: syntax error near 'encodedUrl

                                  M 1 Reply Last reply Reply Quote 0
                                  • M
                                    MCU @tehMilcho last edited by

                                    @tehmilcho In LUA seems to be

                                    local encodedUrl = url.escape(url)
                                    
                                    T 1 Reply Last reply Reply Quote 0
                                    • T
                                      tehMilcho @MCU last edited by

                                      @mcu said in Simple API Use SOLVED:

                                      local encodedUrl = url.escape(url)

                                      mhh seems like fibaro specail lua?

                                      [24.11.2023] [22:54:25] [ERROR] [SCENE29]: (load):23: attempt to call a nil value (field 'escape')

                                      M 1 Reply Last reply Reply Quote 0
                                      • M
                                        MCU @tehMilcho last edited by

                                        @tehmilcho Do you use it so?

                                        url = url.escape(url)
                                        
                                        selfhttp:request(url, {
                                          options={
                                            method = 'GET',
                                            headers = headers,
                                            timeout = 5000
                                          },
                                          success = function(response) 
                                            print(response.status)
                                            print(response.data)
                                          end,
                                          error = function(message)
                                            print("error:", message)
                                          end
                                        })
                                        
                                        T 1 Reply Last reply Reply Quote 0
                                        • T
                                          tehMilcho @MCU last edited by

                                          @mcu yep this leads to "[24.11.2023] [22:54:25] [ERROR] [SCENE29]: (load):23: attempt to call a nil value (field 'escape')"

                                          M 1 Reply Last reply Reply Quote 0
                                          • M
                                            MCU @tehMilcho last edited by

                                            @tehmilcho sagte in Simple API Use SOLVED:

                                            :23: attempt to call a nil value (field 'escape')

                                            Try this

                                            url = url:gsub("([^A-Za-z0-9_])", function(c) return string.format("%%%02X", string.byte(c)) end)
                                            
                                            T 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            681
                                            Online

                                            31.6k
                                            Users

                                            79.4k
                                            Topics

                                            1.3m
                                            Posts

                                            api simple api
                                            5
                                            22
                                            2618
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo