Skip to content

Commit

Permalink
Merge branch 'main' into jellystat
Browse files Browse the repository at this point in the history
  • Loading branch information
bastienwirtz authored Jun 1, 2024
2 parents d92e7df + e6adfd7 commit 711f873
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 19 deletions.
18 changes: 1 addition & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

- [Features](#features)
- [Getting started](#getting-started)
- [Kubernetes Installation](docs/kubernetes.md)
- [Configuration](docs/configuration.md)
- [Custom services](docs/customservices.md)
- [Tips & tricks](docs/tips-and-tricks.md)
Expand Down Expand Up @@ -123,23 +124,6 @@ cp assets/config.yml.dist assets/config.yml
npx serve # or python -m http.server 8010 or apache, nginx ...
```

### Using Helm

Thanks to [@djjudas21](https://github.com/djjudas21) [charts](https://github.com/djjudas21/charts/tree/main/charts/homer):

```sh
helm repo add djjudas21 https://djjudas21.github.io/charts/
helm repo update djjudas21

# install with all defaults
helm install homer djjudas21/homer

# install with customisations
wget https://raw.githubusercontent.com/djjudas21/charts/main/charts/homer/values.yaml
# edit values.yaml
helm install homer djjudas21/homer -f values.yaml
```

### Build manually

```sh
Expand Down
19 changes: 18 additions & 1 deletion docs/customservices.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ within Homer:
- [Immich](#immich)
- [OpenHAB](#openhab)
- [Jellystat](#jellystat)
- [Home Assistant](#home-assistant)

If you experiencing any issue, please have a look to the [troubleshooting](troubleshooting.md) page.

Expand Down Expand Up @@ -479,4 +480,20 @@ The Jellystat server must be running behind a reverse proxy to add some cors hea
type: "Jellystat"
apikey: "<---insert-api-key-here--->"
```
You can create an API key in the dashboard of you jellystat server: settings/API Keys -> Add Key
You can create an API key in the dashboard of you jellystat server: settings/API Keys -> Add Key

## Home Assistant

You need to set the type to HomeAssistant, provide an api key and enable cors on Home Assistant.

```yaml
- name: "HomeAssistant"
logo: "assets/tools/sample.png"
url: "http://192.168.0.151/"
type: "HomeAssistant"
apikey: "<---insert-api-key-here--->"
items: [] # optional, which items to show (and in which order) in the subtitle. Possible values are "name", "version", "entities"
separator: " " # optional, how to separate items
```
To create an API token on HomeAssistant, follow the [official documentation here](https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token).
To enable cors on HomeAssistant, edit your `configuration.yml` and add the IP of Homer to `https: cors_allowed_origins`
88 changes: 88 additions & 0 deletions docs/kubernetes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Kubernetes Installation

We have different solution to install Homer on Kubernetes Cluster, each solution responds to a specific need.


## Table of Contents

- [Helm Chart](#helm-chart)
- [Controller With CRDs](#controller-crds)
- [Controller With Ingress Annotations](#controller-annotations)
- [Operator](#Operator)

## Helm Chart

To deploy Homer in Kubernetes

Thanks to [@djjudas21](https://github.com/djjudas21) [charts](https://github.com/djjudas21/charts/tree/main/charts/homer):

### Installation

```sh
helm repo add djjudas21 https://djjudas21.github.io/charts/
helm repo update djjudas21

# install with all defaults
helm install homer djjudas21/homer

# install with customisations
wget https://raw.githubusercontent.com/djjudas21/charts/main/charts/homer/values.yaml
# edit values.yaml
helm install homer djjudas21/homer -f values.yaml
```

## Controller CRDs

To deploy Homer in Kubernetes with [Custom Resources Definition](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) to dynamic declaration for Homer Service

Thanks to [@jplanckeel](https://github.com/jplanckeel) [homer-k8s](https://github.com/bananaops/homer-k8s/tree/main/):

### Installation

```sh
helm repo add bananaops https://bananaops.github.io/homer-k8s/
helm repo update bananaops

# install with all defaults
helm install homer bananaops/homer-k8s

# install with customisations
wget https://raw.githubusercontent.com/bananaops/homer-k8s/main/helm/homer-k8s/values.yaml
# edit values.yaml
helm install homer bananaops/homer-k8s -f values.yaml
```

### Usage

- [usage](https://github.com/bananaops/homer-k8s/tree/main/?tab=readme-ov-file#crds-homerservices)

## Controller Annotations

To deploy Homer in Kubernetes with controller to check ingress annoation and modify homer configuration

Thanks to [@paulfantom](https://github.com/paulfantom) [homer-reloader](https://github.com/paulfantom/homer-reloader/tree/main/):


## Operator

To deploy many Homer in Kubernetes with [Custom Resources Definition](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/)

Thanks to [@rajsinghtech](https://github.com/rajsinghtech) [homer-operator](https://github.com/rajsinghtech/homer-operator/tree/main/):


### Installation

```sh
# install with customisations
wget https://raw.githubusercontent.com/rajsinghtech/homer-operator/main/deploy/operator.yaml
# Apply operator file
kubectl apply -f operator.yaml
```

### Usage

- [usage](https://github.com/rajsinghtech/homer-operator?tab=readme-ov-file#usage)




2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homer",
"version": "24.04.1",
"version": "24.05.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
167 changes: 167 additions & 0 deletions src/components/services/HomeAssistant.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<template>
<Generic :item="item">
<template #content>
<p class="title is-4">{{ item.name }}</p>
<p class="subtitle is-6">
<template v-if="item.subtitle">
{{ item.subtitle }}
</template>
<template v-else>
{{ details }}
</template>
</p>
</template>
<template #indicator>
<div v-if="status" class="status" :class="status">
{{ status }}
</div>
</template>
</Generic>
</template>

<script>
import service from "@/mixins/service.js";
import Generic from "./Generic.vue";
export default {
name: "HomeAssistant",
mixins: [service],
props: {
item: Object,
},
components: {
Generic,
},
data: () => ({
status: "",
version: "",
entities: 0,
location_name: "",
separator: " ",
items: ["name", "version"],
}),
computed: {
headers: function () {
return {
'Authorization': `Bearer ${this.item.apikey}`,
'Content-Type': 'application/json',
};
},
details: function () {
const details = [];
const items = this.items;
const separator = this.separator;
for (const i in items) {
const key = items[i];
switch (key) {
case "version":
details.push(
`v${this.version}`,
);
break;
case "name":
details.push(
`${this.location_name}`,
);
break;
case "entities":
details.push(
`${this.entities} entities`,
);
break;
default:
details.push(
`undefined key ${key} `,
);
}
}
return details.join(separator);
},
},
created() {
this.fetchServerStatus().then(() => {
if (!this.item.subtitle && this.status !== "dead") {
if (this.item.items) this.items = this.item.items;
if (this.item.separator) this.separator = this.item.separator;
this.fetchServerStats();
}
});
},
methods: {
fetchServerStatus: async function () {
const headers = this.headers;
return this.fetch("/api/", { headers })
.then((response) => {
if (response && response.message) this.status = "running";
else throw new Error();
})
.catch((e) => {
console.log(e);
this.status = "dead";
});
},
fetchServerStats: async function () {
const headers = this.headers;
this.fetch("/api/config", { headers })
.then((response) => {
if (response) {
if (response.version) this.version = response.version;
if (response.location_name) this.location_name = response.location_name;
}
else throw new Error();
})
.catch((e) => {
console.log(e);
this.status = "dead";
});
this.fetch("/api/states", { headers })
.then((response) => {
if (response) {
this.entities = response.length;
}
else throw new Error();
})
.catch((e) => {
console.log(e);
this.status = "dead";
});
},
},
};
</script>

<style scoped lang="scss">
.status {
font-size: 0.8rem;
color: var(--text-title);
&.running:before {
background-color: #94e185;
border-color: #78d965;
box-shadow: 0 0 5px 1px #94e185;
}
&.dead:before {
background-color: #c9404d;
border-color: #c42c3b;
box-shadow: 0 0 5px 1px #c9404d;
}
&:before {
content: " ";
display: inline-block;
width: 7px;
height: 7px;
margin-right: 10px;
border: 1px solid #000;
border-radius: 7px;
}
}
</style>

0 comments on commit 711f873

Please sign in to comment.