Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CQC HTTP Events?
#11
I found the HTTP-Trigger driver.

There's no documentation on it beyond the parameterized values explanation.

Does this use the default web server on port 80? [Pay attention during driver config... it's defined and changeable....]
What is the base URL it's reading from? [It accepts anything]

When I add a new trigger with a name it brings up the action editor?  I made cmd to write to a variable and it loads a "learning mode" which I'm guessing it's waiting for a request so it can check it?  I would think it would accept anything and paramaterize it and let those be chosen for use... maybe I'm too hopeful. [It's a simple 1:1 of mapping]

I have a EcoWitt GW1000 weather info receiver that sends a POST and it's in standard form-encoded format (var1=val&val2=val2) and I just want to get those values and stuff them into variables that get updated with the weather. [HTTP-Trigger won't work for this]

Instance two of use is I have Xeoma NVR and it sends a HTTP on motion start and motion end.  I want to get that for use like I do today.  This is a simple variable flip of true/false for motion. [Setup is now done]

I was hopeful the HTTP-Trigger would work but there's no information on how to use in the documentation and nothing in the forum searches I've tried.
Reply
#12
You tell it the port during installation. The URL is just training data. So you need to train it like you would a learning remote. So use something that can send the URL you want to that action to respond to and send it a few times fairly quickly. Once the driver has seen a consistent URL a few times I knows it has it right and it'll store that URL as the trigger for that action. Only the base part of the URL (ignoring the query parameters) is used as the trigger. That's what lets you send the same URL with different parameters and trigger the same command (which can then look at the incoming query parameters and act on them.)

Be careful of some browsers which send more stuff than the URL you send. They can send favorite icon queries and other stuff, which will confuse the training. Better to use some other sort of simple URL sending tool.
Dean Roddey
Explorans limites defectum
Reply
#13
(01-08-2020, 06:17 PM)Dean Roddey Wrote: You tell it the port during installation. The URL is just training data. So you need to train it like you would a learning remote. So use something that can send the URL you want to that action to respond to and send it a few times fairly quickly. Once the driver has seen a consistent URL a few times I knows it has it right and it'll store that URL as the trigger for that action. Only the base part of the URL (ignoring the query parameters) is used as the trigger. That's what lets you send the same URL with different parameters and trigger the same command (which can then look at the incoming query parameters and act on them.)

Be careful of some browsers which send more stuff than the URL you send. They can send favorite icon queries and other stuff, which will confuse the training. Better to use some other sort of simple URL sending tool.

I did some more snooping and did a reconfig on the driver just to refresh and I found the port info and such.  I edited my original post with info and findings.  

That's actually nice (once I figure it out) how to use the same base url with parameters to take different actions in the event rule.... I'll have to figure that out to work on more complex structures.  It may just be easier to write a little driver though.
Reply
#14
A CML driver cannot listen on a port. That's a privileged operation and it's ultimately kind of dangerous since it's an open entry into your system to make things happen. We provide that driver because a lot of folks use it, but CML drivers can only make outgoing connections, which is much more inherently safe.
Dean Roddey
Explorans limites defectum
Reply
#15
(01-09-2020, 09:23 AM)Dean Roddey Wrote: A CML driver cannot listen on a port. That's a privileged operation and it's ultimately kind of dangerous since it's an open entry into your system to make things happen. We provide that driver because a lot of folks use it, but CML drivers can only make outgoing connections, which is much more inherently safe.
Good to know.

What's the recommended or possible way of integrating something like this?  I have two systems that I use today that I would like to integrate.  One system sends a POST of standard form-encoded values.  The second system sends a POST with the body being JSON.

One is for the EcoWitt GW1000 and their display consoles for weather data from a local PWS.  The other is vehicle data and GPS location data sent from my Traccar server.
Reply
#16
You can always write a little windows service that does the listening and the driver connects to it I guess. Otherwise it has to be a C++ driver.

Or you could use a variables driver and have the trigger driver dump data into it from the incoming posts.
Dean Roddey
Explorans limites defectum
Reply
#17
(01-09-2020, 01:31 PM)Dean Roddey Wrote: You can always write a little windows service that does the listening and the driver connects to it I guess. Otherwise it has to be a C++ driver.

Or you could use a variables driver and have the trigger driver dump data into it from the incoming posts.

Here's how I have done it with other systems.  Can you help guide with how to do this with CQC?

HomeSeer plugins are already using the HS webserver and are available at http://<hs_server>/<plugin_name>/<plugin_page_xxx> with this I can have my own page that accepts the post or get and I can parse out the data and use it for the plugin

ISY Nodeserver I used the Python http.server to listen on a high port and accept a POST and then parse and hand the data off to the nodeserver.  The http server is running in user space and high port not requiring root permissions and the thread is run from the polyglot instance so I can pass my data around.

CQC already has a webserver running and possibly maybe use the HTTP-Trigger?  But the variables are not always the same of what comes from the HTTP POST as it is only sending what has changed/updated weather wise.  So there needs to be some degree of logic/validation to variables which maybe a macro?  I'm not sure.

I suppose I could still write a python service that sits and listens for the data, processes and then writes a file and CQC read and process the file?  Or I could process and push the data to MQTT and process it in CQC that way.  There's probably other ways to do this as well, but I need some guidance on clean normal way of doing this with CQC rather than a jumbled hack.
Reply
#18
If you used MQTT then that would probably give you the most flexibility with something outside of CQC. Data get published and CQC updates a field but it also (for example) turns a light on. This way if CQC fails, the automation still works. (I wish MQTT would become the defalt standard for IoT devices - life would be so simple and integrated)

I may be wrong, but thought the HTTP_Trigger accepted GET only - its been a long time since I looked so I could be wrong.
Mykel Koblenz
Illawarra Smart Home
Reply
#19
(01-09-2020, 03:00 PM)znelbok Wrote: If you used MQTT then that would probably give you the most flexibility with something outside of CQC.  Data get published and CQC updates a field but it also (for example) turns a light on.  This way if CQC fails, the automation still works.  (I wish MQTT would become the defalt standard for IoT devices - life would be so simple and integrated)

I may be wrong, but  thought the HTTP_Trigger accepted GET only - its been a long time since I looked so I could be wrong.

Actually I think you're right the HTTP-Trigger does only accept GET.  So that's not an option for the EcoWitt weather PWS integration.

Looks like I'll have to write a service that listens for the incoming data.  If that's the case I will add MQTT support to publish that so I can use it with anything else I want as well.
Reply
#20
You can write CML handlers for URLs on the web server of course. URLs of a particular form are mapped to CML macros.
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error trying to edit scheduled events George M 15 2,424 09-27-2020, 09:27 AM
Last Post: George M
  Get Field Value via HTTP znelbok 3 1,201 06-11-2020, 03:43 PM
Last Post: Dean Roddey
  HTTP Trigger and Parameters znelbok 1 938 06-11-2020, 03:41 PM
Last Post: Dean Roddey
  HTTP SendPUT simplextech 3 1,479 01-21-2020, 03:05 PM
Last Post: simplextech
  Set value via HTTP Call simplextech 2 1,203 01-07-2020, 04:39 PM
Last Post: simplextech
  Scheduled Events Caseta tom 18 6,189 12-22-2019, 07:06 AM
Last Post: Dean Roddey
  Editing Triggered Events Possibly Causing Kernel Panic/Crash gReatAutomation 6 2,693 11-08-2019, 01:10 PM
Last Post: Dean Roddey
  Possible Bug with Triggered Events gReatAutomation 3 1,567 09-19-2019, 02:41 PM
Last Post: gReatAutomation
  HTTP Trigger Driver - see trained URL's? Shaky 1 1,655 09-15-2019, 12:25 PM
Last Post: Dean Roddey
  Scheduled Events - Cannot find the specified path gReatAutomation 4 1,602 08-16-2019, 12:21 PM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)