n8henrie/fauxmo

How do i send on_data/off_data

Closed this issue · 3 comments

  • Issues not following the template may be closed for that reason alone.
  • Operating system and version:
  • Python version:
  • Fauxmo version (fauxmo --version):
  • Echo device type (e.g. Echo, Echo Plus, Dot):
  • Echo Firmware Version:

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:

  • Try to reproduce the issue with Fauxmo installed in a
    venv
  • Ensure you're running a supported version of Python
    • Requires Python >= 3.2 for Fauxmo < 0.3.0
    • Requires Python >= 3.4.4 for Fauxmo >= 0.3.0
    • Requires Python >= 3.6.0 for Fauxmo >= 0.4.0
  • Run Fauxmo in debug mode (-vvv) and include relevant output
  • Include your Fauxmo config.json
  • Search the existing (including closed) issues
  • Please use codeblocks around your debug output and config

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.

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

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.