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

Ability to specify percentage? #120

Closed skorokithakis closed 11 months ago

skorokithakis commented 11 months ago

Is it possible to specify a percentage? As far as I know, the protocol allows you to set the device to "x%", but this is not exposed in this package. It would be pretty handy, as then I'd be able to set my lights to a percentage, rather than on-off, and I would also be able to hack it so I set my thermostat to "23%" (actually 23 degrees) too.

jdodgen commented 11 months ago

As it is implemented fauxmo only supports "on and "off" Depending on the plugin you are using you could create wemo names that have the percentage in the names like "Bedroom light twenty" "Bedroom light one hundred"

skorokithakis commented 11 months ago

Would it be a lot of work to implement percentages? I'm not too familiar with the protocol, but I could take a stab at it, if you could point me to how the protocol itself implements the value setting.

jdodgen commented 11 months ago

The problem I see is with the wemo protocol only sending "on" or "off" and I do not know of a way to have wemo include a percentage or other values. @n8henrie made a nice writeup about what he learned about how wemo works protocol_notes.md

skorokithakis commented 11 months ago

Other projects support values, so it's definitely doable. I'll look at the other codebases and see, thanks!

n8henrie commented 11 months ago

No promises but this seems worth looking into.

FWIW, some of the other projects have diverged from using the Wemo protocol -- I don't recall what brand off the top of my head, but there is a similar protocol that can be used that has some extra options.

skorokithakis commented 11 months ago

Oh hm, hopefully that's not it, but I'll check it out and report back.

n8henrie commented 11 months ago

Here's a relevant commit, in which the fauxmoESP project went from emulating Wemo to emulating Hue, which his how that project supported brightness controls:

https://github.com/vintlabs/fauxmoESP/commit/e53150265c5c51de89f69f1a95ca7b7af285811c

Unfortunately, it looks like hue support requires listening on port 80: https://github.com/vintlabs/fauxmoESP/blob/8abe4a937bfc49e0578017d9a257d38d5f28e888/README.md?plain=1#L128, which I really don't care for, as this will require elevated permissions.

HomeAssistant also has built-in support for similar purposes, if users are already using hass and fine with using port 80: https://www.home-assistant.io/integrations/emulated_hue/

If you find out that elevated permissions (e.g. port 80) is not a requirement or that wemo can also accomplish this please let me know! But I think I'm going to close this in the meantime as I'm not confident that it's possible.

skorokithakis commented 11 months ago

You can do this without elevated permissions with setcap, and it's encouraging that it is possible. I might have a go at it just for the people who don't mind setcap (and can spare port 80), I think it will be a valuable addition. What do you think, @n8henrie?

n8henrie commented 11 months ago

Yes, I'm familiar with setcap (see https://github.com/n8henrie/rf_pi) -- you cannot use setcap without elevated permissions. Additionally, my fauxmo server requires port 80 for other uses, so I wouldn't be interested in this as a replacement for the current system. I would consider if it were in addition, but I would hope not to have to double the code maintenance (hopefully there would be a considerable amount of code reuse).

EDIT: I hope that makes sense. Happy to clarify otherwise. IOW I would consider it as a PR if fauxmo could continue to use an unprivileged port.