Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getcurrent position for insteon open/close blinds accessorie #20

Closed
xuncia opened this issue Sep 19, 2018 · 2 comments
Closed

getcurrent position for insteon open/close blinds accessorie #20

xuncia opened this issue Sep 19, 2018 · 2 comments

Comments

@xuncia
Copy link

xuncia commented Sep 19, 2018

Hello,
first of all I think this is the best plugin for blinds in homebridge.
Is simple, reliable and it works fine also in homekit app with iOS 12.
I was thinking about the "problem" of current status for insteon accessories.
And I wrote this piece of code to retrieve current status for insteon device.
In insteon devices status of a blinds is saved in a buffstatus.xml after the device is called with a request code 0x19.
example:
http://xxxxx:xxxxx@ip_address:25105/3?02623296C20F1900=I=3
in buff status you will find in BS tag element a string where in a position you will have FF is the blinds is open and 00 if the blinds is closed.
If someone has the time to take a look and give me some hints how to integrate in homebridge-blinds will be awesome, anywise thank you for the great job.
Standalone code is working fine, but I have some problem to integrate in this code.

var XMLHttpRequest = require('node-http-xhr');
var btoa = require('btoa');
var xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function() {
    if (this.readyState == 3 && this.status == 200) {
        myFunction(this);
    }
};
xhttp.open("GET", "http://ip_address:25105/buffstatus.xml", true);
xhttp.setRequestHeader("Authorization", "Basic " + btoa("xxx:xxxxxx"));
xhttp.withCredentials = true;
xhttp.send();

function myFunction(xml) {
    var xmlDoc = xml.responseText;
    console.log("risultato:" + xmlDoc.substring(52,54));
    if (xmlDoc.substring(52,54)== 'FF')
    {
        this.lastPosition= 1;
      
    }
}
@dxdc
Copy link
Owner

dxdc commented Nov 6, 2019

@xuncia See my changes here: #22

I think your idea could be integrated quite easily.

I'm wondering if something as simple as modifying the getCurrentPosition function would do it. Instead of sending this.lastPosition you could just amend this to the value you like. Also, see #14. If you make progress using this idea we can try to integrate it into the plugin.

BlindsHTTPAccessory.prototype.getCurrentPosition = function(callback) {
    if (this.verbose) {
        this.log(`Requested CurrentPosition: ${this.lastPosition}%`);
    }
    callback(null, this.lastPosition);
}

dxdc added a commit that referenced this issue Jan 7, 2020
@dxdc
Copy link
Owner

dxdc commented Jan 7, 2020

@xuncia. In the latest release, I've added a feature (position_url) which should accommodate this. I'm not sure how it would work with the polling frequency, but if you decide to revert to this plugin, I'd be happy to continue tuning it.

I'm going to close the issue for now.

@dxdc dxdc closed this as completed Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants