immersive-home/README.md

190 lines
8.5 KiB
Markdown
Raw Normal View History

2023-11-04 15:24:50 +02:00
![logo](assets/banner.png)
2023-10-16 20:10:02 +03:00
2023-11-04 16:34:46 +02:00
# 🏠 Introduction
2023-11-26 12:25:18 +02:00
Immersive Home is project to bring Smart Home and Mixed Reality technologies together for an intuitive and immersive experience. [Demo Video](https://www.youtube.com/watch?v=vk6uTYOINY4)
2023-11-04 16:34:46 +02:00
2023-11-25 20:56:20 +02:00
## Planned Features
2023-11-04 16:34:46 +02:00
- **Fast and Intuitive control over IoT devices**
- **Live overview over your smart home**
- **Simple way for creating automations**
- **Comfortable way of consuming virtual media unobstructed**
- **Advanced automations based on position in room**
2023-11-25 20:56:20 +02:00
## Try it out
2023-11-25 21:05:19 +02:00
Right now you can try out the app for free using either of the following pages:
2023-11-25 20:56:20 +02:00
<a href="https://github.com/Nitwel/Immersive-Home/releases/latest/download/Android.zip">
<img height="32" src="assets/badges/github.svg" alt="Badge linking to GitHub" />
</a>
<a href="https://nitwel.itch.io/immersive-home">
<img height="32" src="assets/badges/itch.svg" alt="Badge linking to itch.io" />
</a>
<a href="https://sidequestvr.com/app/26827/immersive-home">
<img height="32" src="assets/badges/sidequest.svg" alt="Badge linking to sidequest" />
</a>
2023-11-25 21:05:19 +02:00
💕 If you like to see the project grow to support more devices and interaction methods, consider supporting the project using these methods:
- Donate using [PayPal]( https://paypal.me/nitwel) or [GitHub Sponsors](https://github.com/sponsors/Nitwel)
- Buying the app on [itch.io](https://nitwel.itch.io/immersive-home)
- Contributing to the project by creating issues or pull requests
2023-11-04 16:34:46 +02:00
## Supported Devices
**Smart Home Platforms**
- [Home Assistant](https://www.home-assistant.io/)
**Mixed Reality Headsets**
- Meta Quest 2 / Pro / 3
2023-11-21 12:48:35 +02:00
## Connecting to your Home Assistant Instance
2023-11-25 20:56:20 +02:00
Go to the settings tab (the gear icon) and enter the url of your Home Assistant instance.
In order to authenticate, you have to generate a long-lived access token in Home Assistant.
2023-11-21 12:48:35 +02:00
To generate a HASS token, login into your dashboard, click on your name (bottom left), scroll down and create a long-lived access token.
2023-11-25 20:56:20 +02:00
Finally, click the connect button and you should be connected to your Home Assistant instance.
2023-11-21 12:48:35 +02:00
2023-11-04 16:35:48 +02:00
# 🛠 Development
2023-11-04 16:34:46 +02:00
In order to contribute to this project, you need the following to be setup before you can start working:
- Godot 4.1.3 installed
## Fundamentals
Communication with the Smart Home Environment is done using the `HomeApi` global. Each environment is made up of devices and entities.
2023-11-04 16:34:46 +02:00
A device is a collection of different entities and entities can represent many different things in a smart home.
For example, the entity of name `lights.smart_lamp_1` would control the kitchen lamps while `state.smart_lamp_1_temp` would show the current temperature of the lamp.
2023-11-05 16:27:57 +02:00
### File Structure
```
.
├── addons (All installed Godot Addons are saved here)
├── assets (Files like logos or assets that are shared across scenes)
2023-11-05 16:28:41 +02:00
├── content/ (Main files of the project)
2023-11-05 16:27:57 +02:00
│ ├── entities (Entities that can be placed into the room)
2023-11-11 19:26:58 +02:00
│ ├── functions (Generic functions that can be used in scenes)
2023-11-05 16:27:57 +02:00
│ └── ui (User Interface Scenes and related files)
2023-11-05 16:28:41 +02:00
└── lib/ (Code that is global or shared across scenes)
2023-11-05 16:27:57 +02:00
├── globals (Globally running scripts)
└── home_adapters (Code allowing control smart home entities)
```
### Home Api
2023-11-04 16:34:46 +02:00
The `HomeApi` global allows to communicate with different backends and offers a set of fundamental functions allowing communication with the Smart Home.
2023-11-04 16:34:46 +02:00
```python
Device {
"id": String,
"name": String,
"entities": Array[Entity]
}
Entity {
"state": String
"attributes": Dictionary
}
# Get a list of all devices
func get_devices() -> Signal[Array[Device]]
# Get a single device by id
func get_device(id: String) -> Signal[Device]
# Returns the current state of an entity.
func get_state(entity: String) -> Signal[Entity]
# Updates the state of the entity and returns the resulting state
func set_state(entity: String, state: String, attributes: Dictionary) -> Signal[Entity]
# Watches the state and each time it changes, calls the callback with the changed state, returns a function to stop watching the state
func watch_state(entity: String, callback: Callable[entity: Entity]) -> Callable
```
### Interaction Events
2023-11-05 14:59:33 +02:00
Each time a button is pressed on the primary controller, a ray-cast is done to be able to interact with devices or the UI.
2023-11-11 19:25:59 +02:00
Additionally, each event will bubble up until the root node is reached, allowing to handle events on parents.
In case that an event of a specific node has to be reacted on, use the `Clickable` function node.
2023-11-04 16:34:46 +02:00
2023-11-16 20:23:17 +02:00
It is also possible to bubble up information by returning a dictionary from a function like `_on_click`.
2023-11-04 16:34:46 +02:00
| Function called | Args | Description |
| -- | -- | -- |
2023-11-27 01:23:19 +02:00
| `_on_click` | `[event: EventPointer]` | The back trigger button has been pressed and released |
| `_on_press_down` | `[event: EventPointer]` | The back trigger button has been pressed down |
| `_on_press_move` | `[event: EventPointer]` | The back trigger button has been moved while pressed down |
| `_on_press_up` | `[event: EventPointer]` | The back trigger button has been released |
| `_on_grab_down` | `[event: EventPointer]` | The side grab button been pressed down |
| `_on_grab_move` | `[event: EventPointer]` | The side grab button been pressed down |
| `_on_grab_up` | `[event: EventPointer]` | The side grab button been released |
| `_on_ray_enter` | `[event: EventPointer]` | The ray-cast enters the the collision body |
| `_on_ray_leave` | `[event: EventPointer]` | The ray-cast leaves the the collision body |
2023-11-22 18:35:54 +02:00
| `_on_key_down` | `[event: EventKey]` | The ray-cast leaves the the collision body |
| `_on_key_up` | `[event: EventKey]` | The ray-cast leaves the the collision body |
| `_on_focus_in` | `[event: EventFocus]` | The node is got focused |
| `_on_focus_out` | `[event: EventFocus]` | The node lost focus |
2023-11-22 02:44:07 +02:00
After considering using the build in godot event system, I've decided that it would be better to use a custom event system.
The reason being that we would have to check each tick if the event matches the desired one which seems very inefficient compared to using signals like the browser does.
Thus I've decided to use a custom event system that is similar to the one used in the browser.
2023-11-04 16:34:46 +02:00
2023-11-22 18:35:54 +02:00
### UI Groups
| Group | Description |
| -- | -- |
2023-11-26 13:58:31 +02:00
| `entity` | Marks the object as being an entity placed in space |
2023-11-28 00:46:05 +02:00
| `ui_focus` | The element can be focused, can be a parent |
2023-11-28 15:20:38 +02:00
| `ui_focus_skip` | Focus checking on this element will be skipped |
| `ui_focus_stop` | The focus will not be reset. Useful for keyboard |
2023-11-22 18:35:54 +02:00
2023-11-11 19:25:59 +02:00
### Functions
In order to implement generic features, a set of functions is available to be used in the project.
#### Movable
The `Movable` node allows to move a node around in the room. It uses the grab events in order to transform the parent node.
#### Clickable
The `Clickable` allows to access events of the parent using signals this node emits.
2023-11-21 12:48:35 +02:00
## Installing Locally
1. Make sure Git LFS is installed
2. Run `git clone https://github.com/Nitwel/Immersive-Home.git` in your terminal
3. Import the created `Immersive-Home` folder in Godot
4. Open the project in Godot 4.1.3
2023-11-04 16:34:46 +02:00
### Testing without a VR Headset
In order to test without a headset, press the run project (F5) button in Godot and ignore the prompt that OpenXR failed to start.
To simulate the headset and controller movement, we're using the [XR Input Simulator](https://godotengine.org/asset-library/asset/1775) asset.
2023-11-05 14:59:33 +02:00
Click at the link to get a list of the supported controls.
## Building
2023-11-21 12:48:35 +02:00
1. Possibly fix importing scenes error
2. Follow the following guide to setup exporting for android. [link](https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_android.html)
3. Make sure to reuse any existing `debug.keystore` when updating an app
4. Don't forget to set the JAVA_HOME variable and restart Godot to take effect
5. Install the `Godot XR Android OpenXR Loaders` plugin in Godot
6. Configure the following in the android build template:
2023-11-13 15:12:46 +02:00
- XRMode set to OpenXR
- Check `Use Grandle Build`
- Check `Godot OpenXR Meta`
- In XRFeatures, select at least optional for passthrough
- Ckeck Internet under the permissions
- Under Resources > Filters to export, add `*.j2`
2023-11-26 13:58:31 +02:00
7. `<uses-feature android:name="com.oculus.feature.CONTEXTUAL_BOUNDARYLESS_APP" android:required="true" />` can be added to the `AndroidManifest.xml` to disable the boundary system.
## Troubleshooting
- If you encounter unexpected behavior when building compared to running locally, it may be that the cached data of godot is corrupted or outdated. Try deleting the `.godot` folder and / or all `*.import` files.