INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Some webinterface questions  (Read 8584 times)

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Some webinterface questions
« on: July 26, 2016, 02:21:51 pm »

I have a few questions about the webinteface, and the webcommands, I am trying to control a switch with commands (info about the switch posted at the bottom):

I read the documentation, and tried the command: http://localhost:52125/api/v1/nodes/5 just to get info about the node, but i get the message that there is no node number 5. And it wasn't entirely clear to me what the command for setting the switch "on" was, there is an example int he wiki, but the structure seems to be a bit different (http://localhost:52110/alpha000/basic_set?node=2,value=100)

A related question, the switching stuff on and off seems to work fine in engen, but is there no function to receive commands from a button at this time? And/or do something in response to the command?




{
    "status": {
        "query": {
            "success": 99.71298810583478,
            "ack": 0.9630729615077083,
            "query": 36.003808549643566,
            "reply": 25.666855401830784,
            "response": 8.565422479379093,
            "wait": 0.00017372885839229857
        },
        "cmd": {
            "busy": 0.0,
            "success": 99.71529494033922,
            "nak": 0.2790420885850588,
            "route": 0.0,
            "fail_count": 0,
            "send_time": 1469560411.822,
            "fail": 0.0,
            "response_time": 0.026000022888183594
        },
        "mfg_spec": {
            "request_time": 1469558351.651,
            "request_count": 0
        },
        "basic": {
            "request_time": 1469560411.858,
            "request_count": 0
        }
    },
    "prod_id_type": 1536,
    "cap": 83,
    "listening": true,
    "basic": {
        "value": 100
    },
    "wstatus": 2,
    "prod_id": 4096,
    "name": "strombryter",
    "mfg_id": 271,
    "gmark": true,
    "cmdclasses": [
        "manufacturer_specific",
        "version",
        "configuration",
        "association",
        "multi_instance_association",
        "switch_binary",
        "powerlevel",
        "meter",
        "sensor_multilevel",
        "firmware_update_md",
        "mark",
        "switch_binary",
        "meter",
        "sensor_multilevel"
    ],
    "address": [
        0,
        5,
        0
    ],
    "sensor250": false,
    "security": 28,
    "sensor1000": false
}
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72439
  • Where did I put my teeth?
Re: Some webinterface questions
« Reply #1 on: July 27, 2016, 02:42:32 am »

Sorry, but I don't know.  linutic is out for a couple of days, too.

In the terminal window,  type "help" to get to the documentation for it.

It's possible that the docs don't match the program because of changes.

I tried what you were trying and couldn't get it to work.

I assume you're using build 19.

In email last night, Gene (linutic) said this about the next build:

"New in this build are REST APIs to configure zwave button controllers so they can send commands to zwave devices and directly control them using zwave scenes.   Some time ago, I was hoping this might be a big part of our lighting configuration.  Unfortunately about 35% of light switches do not support scenes.  This includes the GE/Jasco switches which are very popular, and I think the ones that Jim is using.  All of them have significant bugs."
Logged

keenan

  • Regular Member
  • Recent member
  • *
  • Posts: 11
Re: Some webinterface questions
« Reply #2 on: July 27, 2016, 10:40:59 am »

There is a fix for the issue you describe awaiting a build - I think we will get one out today. Currently retrieving specific node information is broken, but you can still access /api/v1/nodes. Sending node updates is functioning, but not documented.

The v1 API does has a very different syntax than alpha000. While alpha000 only uses GET methods, v1 takes advantage of the different traditional HTTP methods. Right now we do not have any documentation because it is changing so dramatically build after build, but I can give a working current example:

Set a dimmer/multi-level capable device to 50 (any value from 0 to 99):

Code: [Select]
PATCH /api/v1/nodes/5

{"value": 50}
Code: [Select]
$ curl --request PATCH --data '{"value": 50}' --header "Content-Type: application/json" localhost:52125/api/v1/nodes/5


Set an RGB bulb's color:

Code: [Select]
PATCH /api/v1/nodes/5

{
  "color": {
    "red": 150,
    "blue": 255,
    "green": 50
  }
}
Code: [Select]
$ curl --request PATCH --data '{"color": {"red": 150, "blue": 255, "green": 50}' --header "Content-Type: application/json" localhost:52125/api/v1/nodes/5

There is no way to receive commands/updates from devices at this time (like a button, a sensor, etc). We plan to get to this soon, along with events, schedules and more.
Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Re: Some webinterface questions
« Reply #3 on: August 04, 2016, 04:42:45 pm »

Getting the node information works now, but i am not too familiar with this REST-system, so sorry for my simple question, but how do I use a patch command via just a http_address in the browser, can i for instance turn on a switch by sending a properly formatted address to the browser?
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4226
Re: Some webinterface questions
« Reply #4 on: August 04, 2016, 05:23:22 pm »

how do I use a patch command via just a http_address in the browser,
you don't, browsers (AFAIK) only support GET and POST directly. Why would you want to though? how do you intend to trigger a command like that? it's presumably as a result of some other event (whether a key press or a reaction to some other event) and hence you will be executing a script of some description won't you?
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72439
  • Where did I put my teeth?
Re: Some webinterface questions
« Reply #5 on: August 05, 2016, 12:44:34 am »

On the Lighting page of Panel, click on "Documentation" on the left side.  It gives you some guidance.  I'm not sure it's all hooked up yet.
Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Re: Some webinterface questions
« Reply #6 on: August 05, 2016, 03:34:48 am »

you don't, browsers (AFAIK) only support GET and POST directly. Why would you want to though? how do you intend to trigger a command like that? it's presumably as a result of some other event (whether a key press or a reaction to some other event) and hence you will be executing a script of some description won't you?

The reason for using a browser (or actually, not using a browser per se, but using just a simple "URL"), is that just sending a http-address like this is supported by a lot of different products. For instance, I have a small server with its own custom OS to control the rest of the appliances in my home, this custom mini-os can send http-commands. If you can turn on a switch with a single properly formatted address, it makes it much easier to integrate with other systems.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72439
  • Where did I put my teeth?
Re: Some webinterface questions
« Reply #7 on: August 05, 2016, 04:27:40 am »

By trial and error, I think I came close with this:
http://localhost:52125/api/v1/node?name=8&value=99

I don't have time to do more now, but I'll try later, and I've asked Gene to comment. 
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4226
Re: Some webinterface questions
« Reply #8 on: August 05, 2016, 05:12:15 am »

The reason for using a browser (or actually, not using a browser per se, but using just a simple "URL"), is that just sending a http-address like this is supported by a lot of different products. For instance, I have small server with its own custom OS to control the rest of the appliances in my home, this custom mini-os can send http-commands. If you can turn on a switch with a single properly formatted address, it makes it much easier to integrate with other systems.
I don't follow. You can send a PATCH with a single properly formatted command using something like curl, just not via a browser. There's an example higher up in the thread.

Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Re: Some webinterface questions
« Reply #9 on: August 05, 2016, 05:18:15 am »

I don't follow. You can send a PATCH with a single properly formatted command using something like curl, just not via a browser. There's an example higher up in the thread.



I am not very skilled in matters like this, so I might have misunderstood. But curl is something you need a computer with a "regular OS" to do right? I don't want to send the command via a computer (although it is possible in a roundabout way to go via a computer), I want to send it directly from one of the many products with specialized software, that can send a webcommand (in my instance this: http://www.loxone.com/enen/products/miniserver/miniserver.html).
Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Re: Some webinterface questions
« Reply #10 on: August 05, 2016, 05:18:49 am »

By trial and error, I think I came close with this:
http://localhost:52125/api/v1/node?name=8&value=99

I don't have time to do more now, but I'll try later, and I've asked Gene to comment. 

Thanks, I will try commands on that format :)
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4226
Re: Some webinterface questions
« Reply #11 on: August 05, 2016, 07:50:11 am »

I am not very skilled in matters like this, so I might have misunderstood. But curl is something you need a computer with a "regular OS" to do right? I don't want to send the command via a computer (although it is possible in a roundabout way to go via a computer), I want to send it directly from one of the many products with specialized software, that can send a webcommand (in my instance this: http://www.loxone.com/enen/products/miniserver/miniserver.html).
you might be able to do it using http://www.loxone.com/enen/service/documentation/loxone-config/global-functions/virtual-io.html

I think the docs assume you have the app in front of you but the virtual UDP output connector has options around which HTTP method to use. Alternatively I guess you ask their support, an inability to talk to some arbitrary http based api would be an odd gap in the feature set of a product like that.
Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Re: Some webinterface questions
« Reply #12 on: August 05, 2016, 10:20:48 am »

you might be able to do it using http://www.loxone.com/enen/service/documentation/loxone-config/global-functions/virtual-io.html

I think the docs assume you have the app in front of you but the virtual UDP output connector has options around which HTTP method to use. Alternatively I guess you ask their support, an inability to talk to some arbitrary http based api would be an odd gap in the feature set of a product like that.

I can send web-commands via that server, and with other products. But it needs a command send/web-address to use, right? (for example one of the type Jim posted)
Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Re: Some webinterface questions
« Reply #13 on: August 05, 2016, 10:49:21 am »

By trial and error, I think I came close with this:
http://localhost:52125/api/v1/node?name=8&value=99

I don't have time to do more now, but I'll try later, and I've asked Gene to comment. 

I wasn't able to get commands on that form to function (provided i didn't misunderstand anything) "No endpoint found for the path provided."
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4226
Re: Some webinterface questions
« Reply #14 on: August 05, 2016, 11:46:48 am »

I can send web-commands via that server, and with other products. But it needs a command send/web-address to use, right? (for example one of the type Jim posted)

what Jim posted and what Keenan posted are both HTTP requests

http://localhost:52125/api/v1/node?name=8&value=99 is an HTTP GET to localhost:52125/api/v1/node with 2 parameters (name=8 and value=99)

whereas

Code: [Select]
curl --request PATCH --data '{"value": 50}' --header "Content-Type: application/json" localhost:52125/api/v1/nodes/5

is an HTTP PATCH to localhost:52125/api/v1/nodes/5 and the data being PATCHed is a bit of json (a PATCH is like a PUT except PATCH is intended to overwrite a bit of existing data where a PUT is intended to create a new thing)

a developer could choose to implement that particular PATCH request as a GET like http://localhost:52125/api/v1/nodes/5?value=50 but then it wouldn't really be a RESTful interface (and parameters are just a load of key/value pairs which is less flexible/descriptive than accepting some json)

Logged

linutic

  • Recent member
  • *
  • Posts: 33
Re: Some webinterface questions
« Reply #15 on: August 05, 2016, 02:35:12 pm »

I've verified the problems described in this chain, plus a bunch of other unreported but related problems.   We've made some changes that broke a bunch of things in the old web interface, and failed to notice it.   I'm personally very embarrassed about this.   Fixing these problems is now my highest priority.

I'm planning to make the interface solid again for the next build, probably Monday.

Thanks much for your bug reports and your patience.

Gene
Logged

linutic

  • Recent member
  • *
  • Posts: 33
Re: Some webinterface questions
« Reply #16 on: August 05, 2016, 06:44:39 pm »

A related question, the switching stuff on and off seems to work fine in engen, but is there no function to receive commands from a button at this time? And/or do something in response to the command?

We've been working on talking to button controllers.   Not sure why, but only a few manufacturer's are making something useful.   The two we have had success with are the Enerwave wall controller and the Aeon Minimote.   There are some very inexpensive GE/Jasco controllers, but they are too narrowly focused on non-intelligent systems to be much use.   We can probably get the Aeon key fob and the Aeon panic button to work, but we haven't got there yet.

There are some very clever hacks out there using Amazon Dash buttons, but these are all cloud-connected hacks.  We'd like to build a system that is reliable when the Internet goes down.....

http://www.dashbuttondudes.com/blog/2015/12/11/26-amazon-dash-button-hacks

Right now we don't have a roadmap to integrate Z-wave button controllers into Engen.  Obviously they can be used with groups/scenes.   How would you like to use them?
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72439
  • Where did I put my teeth?
Re: Some webinterface questions
« Reply #17 on: August 06, 2016, 01:01:17 am »

I hope we'll be able to add some of the lighting controls to Theater View this year.
Logged

keenan

  • Regular Member
  • Recent member
  • *
  • Posts: 11
Re: Some webinterface questions
« Reply #18 on: August 08, 2016, 01:38:28 pm »

Now since the alpha000 api is fixed, you can now always refer to http://localhost:52125/alpha000 to see examples of basic GET commands.

For more complex ones and if you are familiar with using different HTTP methods, http://localhost:52125/docs can be helpful.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72439
  • Where did I put my teeth?
Re: Some webinterface questions
« Reply #19 on: September 25, 2016, 07:47:37 am »

I wasn't able to get commands on that form to function (provided i didn't misunderstand anything) "No endpoint found for the path provided."
Were you able to get this working after the fixes linutic made?
Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Re: Some webinterface questions
« Reply #20 on: September 28, 2016, 03:08:01 pm »

Were you able to get this working after the fixes linutic made?

Yes, I have been off the grid a little while, but I am back now. Engen at first didn't work (due to trial being over), but I bought a license and upgraded to the newest versions, and the get commands seem to work fine now when using the commands in the doc.

I am still struggling a bit though, but I think that is due to my own incompetence. Using GET commands is very easy, you just access the page through a browser, but what is the easiest way to send a PATCH-command to the webinterface? And the home-control-server I already have supports sending commands, but only GET, POST, PUT, DELETE. Is that solvable?

And according to the changelog receiving commands from buttons/sensors should now be possible, right?



Logged

linutic

  • Recent member
  • *
  • Posts: 33
Re: Some webinterface questions
« Reply #21 on: October 06, 2016, 04:02:42 pm »

I am still struggling a bit though, but I think that is due to my own incompetence. Using GET commands is very easy, you just access the page through a browser, but what is the easiest way to send a PATCH-command to the webinterface? And the home-control-server I already have supports sending commands, but only GET, POST, PUT, DELETE. Is that solvable?

Thanks for bringing this to our attention.  Perhaps we are a little ahead of the curve in using PATCH instead of POST when modifying variables.   PATCH has the benefit of clearly indicating an update operation, while POST can be used to do most anything at all.  PATCH is more specific, but POST is more compatible.  Your experience indicates the compatibility is most important here.  We will switch from using PATCH to POST everywhere for the next release of Engen.   PATCH will still work, but the documentation will now say to use POST.
Logged
Pages: [1]   Go Up