-
Notifications
You must be signed in to change notification settings - Fork 56
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
Alpha0.3: GarageDoorOpener and/or timer or wait function? #49
Comments
The latter should work. I will have to test it myself because my garage door works as yours. |
In JavaScript you can define the functions directly where the callback function is passed: setTimeout(time, function () { bla; bla;}); |
OK I can upload my handler later on when I am back home... |
I did try to upload my handler to the addins folder but I need some more rights from you to do it. :-( |
You can create a pull request: Fork the repo, upload your changes to github (into your fork), and then create a pull request. |
about the timer again. and get this error: timers.js:92 TypeError: first._onTimeout is not a function |
did found the above problem myself. Now I use this: And get this error: /usr/local/lib/node_modules/homebridge-knx/lib/addins/Misc2000Test.js:38 TypeError: Cannot read property 'knxWrite' of undefined Misc2000Test.js is my test handler |
If the function is called from "outside" the object function() { bla }.bind(this) Inside the setTimeout() Regards |
my garage door opener is a little different after all. https://github.com/snowdd1/homebridge-knx/blob/plugin-2.0/lib/addins/MonoStableMultivibrator.js |
OK timer is working. |
OK its working with the timer to set the open state now also in the garage door handler. |
Updated Version 2.1 of Misc2000GarageDoorOpener.js with simulated DoorOpen contact |
Version 2.2 of Misc2000GarageDoorOpener.js is now part of 0.3 Beta Version. If you want to use it please read the header section of the handler to understand the needed HW conditions. |
Cool stuff guys. I was searching for something like this. I currently use SmartHome.py logics to simulate the "Closing", "Opening", "Open". This thing will make my life easier 👍 |
Hi @misc2000 , I just had a look into the example a bit. One comment: In addition, it would be great to have this stuff configurable in the knx_config, not in the addin itself: Further, my door-contacts work exactly the other way around, meaning that a "1" means a contact is on. Can we make this configurable as well. I could of course change this myself as well, but I think we should not create too many flavours of examples. Makes sense? Cheers, |
hi @giase82 |
Hi, //giase |
@giase82 use setTimeout() see here: https://github.com/snowdd1/homebridge-knx/blob/master/lib/addins/MonoStableMultivibrator.js#L45 |
That creates a callback timer that will be called after given time, without interrupting the code execution much. The only thing to consider is that you can not be sure of order of execution - will the callback be called before or after a certain line in the rest of the code? |
That's exactly the issue, as I need to create up to three pulses (switch on/off) and therefore I need to be sure to only switch on again after it has been switched off! |
I started with setTimeout but this didn't work so far... if I don't get further by myself I'll post the code and you can check. |
You need to keep the created timer object, so you can check if there is an active timer In the callback function you need to clear the timer variable |
So what I have right now is this:
(why doesn't the formatting work?) But I get the following error currently: TypeError: Cannot read property 'knxWrite' of undefined My JS-skills are rather copy/paste-based currently, as I didn't do this for some years now. Can you guys point out what's wrong? In addition, I got the issue that I see the needed address for the pulse switched on the bus, but for whatever reason, when I do this via Homebridge, it does not get switched off anymore... If I do it manually it works fine. I raised to timeout to 2 seconds already, but this doesn't change anything. But this is a different topic. |
I guess I need to use the 'bind'? |
you can either use |
^ that=this: before the function definition |
Ok thanks. I did the .bind now and this works finally (also setting it correctly on the bus). I am not that much concerned about performance :) When I've got time to test further, I'll send a pull request and we can probably merge it with the one from misc2000 later.
|
Hi, Hier ist der pull-request: #63 Ist jetzt doch n bisschen umfangreicher geworden... |
hi Giase82, |
@giase82 |
Hi Raoul, I saw this. How can I re-base in git or merge back the base? It just tells me: This branch has conflicts that must be resolved |
I think it happens if you start modifying a file and haven't merged (pulled) the latest version. So you need to pull the latest version of the repository, do the changes again to WindowCoveringTilt.js and commit it, then I can click the merge pull request button. |
hi Christof, |
Hi Raoul, Hi Michael, Thanks for reviewing and testing! I did indeed see the push-notification twice in this case as well. I only had a quick look, but from the implementation it seem to be fine, so I guess this is an Apple issue. I get a "door opened" once it starts showing "opening" in the App, and then again when the door is really opened. Regarding the merge: I am still trying to figure out how git works in its details. Just a matter of years .. ;-) |
I see these two notifications as well, I think that it has to do with the TargetState and CurrentState - Apple has chosen to send a push upon receiving TargetState and CurrentState changes, might be a bug. |
hi Christof/Raoul, |
I agree with Raoul that sending a push on both TargetState and CurrentState is probably the issue. I think the if =! "newValue" wouldn't change that. |
Hi guys, I just did another update after running into a problem where there was only the "open-door" contact present. I am going to send another pull-request soon... //Christof |
Here we go: #64 |
Having a bad night or are you in another time zone? |
I've got kids, so rather the former currently ;-) |
hi,
I am on the way to implement a own handler for my 2 garage door openers.
Unfortunately I did only install one "Reed" sensor on the doors that detect if the door is closed from the hardware side.I can use this to detect the start of the movement and set "Characteristic.CurrentDoorState.OPENING = 2"
But to implement it "the Apple way" you also need on signal when the door is complete open.
My door need 18 seconds to open. And I need to send a "Characteristic.CurrentDoorState.OPEN = 0"
after that 18 seconds.
My idea was to simulate this signal by software inside my own Homebridge-KNX garage door Handler.
Just start a 18 second timer when the door starts to open (value change on the existing HW sensor)
And if the timer is over, and no interrupt/stop command was detected during the timer run, send the "open" value to the HK device.
Because I am not a Java Script expert at all my question is how could I implement this?
I think a easy
yield WaitForSeconds (18);
would not work because it will block everything in the handler for 18s.
My idea was more like:
function function1() {
// stuff you want to happen right away
console.log('All stuff needed when door start to open');
}
function function2() {
// all the stuff you want to happen after that pause
console.log('All stuff needed when door is complete open');
}
// call the first chunk of code right away
function1();
// call the rest of the code and have it execute after 18 seconds
setTimeout(function2, 18000);
Do this approach work in java script and also in your handler framework?
And if yes can someone give me a hint how to implement it (where to declare the functions)?
And how to interrupt the time if needed?
Thanks
The text was updated successfully, but these errors were encountered: