Skip to content

Commit 4b08e4d

Browse files
authored
Merge pull request #26 from Teslemetry/claude/plan-homebridge-integration-9ym5y
Add HomeBridge integration
2 parents 6eaea1e + 6ad5104 commit 4b08e4d

30 files changed

+2834
-0
lines changed
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
# @teslemetry/homebridge-teslemetry
2+
3+
[![npm version](https://badge.fury.io/js/%40teslemetry%2Fhomebridge-teslemetry.svg)](https://badge.fury.io/js/%40teslemetry%2Fhomebridge-teslemetry)
4+
[![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
5+
6+
Teslemetry platform plugin for Homebridge with **real-time streaming support** for Tesla vehicles and energy sites.
7+
8+
## Features
9+
10+
🚗 **Tesla Vehicle Control**
11+
- Real-time status updates via Server-Sent Events (SSE)
12+
- Lock/unlock doors
13+
- Climate control (heat/cool)
14+
- Charge management
15+
- Sentry mode control
16+
- Window control
17+
- And more...
18+
19+
**Energy Site Support** *(Coming Soon)*
20+
- Powerwall monitoring
21+
- Solar production tracking
22+
- Grid control
23+
24+
🔄 **Real-time Streaming**
25+
- Instant updates when vehicle state changes
26+
- No polling - efficient and responsive
27+
- Built on Teslemetry's Fleet Telemetry API
28+
29+
## Requirements
30+
31+
- **Active Teslemetry Subscription**: Create an account and get an access token at [teslemetry.com](https://teslemetry.com)
32+
- **Node.js**: Version 18 or higher
33+
- **Homebridge**: Version 1.8.0 or higher
34+
- **Fleet Telemetry Support**: Your vehicle must support Fleet Telemetry (most recent Tesla vehicles)
35+
36+
## Installation
37+
38+
### Via Homebridge Config UI X (Recommended)
39+
40+
1. Search for "Teslemetry" in the Homebridge Config UI X plugin search
41+
2. Click **Install**
42+
3. Configure the plugin with your Teslemetry access token
43+
44+
### Via Command Line
45+
46+
```bash
47+
npm install -g @teslemetry/homebridge-teslemetry
48+
```
49+
50+
Or if using pnpm:
51+
52+
```bash
53+
pnpm add -g @teslemetry/homebridge-teslemetry
54+
```
55+
56+
## Configuration
57+
58+
### Via Homebridge Config UI X
59+
60+
The easiest way to configure this plugin is through the Homebridge Config UI X interface. All options are available through the visual interface.
61+
62+
### Manual Configuration
63+
64+
Add the following to your Homebridge `config.json`:
65+
66+
```json
67+
{
68+
"platforms": [
69+
{
70+
"platform": "Teslemetry",
71+
"name": "Teslemetry",
72+
"accessToken": "your_teslemetry_access_token_here",
73+
"prefixName": true,
74+
"latitude": 37.7749,
75+
"longitude": -122.4194,
76+
"ignoreVehicles": [],
77+
"ignoreEnergySites": []
78+
}
79+
]
80+
}
81+
```
82+
83+
### Configuration Options
84+
85+
| Option | Type | Required | Default | Description |
86+
|--------|------|----------|---------|-------------|
87+
| `platform` | string | **Yes** | - | Must be `"Teslemetry"` |
88+
| `accessToken` | string | **Yes** | - | Your Teslemetry API access token from [teslemetry.com](https://teslemetry.com) |
89+
| `name` | string | No | `"Teslemetry"` | Display name for the platform |
90+
| `prefixName` | boolean | No | `true` | Whether to prefix accessory names with the vehicle name |
91+
| `latitude` | number | No | - | Latitude for Homelink activation (required if using Homelink) |
92+
| `longitude` | number | No | - | Longitude for Homelink activation (required if using Homelink) |
93+
| `ignoreVehicles` | string[] | No | `[]` | Array of vehicle VINs to ignore |
94+
| `ignoreEnergySites` | number[] | No | `[]` | Array of energy site IDs to ignore |
95+
96+
## Getting a Teslemetry Access Token
97+
98+
1. Go to [teslemetry.com](https://teslemetry.com)
99+
2. Create an account or log in
100+
3. Navigate to your account settings
101+
4. Generate a new API access token
102+
5. Copy the token and paste it into your Homebridge configuration
103+
104+
## Supported Vehicles
105+
106+
This plugin supports all Tesla vehicles that have Fleet Telemetry capability:
107+
108+
- Model 3 (2017+)
109+
- Model Y (2020+)
110+
- Model S (2021+ refresh)
111+
- Model X (2021+ refresh)
112+
- Cybertruck (2023+)
113+
114+
Older Model S and Model X vehicles may have limited support.
115+
116+
## HomeKit Accessories
117+
118+
Each Tesla vehicle will appear as multiple accessories in HomeKit:
119+
120+
### Current Implementation (Phase 1)
121+
- **Vehicle Discovery** - Automatic discovery and registration of vehicles
122+
- **Real-time Streaming** - Connection to Teslemetry's streaming API
123+
124+
### Coming Soon (Phase 2)
125+
- **Battery Service** - Battery level and charging status
126+
- **Lock Service** - Lock/unlock doors
127+
- **Climate Service** - Temperature control and HVAC
128+
- **Charge Port** - Open/close charge port
129+
- **Charge Switch** - Start/stop charging
130+
- **Charge Limit** - Set charge limit percentage
131+
- **Defrost Service** - Activate max defrost
132+
- **Door Sensors** - Individual door status
133+
- **Window Control** - Vent/close windows
134+
- **Sentry Mode** - Enable/disable sentry mode
135+
- **Homelink** - Trigger Homelink (requires location config)
136+
137+
## Troubleshooting
138+
139+
### Plugin Not Discovering Vehicles
140+
141+
1. Verify your access token is correct
142+
2. Check that you have an active Teslemetry subscription
143+
3. Ensure your vehicle supports Fleet Telemetry
144+
4. Check Homebridge logs for error messages
145+
146+
### Streaming Connection Issues
147+
148+
1. Verify network connectivity
149+
2. Check that Teslemetry streaming is enabled for your account
150+
3. Restart Homebridge
151+
4. Check firewall settings (SSE requires persistent connections)
152+
153+
### Accessories Not Responding
154+
155+
1. Check if vehicle is asleep (may take a moment to wake)
156+
2. Verify streaming connection status in logs
157+
3. Try restarting the Homebridge service
158+
159+
## Development
160+
161+
This package is part of the [Teslemetry TypeScript monorepo](https://github.com/Teslemetry/typescript-teslemetry).
162+
163+
### Local Development
164+
165+
```bash
166+
# Clone the repository
167+
git clone https://github.com/Teslemetry/typescript-teslemetry.git
168+
cd typescript-teslemetry
169+
170+
# Install dependencies
171+
pnpm install
172+
173+
# Build the package
174+
pnpm --filter @teslemetry/homebridge-teslemetry build
175+
176+
# Watch mode for development
177+
pnpm --filter @teslemetry/homebridge-teslemetry watch
178+
```
179+
180+
### Testing Locally
181+
182+
```bash
183+
# Link globally for testing
184+
cd packages/homebridge-teslemetry
185+
pnpm link --global
186+
187+
# In your Homebridge directory
188+
cd ~/.homebridge
189+
pnpm link --global @teslemetry/homebridge-teslemetry
190+
191+
# Run Homebridge in debug mode
192+
homebridge -D
193+
```
194+
195+
## Contributing
196+
197+
Contributions are welcome! Please read the [contributing guidelines](../../CONTRIBUTING.md) before submitting pull requests.
198+
199+
## Support
200+
201+
- **Issues**: [GitHub Issues](https://github.com/Teslemetry/typescript-teslemetry/issues)
202+
- **Documentation**: [Teslemetry Docs](https://teslemetry.com/docs)
203+
- **Community**: [Teslemetry Discord](https://discord.gg/teslemetry)
204+
205+
## License
206+
207+
Apache-2.0 - see [LICENSE](../../LICENSE) for details.
208+
209+
## Credits
210+
211+
- Built with [@teslemetry/api](https://www.npmjs.com/package/@teslemetry/api)
212+
- Powered by [Teslemetry](https://teslemetry.com)
213+
- Part of the [Homebridge](https://homebridge.io) ecosystem
214+
215+
## Related Projects
216+
217+
- [@teslemetry/api](../api) - Core TypeScript SDK
218+
- [node-red-contrib-teslemetry](../node-red-contrib-teslemetry) - Node-RED integration
219+
- [n8n-nodes-teslemetry](../n8n-nodes-teslemetry) - n8n workflow integration
220+
- [homey](../homey) - Homey smart home app
221+
222+
## Changelog
223+
224+
See [CHANGELOG.md](./CHANGELOG.md) for release history.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"pluginAlias": "Teslemetry",
3+
"pluginType": "platform",
4+
"singular": true,
5+
"headerDisplay": "Teslemetry platform plugin for Homebridge with real-time streaming support. Create an access token at [teslemetry.com](https://teslemetry.com).",
6+
"footerDisplay": "For support and documentation, visit [GitHub](https://github.com/Teslemetry/typescript-teslemetry/tree/main/packages/homebridge-teslemetry).",
7+
"schema": {
8+
"type": "object",
9+
"properties": {
10+
"name": {
11+
"title": "Platform Name",
12+
"type": "string",
13+
"default": "Teslemetry",
14+
"required": false,
15+
"description": "The name for this platform instance"
16+
},
17+
"accessToken": {
18+
"title": "Teslemetry Access Token",
19+
"type": "string",
20+
"required": true,
21+
"description": "Your Teslemetry API access token from teslemetry.com"
22+
},
23+
"prefixName": {
24+
"title": "Prefix Accessory Names",
25+
"type": "boolean",
26+
"default": true,
27+
"required": false,
28+
"description": "Prefix accessory names with vehicle/site name for easier identification"
29+
},
30+
"latitude": {
31+
"title": "Latitude",
32+
"type": "number",
33+
"required": false,
34+
"description": "Latitude for Homelink activation (required for Homelink service)"
35+
},
36+
"longitude": {
37+
"title": "Longitude",
38+
"type": "number",
39+
"required": false,
40+
"description": "Longitude for Homelink activation (required for Homelink service)"
41+
},
42+
"ignoreVehicles": {
43+
"title": "Ignore Vehicles",
44+
"type": "array",
45+
"required": false,
46+
"description": "List of vehicle VINs to ignore",
47+
"items": {
48+
"type": "string",
49+
"title": "VIN",
50+
"description": "Vehicle Identification Number"
51+
}
52+
},
53+
"ignoreEnergySites": {
54+
"title": "Ignore Energy Sites",
55+
"type": "array",
56+
"required": false,
57+
"description": "List of energy site IDs to ignore",
58+
"items": {
59+
"type": "number",
60+
"title": "Site ID",
61+
"description": "Energy site identifier"
62+
}
63+
}
64+
},
65+
"required": ["accessToken"]
66+
},
67+
"layout": [
68+
{
69+
"type": "fieldset",
70+
"title": "Authentication",
71+
"expandable": false,
72+
"items": ["accessToken"]
73+
},
74+
{
75+
"type": "fieldset",
76+
"title": "General Settings",
77+
"expandable": true,
78+
"expanded": false,
79+
"items": ["name", "prefixName"]
80+
},
81+
{
82+
"type": "fieldset",
83+
"title": "Homelink Location",
84+
"expandable": true,
85+
"expanded": false,
86+
"description": "Configure location for Homelink activation",
87+
"items": ["latitude", "longitude"]
88+
},
89+
{
90+
"type": "fieldset",
91+
"title": "Filters",
92+
"expandable": true,
93+
"expanded": false,
94+
"description": "Optionally ignore specific vehicles or energy sites",
95+
"items": ["ignoreVehicles", "ignoreEnergySites"]
96+
}
97+
]
98+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "@teslemetry/homebridge-teslemetry",
3+
"displayName": "Homebridge Teslemetry",
4+
"version": "0.1.0",
5+
"description": "Teslemetry integration for Homebridge with real-time streaming support",
6+
"author": "Teslemetry",
7+
"license": "Apache-2.0",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/Teslemetry/typescript-teslemetry.git",
11+
"directory": "packages/homebridge-teslemetry"
12+
},
13+
"bugs": {
14+
"url": "https://github.com/Teslemetry/typescript-teslemetry/issues"
15+
},
16+
"main": "dist/index.cjs",
17+
"type": "module",
18+
"engines": {
19+
"node": ">=18.0.0",
20+
"homebridge": "^1.8.0 || ^2.0.0-beta.0"
21+
},
22+
"scripts": {
23+
"build": "tsdown --format cjs",
24+
"watch": "tsdown --format cjs --watch",
25+
"tsc": "tsc --noEmit",
26+
"prepublishOnly": "pnpm build"
27+
},
28+
"keywords": [
29+
"homebridge-plugin",
30+
"tesla",
31+
"teslemetry",
32+
"streaming",
33+
"vehicle",
34+
"smart-home",
35+
"iot"
36+
],
37+
"dependencies": {
38+
"@teslemetry/api": "workspace:*"
39+
},
40+
"devDependencies": {
41+
"homebridge": "^1.8.0",
42+
"tsdown": "^0.16.7",
43+
"typescript": "^5.9.3"
44+
},
45+
"peerDependencies": {
46+
"homebridge": "^1.8.0 || ^2.0.0-beta.0"
47+
},
48+
"files": [
49+
"dist",
50+
"config.schema.json"
51+
]
52+
}

0 commit comments

Comments
 (0)