Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Domoticz
  4. How do I send a REST command?

How do I send a REST command?

Scheduled Pinned Locked Moved Domoticz
4 Posts 3 Posters 4.3k Views 1 Watching
  • 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.
  • Cliff KarlssonC Offline
    Cliff KarlssonC Offline
    Cliff Karlsson
    wrote on last edited by
    #1

    Hi I just managed to integrate my first mysensors.org switch into domoticz. If I flick the switch it gets updated correctly in domotiz, and now I want to send a REST command witch look like this whenever the switch is switched:

    "PUT 192.168.0.22:4455/devices/{udn} The body should be "application/json" as {"STATE": true } "

    How do I do this? I guess i need to write a script somehow and place it in the right folder and then specifying it under the switch options.

    But I have no idea of how to write a script for this.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qu3Uk
      wrote on last edited by
      #2

      An example of using the Domoticz api over http would be http://192.168.0.22:4455/json.htm?type=command&param=switchlight&idx=99&switchcmd=On

      Not sure where you got your info from but the API is detailed here.
      Domoticz API

      1 Reply Last reply
      0
      • Cliff KarlssonC Offline
        Cliff KarlssonC Offline
        Cliff Karlsson
        wrote on last edited by
        #3

        But will that send a PUT command? And where do I enter the body info:{"STATE": true }

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pjr
          wrote on last edited by pjr
          #4

          What are you trying to archieve with this? What is the receiving end?

          I think you can send your "ajax call" from lua script with os.execute method using curl if you are in linux enviroment.

          commandArray = {}
          if (devicechanged['NameOfYourSwitch'] == 'On') then
            os.execute('/usr/bin/curl -X PUT -d STATE=true 192.168.0.22:4455/devices/{udn}')
          else if(devicechanged['NameOfYourSwitch'] == 'Off') then
            os.execute('/usr/bin/curl -X PUT -d STATE=false 192.168.0.22:4455/devices/{udn}')
          end
          return commandArray
          

          And give it a name with prefix: script_device_xxxxxxx.lua where xxxxxxx is name for your script. Then domoticz will launch it everytime some device state changes. Location for it is script/lua under your domoticz folder.

          1 Reply Last reply
          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
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          26

          Online

          12.0k

          Users

          11.2k

          Topics

          113.4k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular