Skip to content

Commit

Permalink
Beginnings of playground (#15)
Browse files Browse the repository at this point in the history
* feat: add playground

* chore: create user

* chore: update readme

* chore: update state
  • Loading branch information
webbertakken authored Apr 21, 2024
1 parent ef6d687 commit 329697a
Show file tree
Hide file tree
Showing 37 changed files with 737 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,20 @@ Run your automations locally
yarn dev
```

### Test
## Testing

#### Unit tests and integration tests

Run all your tests

```bash
yarn test
```

#### End-to-end tests

See [./playground](./playground/README.md) folder readme.

## Publication

### Build
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"type": "module",
"scripts": {
"dev": "bun --hot --watch src/main.ts",
"play": "docker-compose -f playground/docker-compose.yml up",
"endplay": "docker-compose -f playground/docker-compose.yml down",
"sync": "yarn up \"@digital-alchemy/*\" && bunx --env-file .env type-writer",
"build": "bun --env-file .env build:docker",
"build:dist": "bun build src/main.ts --compile --minify --outfile dist/server",
Expand Down
30 changes: 30 additions & 0 deletions playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Automation Playground

This playground is intended to help you test and learn about making automations.

It features a Home Assistant instance that you can safely experiment with, without affecting your
own home environment.

## Credentials

In the playground we'll use the following credentials:

Username: `digital` Password: `alchemy`

## Home assistant

Accessible at: http://localhost:8123

## Usage

#### Start playground

```bash
yarn play
```

#### Stop playground

```bash
yarn endplay
```
17 changes: 17 additions & 0 deletions playground/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
services:
homeassistant:
image: lscr.io/linuxserver/homeassistant:latest
container_name: playground-homeassistant
network_mode: bridge
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
volumes:
- ./homeassistant/config:/config
ports:
- 8123:8123 #optional
# devices:
# - /path/to/device:/path/to/device #optional
restart: unless-stopped
1 change: 1 addition & 0 deletions playground/homeassistant/config/.HA_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024.4.3
17 changes: 17 additions & 0 deletions playground/homeassistant/config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Sensitive files
passwd
*.db*
!*.db
*.sqlite

# Home Assistant generated files
/.cloud
/backups
**/*.log*
temp.txt
*.bolt
/lsiopy
tts/*

# Vendor files (explicitly per folder, for reinstall purposes)
/custom_components/hacs
24 changes: 24 additions & 0 deletions playground/homeassistant/config/.storage/assist_pipeline.pipelines
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"minor_version": 2,
"key": "assist_pipeline.pipelines",
"data": {
"items": [
{
"conversation_engine": "homeassistant",
"conversation_language": "en",
"id": "01hvypmpwba6n20a5a3gz0wk57",
"language": "en",
"name": "Home Assistant",
"stt_engine": null,
"stt_language": null,
"tts_engine": "cloud",
"tts_language": "en-US",
"tts_voice": "JennyNeural",
"wake_word_entity": null,
"wake_word_id": null
}
],
"preferred_item": "01hvypmpwba6n20a5a3gz0wk57"
}
}
92 changes: 92 additions & 0 deletions playground/homeassistant/config/.storage/auth
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": 1,
"minor_version": 1,
"key": "auth",
"data": {
"users": [
{
"id": "a5e3f0338e38448a90aa4797511b5b4d",
"group_ids": [
"system-read-only"
],
"is_owner": false,
"is_active": true,
"name": "Home Assistant Content",
"system_generated": true,
"local_only": false
},
{
"id": "5217a56b1c754713b6308e883dd5f22f",
"group_ids": [
"system-admin"
],
"is_owner": true,
"is_active": true,
"name": "Digital Alchemy",
"system_generated": false,
"local_only": false
}
],
"groups": [
{
"id": "system-admin",
"name": "Administrators"
},
{
"id": "system-users",
"name": "Users"
},
{
"id": "system-read-only",
"name": "Read Only"
}
],
"credentials": [
{
"id": "0eb3dd17ce874321938c88bcdfdf89a6",
"user_id": "5217a56b1c754713b6308e883dd5f22f",
"auth_provider_type": "homeassistant",
"auth_provider_id": null,
"data": {
"username": "digital"
}
}
],
"refresh_tokens": [
{
"id": "71b3f77099fa4d86b33a4acc74ed2d90",
"user_id": "a5e3f0338e38448a90aa4797511b5b4d",
"client_id": null,
"client_name": null,
"client_icon": null,
"token_type": "system",
"created_at": "2024-04-20T21:29:48.827488+00:00",
"access_token_expiration": 1800.0,
"token": "da5a2b72e294aa44a48e337fdc1403aed3193461a7ab2c8619c0a5dd0d2c3884c4678b57c365e78e73c3e48c6b40c3505f4f81ba731179adb2d1312d91976891",
"jwt_key": "2f39d1c4e836a81314e3dc378feae8d1ff4d88e7651e93865c636cc355fc983144fffbc14a90da8be502b85461c3f2ea3cc7145d59e652996565b8e327a638aa",
"last_used_at": null,
"last_used_ip": null,
"expire_at": null,
"credential_id": null,
"version": "2024.4.3"
},
{
"id": "5248f6204da5445cafaf9dd7c1af0f92",
"user_id": "5217a56b1c754713b6308e883dd5f22f",
"client_id": "http://localhost:8123/",
"client_name": null,
"client_icon": null,
"token_type": "normal",
"created_at": "2024-04-20T21:30:45.847881+00:00",
"access_token_expiration": 1800.0,
"token": "75b599e455ffac0f1b2b82d27bd866ad1ca978b28900ab3e5d45653e1933d36f07499277ecb2e568338e5713947981063ee7e385500594906a3f81bfdb8f9bd0",
"jwt_key": "0d16c3e597c4ddf3c82c22ae1db23f76e82147cc1c2b439bc90635f2a7c3a89a418f9cb06335d7a831a187dc514617a0d59465002ee6e983c09b3077e709a973",
"last_used_at": "2024-04-20T22:27:39.538260+00:00",
"last_used_ip": "172.17.0.1",
"expire_at": 1721428059.53826,
"credential_id": "0eb3dd17ce874321938c88bcdfdf89a6",
"version": "2024.4.3"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"minor_version": 1,
"key": "auth_provider.homeassistant",
"data": {
"users": [
{
"username": "digital",
"password": "JDJiJDEyJHB3b2ZrNXZPY1RLbFU5UlRkQkpwWnVMUFZjV0pBU1FIMC5CbzZ6VlNxdWZMbks3RHFmdXdT"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": 1,
"minor_version": 1,
"key": "bluetooth.passive_update_processor",
"data": {}
}
10 changes: 10 additions & 0 deletions playground/homeassistant/config/.storage/core.analytics
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": 1,
"minor_version": 1,
"key": "core.analytics",
"data": {
"onboarded": true,
"preferences": {},
"uuid": null
}
}
36 changes: 36 additions & 0 deletions playground/homeassistant/config/.storage/core.area_registry
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": 1,
"minor_version": 6,
"key": "core.area_registry",
"data": {
"areas": [
{
"aliases": [],
"floor_id": null,
"icon": null,
"id": "living_room",
"labels": [],
"name": "Living Room",
"picture": null
},
{
"aliases": [],
"floor_id": null,
"icon": null,
"id": "kitchen",
"labels": [],
"name": "Kitchen",
"picture": null
},
{
"aliases": [],
"floor_id": null,
"icon": null,
"id": "bedroom",
"labels": [],
"name": "Bedroom",
"picture": null
}
]
}
}
18 changes: 18 additions & 0 deletions playground/homeassistant/config/.storage/core.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 1,
"minor_version": 3,
"key": "core.config",
"data": {
"latitude": 52.3731339,
"longitude": 4.8903147,
"elevation": 0,
"unit_system_v2": "metric",
"location_name": "Home",
"time_zone": "Europe/Amsterdam",
"external_url": null,
"internal_url": null,
"currency": "EUR",
"country": "NL",
"language": "en-GB"
}
}
68 changes: 68 additions & 0 deletions playground/homeassistant/config/.storage/core.config_entries
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": 1,
"minor_version": 1,
"key": "core.config_entries",
"data": {
"entries": [
{
"entry_id": "665cc088f5856930ec3692b7bcebf062",
"version": 1,
"minor_version": 1,
"domain": "sun",
"title": "Sun",
"data": {},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "import",
"unique_id": null,
"disabled_by": null
},
{
"entry_id": "241d4179d6b2fe8e42531678290d4b83",
"version": 1,
"minor_version": 1,
"domain": "shopping_list",
"title": "Shopping list",
"data": {},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "onboarding",
"unique_id": "shopping_list",
"disabled_by": null
},
{
"entry_id": "d6f293056a7bd8817eb06ccacea4fe86",
"version": 1,
"minor_version": 1,
"domain": "google_translate",
"title": "Google Translate text-to-speech",
"data": {
"language": "en",
"tld": "com"
},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "onboarding",
"unique_id": null,
"disabled_by": null
},
{
"entry_id": "32d636dfe7fbca41a2641a4cb5554e16",
"version": 1,
"minor_version": 1,
"domain": "radio_browser",
"title": "Radio Browser",
"data": {},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "onboarding",
"unique_id": null,
"disabled_by": null
}
]
}
}
11 changes: 11 additions & 0 deletions playground/homeassistant/config/.storage/core.device_registry
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": 1,
"minor_version": 5,
"key": "core.device_registry",
"data": {
"devices": [
{"area_id":null,"config_entries":["665cc088f5856930ec3692b7bcebf062"],"configuration_url":null,"connections":[],"disabled_by":null,"entry_type":"service","hw_version":null,"id":"a28cabc60853c3d7752bf77044425bfc","identifiers":[["sun","665cc088f5856930ec3692b7bcebf062"]],"labels":[],"manufacturer":null,"model":null,"name_by_user":null,"name":"Sun","serial_number":null,"sw_version":null,"via_device_id":null}
],
"deleted_devices": []
}
}
Loading

0 comments on commit 329697a

Please sign in to comment.