n8henrie / fauxmo

Emulated Belkin WeMo devices that work with the Amazon Echo
https://n8henrie.com/2016/02/fauxmo-home-automation-with-the-amazon-echo-raspberry-pi-and-homeassistant/
Other
376 stars 78 forks source link

How do i send on_data/off_data #97

Closed martinpetrov1096 closed 4 years ago

martinpetrov1096 commented 4 years ago

My Issue

I've spend like 3 hours trying to get a simple post request with x-www-form-data to pass with the simple http-plugin. I can't remember the last time I've been this frustrated.

How, how how do i need to input this data? Where can I find the response to my request? Why do i need to see so much debug text except for a response?

The settings are stored in a JSON file. So I try to find an example, but can't, so I just enter the what the raw format of the POST request should look like. After a couple hours, I find the pdf of the documentation that states that on_data is a dictionary. So I try to format it into JSON only to have the entire service refuse to start.

WHYT


Please make sure you've taken these steps before submitting a new issue:

n8henrie commented 4 years ago

I can't remember the last time I've been this frustrated.

Sorry to hear that.

How, how how do i need to input this data?

I don't know what x-www-form-data is, and you haven't provided enough information to clue me in.

Where can I find the response to my request?

In the verbose logs.

EDIT: Rereading, you're likely talking about the POST request, whose response is not logged. Looks like it would be reasonable to add a logger.debug(f"response_content: {response_content}") about here.

Why do i need to see so much debug text except for a response?

To see the things like the response to your request. You're welcome to increase or decrease the verbosity with the number of -v flags, as documented with fauxmo --help.

EDIT: As noted above, you're correct and the response you're interested is not logged.

So I try to find an example, but can't

There is a top-level sample config that has a POST example with SimpleHTTPPlugin. https://github.com/n8henrie/fauxmo/blob/master/config-sample.json

After a couple hours, I find the pdf of the documentation that states that on_data is a dictionary.

Sorry, I thought the documentation was reasonably visible: https://fauxmo.readthedocs.io/en/latest/fauxmo.plugins.html#fauxmo.plugins.simplehttpplugin.SimpleHTTPPlugin . The type of on_data is listed there as a Mapping.

So I try to format it into JSON only to have the entire service refuse to start.

You haven't included any logs or any of the requested data from the issue template, so I can't really help you here.

One thing to consider, as noted in the SimpleHTTPPlugin docs, you may have an easier time with RESTAPIPlugin For more complicated requests (e.g. authentication, sending JSON), check out RESTAPIPlugin in https://github.com/n8henrie/fauxmo-plugins/, which takes advantage of Requests’ rich API. https://github.com/n8henrie/fauxmo-plugins/blob/master/restapiplugin.py

Happy to try to help if you'll include the requested data from the template; I'll leave this open for a week or so pending response.

n8henrie commented 4 years ago

Please try the issue_97 branch, where I've tried to add response logging to the debug log.

Installing from a specific branch: https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch

n8henrie commented 4 years ago

Bump.

This issue is pending a response and is blocked until I have more info. To keep the issue list groomed, I will often close these stalled issues if they go a prolonged time without a response. In this case, I will give it another week or so.