Giter VIP home page Giter VIP logo

Comments (17)

rthewhite avatar rthewhite commented on July 17, 2024

Sorry for the late reaction, have been very busy last couples of days/weeks. I don't know if this is supported by Homebridge, will have a quick look tonight to see if it's possible and if so how much work it would be.

from homebridge-homewizard.

rthewhite avatar rthewhite commented on July 17, 2024

I looked in to it, looks like homebridge has some support for it. There appears to be an updateValue characteristic. The only thing is that HomeWizard doesn't support a push mechanisme to update value, so the plugin should then constantly make calls to the HomeWizard to check if the state/value has changed.

Will try to make some time this weekend to see how i can do this nicely. Don't want every accessoiry to constantly fire a stream of requests to the HomeWizard to check it's value.

from homebridge-homewizard.

msetten avatar msetten commented on July 17, 2024

Maybe you could make it configurable? Have a dictionary in the config file for each device that specifies the amount of minutes (or seconds) to retrieve and update the sensor value, with zero meaning to not update it automatically.

I can see that sensors like thermometers can be updated every 5 to 10 minutes, while something like a door sensor should be updated no less than every minute.

from homebridge-homewizard.

rthewhite avatar rthewhite commented on July 17, 2024

Ok i created a working prototype of this today, it pushed the state of a motion sensor to HomeKit. I setup a trigger in Homekit to turn on a light bulb when it saw movement and it worked. Thought of a way to limit the number of requests etc as well. Didn't have a enough time to finish it all up, will try to complete it this week 👍

from homebridge-homewizard.

ygageot avatar ygageot commented on July 17, 2024

Same problem with smoke sensors !

from homebridge-homewizard.

rthewhite avatar rthewhite commented on July 17, 2024

Yeah it's on my list, been quite busy. Will have another look at it tonight, problem with this is that i need some nice way to handle the interval for the requests. Would like to try and prevent each accessory to have it's on interval running to retrieve things.

Would like to have one central interval which retrieves the right data and then fires events the accessories listen to and update their value if needed. Since we know the API of the HW isn't really fast need to prevent constant requests being fired.

from homebridge-homewizard.

ygageot avatar ygageot commented on July 17, 2024

Something more complex :

  • in the plugin you add a very simple HTTP or UDP server, when it receive any request it ask and refresh the status of all the sensors
  • in HW you add an IP Switch "Homebridge" with this request
  • in HW you add task/trigger to each important sensor with an action to the IP switch
    In addition you can always have a "slow" periodic timer

from homebridge-homewizard.

ygageot avatar ygageot commented on July 17, 2024

Do you think that it is possible in api.js when we execute getStatus to loop the accessories/services and fire all the getters ?
If it is possible the advantage is then : when you update one, you update all !

from homebridge-homewizard.

ygageot avatar ygageot commented on July 17, 2024

@rthewhite An experience with a contact sensor :
In HW app
I added a virtual accessory sending an UDP broadcast message.
I added an action on my contact sensor firing this virtual accessory when changes.
In the plugin
I added an UDP server cleaning the caches and sending a special event when it receive something
In contact-sensor.js I added a specific eventListener executing a getContactSensorState
In Eve app
I added a scene connected to a lightbulb
I added a trigger with my sensor running these scene

Conclusion, when I open/close my sensor, the plugin execute immediately a getContactSensorState with the fresh value.
BUT the Eve app execute this trigger only if I manually refresh the app.

I am looking for a method to PUSH in HomeKit the new value of the Characteristic.ContactSensorState, some people speaks about characteristic.updateValue(newValue, null) but I cannot find it.

Have you some ideas ?

from homebridge-homewizard.

rthewhite avatar rthewhite commented on July 17, 2024

I did some investigation last night. Looks like the updateValue method is available on the characteristic.
This would mean that we have to change something like this which is now in switch.js:

service
      .getCharacteristic(this.hap.Characteristic.On)
      .on('set', this.setPowerState.bind(this))
      .on('get', this.getPowerState.bind(this));

To:

const onCharacteristic = service.getCharateristic(this.hap.Characteristic.On);

onCharacteristic  
      .on('set', this.setPowerState.bind(this))
      .on('get', this.getPowerState.bind(this));

onCharacteristic is then supposed to have the updateValue method. Then you need an http server or something which can listen to virtual virtual accessories change. Write some code to call the update method on the correct accessory which will then call the updateValue method of the characteristic.

That's the global idea, I think running a loop which checks every couple of seconds all accessories won't work with the HomeWizard because of the performance issues. So using the virtual accessory is probably the only reliable way to do this.

Like I said I don't have much time to develop and test it and also don't have a HomeWizard anymore. So if anyone feels up for this, feel free to make a pull request.

from homebridge-homewizard.

ygageot avatar ygageot commented on July 17, 2024

I had the time this evening to merge my April tests with the current version and I checked with Home app in place of Eve and it works !!!
In fact you must execute characteristic.setValue(newValue).

For the moment I added in HW a unique virtual accessory "HomeKit ping" broadcasting UDP with an OPEN&CLOSE state message.
I added in the plugin a global NotificationListener with inside an UDP server for the moment.
I checked with a contact sensor.
When I open/close the sensor, the Home app widget of the accessory change in less than one second.

For the moment I modified lightly contact-sensor, light-sensor, motion-sensor and smoke-sensor to have the same possibility.

Technically, when the new NotificationListener receive any "ping" , it request all the status from the HW and notify all the HomeKit accessories of any change immediatly.

For the moment I made this choice with a unique virtual HW accessory (The reason I named it "Ping")

I dont want to create one virtual for each real.

Probably tomorow I will had in NotificationListener an http server to do the same especially if the plugin is not on the same network but the user must know the IP address of the plugin server... I will lead UPD and HTTP in //

from homebridge-homewizard.

ygageot avatar ygageot commented on July 17, 2024

@rthewhite
Do yo want I change the README and version number of the last version ?

from homebridge-homewizard.

rthewhite avatar rthewhite commented on July 17, 2024

That would be great 👍

from homebridge-homewizard.

ygageot avatar ygageot commented on July 17, 2024

In the last version I am thinking about the feature to have by default a periodic refresh with 5 minutes.
Want do you think about that ?

from homebridge-homewizard.

rthewhite avatar rthewhite commented on July 17, 2024

If you have throughly tested this and it works fine. Im ok with that, it's a great feature to have.

Think it will be good to mention in the readme though that if you want real time updates you will need to use the http/udp method. Because even an 1 minute interval might be to short to detect a doorbell for example.

from homebridge-homewizard.

rthewhite avatar rthewhite commented on July 17, 2024

Think this is covered for now right 👍

from homebridge-homewizard.

arkadicolson avatar arkadicolson commented on July 17, 2024

@ygageot
Hi Can you tell me what exactly you filled in in the ip switch in the fields data? I see the request coming in on Homebridge but then nothing happens...

from homebridge-homewizard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.