Closed focher closed 4 years ago
Does this work for you? Also, it seems like it should be exposed as a "garage door" accessory instead of a "switch", what do you think?
To be honest, I was only able to test using Postman to call the teslajs API call of homelink() and that worked. I do not know how to build this and install into Homebridge.
I think exposing it as a Garage Door Opener sensor type would be overkill, as the Homelink functionality in the car simply sends the garage door signal. There's no ability for the car to receive information back like whether the door is open or closed, if there's an obstruction, etc.
In the Homebridge Garage Door Sensor type, the following Characteristics are supported. However, the car cannot use any of them.
Required Characteristics Current Door State Target Door State Obstruction Detected
Optional Characteristics Lock Current State Lock Target State Name
Unfortunately, I am not getting this to successfully work. I've now tried:
Switch Garage Door Opener Stateless Programmable Switch
None appear to actually call the homelink() API. I believe it is something to do with the latitude and longitude being necessary. I'll play a bit more to see if I can make progress.
I recommend to cancel / reject this pull request until I can successfully test it. So far, no go. But I'll keep trying.
I finally got back to this and have it working. However, the Homelink API call in the TeslaJS library needs to be fixed first. I have provided the fixes to that developer here. Once that fix is applied, I'll create a new pull request with the final code.
Discovered the change needed in the TeslaJS library. There's a code commit to fix the Homelink API call. Once that's deployed, I'll do another pull request with the Homelink that I've added.
I'm still experiencing one strange issue. Homelink only works if the car is awake. I've added an
`await this.setConnectionOn;
but found this does not does not really work. Instead I have to use the explicit call from the Homebridge - Accessories UI to wake the car, then wait for the car to be awake before I can call the Homelink trigger.
Any ideas why that's happening so that I can handle it differently?
Calling await this.wakeUp();
should be sufficient to wake up the car - that's what all the other commands do internally?
I'm just waiting for the patched release of TeslaJS and then the code is good to go. I also added a Charge Level indicator (in %).
You'll also see a small change I made in one of your logging messages. It appears there might have been a hidden character, as it was messing up in the log display.
this.log("Waiting for vehicle to wake up...");
This is good to go. Unfortunately, the TeslaJS version wasn't bumped when he applied the Homelink API fix but I set it to the 4.8.1 (current) in package.json
So the pull request should be good to go and now there's Homelink support!
Seems great to me, thanks for all this work! Can you update the README with information about these two new features? Also since some people don't have HomeLink support in their car (or a home with a garage door), could the HomeLink service be opt-in instead of opt-out?
Oh and could you update config.schema.json
to reflect these new options, for those who are using GUI configuration tools like config-ui-x?
Funny. I had actually already done the stuff to support GUI config but neglected to commit it. Those two commits:
Awesome, thank you! I think this is good to merge.
I pushed one more commit with some aesthetic changes and will publish v2.5.0 now!
It appears that teslajs does not require the latitude and longitude values, so the code I added just makes a call to homelink().
Forgive any mistakes. I'm not really a coder but it looked pretty straightforward to add new commands.