dxdc / homebridge-blinds

:sunrise: Homebridge Plugin to control my blinds over HTTP
https://www.npmjs.com/package/homebridge-blinds
ISC License
54 stars 25 forks source link

Externally set position #30

Closed peros550 closed 4 years ago

peros550 commented 4 years ago

@zwerch , with your nice and helpful plugin I have my window electric shutters controlled under homekit! With your recent updates the plugin has greatly been improved and after extended testing I have no issues at all.

I have one question though and wanted to discuss with you. My shades are controlled by homekit, by wall switches and by remotes. If I control the shades by any other mean than homekit, your plugin gets out of sync, meaning the plugin may report wrong position/state in homekit and that's expected because it can't be aware of what's happening in the rest system.

I was thinking how could we overcome this situation.

One idea would be to use wireless contact sensors. With the help of those sensors, we could retrieve shutter position.

But the question then would be, how could we set the position manually? Perhaps if your plugin exposed an web server and allowed to receive http calls, it would be possible.

Thank you

dxdc commented 4 years ago

But the question then would be, how could we set the position manually? Perhaps if your plugin exposed an web server and allowed to receive http calls, it would be possible.

@peros550 This is already part of the feature set. Please see the description on position_url in the settings. That being said, it's a "permanent" link, not a temporary override. If a temporary override is needed, it's a feature we could discuss/look into.

If you want to go for this, you could look into Tasmota support for blinds/shutters, which has some nice options. According to the discussion here #29 the next release of Tasmota should fully support these kinds of features.

There are several other ways in which you could accomplish this goal though.

Daily "reset" of the blinds

Using HomeKit Automation, send the blinds a command (down/up) at some time each day. This way, no matter what the blinds think the position is, it will "reset" it if someone has manually intervened with the remote.

Fully automated blinds

Design automation rules, either within HomeKit (or using Node-RED), that trigger the blinds to go up/down based on your preferences/weather/occupancy/etc. Now, there's never a need to use the remote and it won't get out of sync.

Get rid of your current remote and replace it with an alternate way to trigger via a HomeKit button

Possible "triggers":

  1. Purchase an Rf-capable button (e.g., doorbell) that is supported by rtl_433. Use RTL-SDR and rtl_433 to retrieve data and send it to MQTT server.

  2. (More advanced)... build support for your existing remote control into rtl_433 with the above command. Now, it will know which button was pressed.

  3. Purchase a wifi "Button" which can send data to MQTT server. Tasmota is a handy tool for this.

Receiving the "trigger":

Using Node-RED, parse the input from the the MQTT server, and relay the correct command to the blinds tile using node-red-contrib-homebridge-automation.

peros550 commented 4 years ago

@dxdc thank you for your suggestions. I may haven't made my point clear. I simply need a way to set the plugin's internal position but without the plugin issuing the http command. Is this possible with the current feature set?

dxdc commented 4 years ago

@peros550 Are you referring to this?

That being said, it's a "permanent" link, not a temporary override. If a temporary override is needed, it's a feature we could discuss/look into.

In other words, to issue a HTTP webhook to manually update (on a one-time basis) the internal position? This could also be done via MQTT.

peros550 commented 4 years ago

I'm afraid it's still not clear to me. If you could you provide an example of using http webhook to manual update position, it would help me a lot?

Many thanks :)

dxdc commented 4 years ago

For ex.

http://1.2.3.4/blinds1/update?pos=30

I simply need a way to set the plugin's internal position but without the plugin issuing the http command. Is this possible with the current feature set?

How did you want to accomplish this? For example, one other idea would be to create another accessory within the same blinds that would allow you to manually reset the position I suppose.

peros550 commented 4 years ago

The above example shows the plugin requesting exact position by making a http call.

What's I'm proposing is the opposite. The plugin to receive the exact position via http call and just update its internal position (and home app position) without issuing any http call to the actual device.

For example, it could work if the plugin listened for http calls like the following

http://ip-address-hombridge:[some port]/blinds1/update?pos=30

dxdc commented 4 years ago

The above example shows the plugin requesting exact position by making a http call.

No, we're talking about the same thing. If it was requesting the exact position, it wouldn't make sense to use pos=30 at the end. It's only because it is sending the position to use.

This is an HTTP webhook to update the position.

So, to be clear, you want to periodically update the position using a built-in webhook correct?

peros550 commented 4 years ago

In your example above 1.2.3.4 is supposed to be homebridge IP address?

dxdc commented 4 years ago

In your example above 1.2.3.4 is supposed to be homebridge IP address?

Yes. It's just a general IP

peros550 commented 4 years ago

Is it already implemented and I missed it or no ?

dxdc commented 4 years ago

It's not implemented.

That being said, it's a "permanent" link, not a temporary override. If a temporary override is needed, it's a feature we could discuss/look into.

This is a "temporary" override via webhook that we are dicsussing.

dxdc commented 4 years ago

@peros550 There is a working implementation now of this feature.

The simplest way to try it is to add webhook_port to the config.json as follows. There are some issues with self-signed HTTPS certificates at the moment, but you can implement your own HTTPS certificates and/or skip HTTPS support entirely. See the README for details.

"webhook_port": 51828,

Then, you can update the position as follows: http://homebridgeip:51818/?pos=30

I tried to account for this feature both when the blinds were moving and when they were not, but it will be most stable of course if the blinds are stationary. If you have any issues please let me know but closing this for now.

dxdc commented 4 years ago

(Also, remember to install the new version and then restart homebridge:)

  1. sudo npm -g install homebridge-blinds
  2. restart homebridge
peros550 commented 4 years ago

@dxdc I hope you are doing well during these challenging times.

Better late than never, I wanted to thank you. I just had the chance to test this implementation and it works great. Many thanks it is really much appreciated.

And one question: On your first page I saw: "Receiving specific position (optional, one-time basis)"

what's the point of one-time basis?

dxdc commented 4 years ago

Better late than never, I wanted to thank you. I just had the chance to test this implementation and it works great.

Fantastic. And, you're quite welcome.

what's the point of one-time basis?

Probably just a naming convention difference. I've updated it to "ad hoc". The idea is that it's not truly "linked" but can be updated by the user when they want.