Compare commits

...

2 Commits

Author SHA1 Message Date
9a3f622941 updated readme 2024-01-30 13:54:04 +01:00
aca5de8cff new pipeline version handling 2024-01-30 13:35:40 +01:00
5 changed files with 66 additions and 15 deletions

View File

@ -1,7 +1,6 @@
name: Publish Docker image
on:
push
on: push
jobs:
push_to_registry:
@ -10,22 +9,35 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Run read-yaml action
id: yaml-data
uses: jbutcher5/read-yaml@1.6
with:
file: "./matter-bridge/config.yml"
key-path: '["version"]'
- name: Display read-yaml output
run: echo "${{ steps.yaml-data.outputs.data }}"
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
uses: docker/login-action@v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ steps.yaml-data.outputs.data }}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
uses: docker/build-push-action@v5.1.0
with:
context: ./matter-bridge
file: ./matter-bridge/Dockerfile

View File

@ -6,9 +6,14 @@ This project serves as a proof of concept to connect HomeAssistant devices to Vo
## Getting Started
### Prerequisites
### Setup
- Add this repository to your home assistant install
- Add this repository to your home assistant install \
[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2FJatus93%2Fha-matter-bridge)
- click on check for updates
- click on HA Matter Bridge
- install
### Configuration

View File

@ -35,10 +35,10 @@ export class HAMiddleware {
subscribe() {
this.hassClient.on('state_changed', (event) => {
this.logger.debug(event);
this.logger.debug(JSON.stringify(event));
const toDo = this.functionsToCallOnChange[event.data.entity_id];
if (toDo) {
toDo(event.data);
toDo(event);
}
});
}
@ -58,7 +58,7 @@ export class HAMiddleware {
},
{}
);
this.logger.debug({ getStates: sorted });
this.logger.debug(JSON.stringify({ getStates: sorted }));
this.entities = sorted;
return this.entities;
}
@ -75,7 +75,9 @@ export class HAMiddleware {
prev[key].push(states[current]);
return prev;
}, {});
this.logger.debug({ getStatesPartitionedByType: toReturn });
this.logger.debug(
JSON.stringify({ getStatesPartitionedByType: toReturn })
);
return toReturn;
}

View File

@ -16,16 +16,28 @@ export const addDimmerableLightDevice: AddHaDeviceToBridge = (
haMiddleware: HAMiddleware,
bridge: Bridge
): Device => {
LOGGER.debug(
`Building device ${haEntity.entity_id} \n ${JSON.stringify({
haEntity,
})}`
);
const device = new DimmableLightDevice(
{ onOff: haEntity.state === 'on' },
{
currentLevel: Number(haEntity.attributes['brightness']) || null,
currentLevel:
Number(haEntity.attributes['brightness']) / 255 || null,
onLevel: 0.1,
options: { coupleColorTempToLevel: false, executeIfOff: false },
}
);
const serialFromId = MD5(haEntity.entity_id).toString();
device.addOnOffListener((value, oldValue) => {
LOGGER.debug(
`OnOff Event for device ${haEntity.entity_id}, ${JSON.stringify({
value,
oldValue,
})}`
);
if (value !== oldValue) {
haMiddleware.callAService('light', value ? 'turn_on' : 'turn_off', {
entity_id: haEntity.entity_id,
@ -41,15 +53,21 @@ export const addDimmerableLightDevice: AddHaDeviceToBridge = (
);
device.addCurrentLevelListener((value) => {
LOGGER.debug(
`CurrentLevel Event for device ${haEntity.entity_id} value: ${value}`
);
haMiddleware.callAService(
'light',
Number(value) > 0 ? 'turn_on' : 'turn_off',
{ entity_id: haEntity.entity_id, brightness: Number(value) }
);
});
haMiddleware.subscrieToDevice(
haEntity.entity_id,
(event: StateChangedEvent) => {
LOGGER.debug(`Event for device ${haEntity.entity_id}`);
LOGGER.debug(JSON.stringify(event));
device.setOnOff(event.data.new_state?.state === 'on');
device.setCurrentLevel(
(event.data.new_state?.attributes as never)['brightness']

View File

@ -14,9 +14,21 @@ export const addOnOffLightDevice: AddHaDeviceToBridge = (
haMiddleware: HAMiddleware,
bridge: Bridge
): Device => {
LOGGER.debug(
`Building device ${haEntity.entity_id} \n ${JSON.stringify({
haEntity,
})}`
);
const device = new OnOffLightDevice();
const serialFromId = MD5(haEntity.entity_id).toString();
device.addOnOffListener((value, oldValue) => {
LOGGER.debug(
`OnOff Event for device ${haEntity.entity_id}, ${JSON.stringify({
value,
oldValue,
})}`
);
if (value !== oldValue) {
haMiddleware.callAService('light', value ? 'turn_on' : 'turn_off', {
entity_id: haEntity.entity_id,
@ -33,6 +45,8 @@ export const addOnOffLightDevice: AddHaDeviceToBridge = (
haMiddleware.subscrieToDevice(
haEntity.entity_id,
(event: StateChangedEvent) => {
LOGGER.debug(`Event for device ${haEntity.entity_id}`);
LOGGER.debug(JSON.stringify(event));
device.setOnOff(event.data.new_state?.state === 'on');
}
);