Compare commits
2 Commits
c3df0aa619
...
9a3f622941
Author | SHA1 | Date | |
---|---|---|---|
9a3f622941 | |||
aca5de8cff |
@ -6,9 +6,14 @@ This project serves as a proof of concept to connect HomeAssistant devices to Vo
|
|||||||
|
|
||||||
## Getting Started
|
## 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
|
### Configuration
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@ export const addDimmerableLightDevice: AddHaDeviceToBridge = (
|
|||||||
haMiddleware: HAMiddleware,
|
haMiddleware: HAMiddleware,
|
||||||
bridge: Bridge
|
bridge: Bridge
|
||||||
): Device => {
|
): Device => {
|
||||||
|
LOGGER.debug(
|
||||||
|
`Building device ${haEntity.entity_id} \n ${JSON.stringify({
|
||||||
|
haEntity,
|
||||||
|
})}`
|
||||||
|
);
|
||||||
const device = new DimmableLightDevice(
|
const device = new DimmableLightDevice(
|
||||||
{ onOff: haEntity.state === 'on' },
|
{ onOff: haEntity.state === 'on' },
|
||||||
{
|
{
|
||||||
@ -27,6 +32,12 @@ export const addDimmerableLightDevice: AddHaDeviceToBridge = (
|
|||||||
);
|
);
|
||||||
const serialFromId = MD5(haEntity.entity_id).toString();
|
const serialFromId = MD5(haEntity.entity_id).toString();
|
||||||
device.addOnOffListener((value, oldValue) => {
|
device.addOnOffListener((value, oldValue) => {
|
||||||
|
LOGGER.debug(
|
||||||
|
`OnOff Event for device ${haEntity.entity_id}, ${JSON.stringify({
|
||||||
|
value,
|
||||||
|
oldValue,
|
||||||
|
})}`
|
||||||
|
);
|
||||||
if (value !== oldValue) {
|
if (value !== oldValue) {
|
||||||
haMiddleware.callAService('light', value ? 'turn_on' : 'turn_off', {
|
haMiddleware.callAService('light', value ? 'turn_on' : 'turn_off', {
|
||||||
entity_id: haEntity.entity_id,
|
entity_id: haEntity.entity_id,
|
||||||
@ -42,12 +53,16 @@ export const addDimmerableLightDevice: AddHaDeviceToBridge = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
device.addCurrentLevelListener((value) => {
|
device.addCurrentLevelListener((value) => {
|
||||||
|
LOGGER.debug(
|
||||||
|
`CurrentLevel Event for device ${haEntity.entity_id} value: ${value}`
|
||||||
|
);
|
||||||
haMiddleware.callAService(
|
haMiddleware.callAService(
|
||||||
'light',
|
'light',
|
||||||
Number(value) > 0 ? 'turn_on' : 'turn_off',
|
Number(value) > 0 ? 'turn_on' : 'turn_off',
|
||||||
{ entity_id: haEntity.entity_id, brightness: Number(value) }
|
{ entity_id: haEntity.entity_id, brightness: Number(value) }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
haMiddleware.subscrieToDevice(
|
haMiddleware.subscrieToDevice(
|
||||||
haEntity.entity_id,
|
haEntity.entity_id,
|
||||||
(event: StateChangedEvent) => {
|
(event: StateChangedEvent) => {
|
||||||
|
@ -14,9 +14,21 @@ export const addOnOffLightDevice: AddHaDeviceToBridge = (
|
|||||||
haMiddleware: HAMiddleware,
|
haMiddleware: HAMiddleware,
|
||||||
bridge: Bridge
|
bridge: Bridge
|
||||||
): Device => {
|
): Device => {
|
||||||
|
LOGGER.debug(
|
||||||
|
`Building device ${haEntity.entity_id} \n ${JSON.stringify({
|
||||||
|
haEntity,
|
||||||
|
})}`
|
||||||
|
);
|
||||||
const device = new OnOffLightDevice();
|
const device = new OnOffLightDevice();
|
||||||
const serialFromId = MD5(haEntity.entity_id).toString();
|
const serialFromId = MD5(haEntity.entity_id).toString();
|
||||||
device.addOnOffListener((value, oldValue) => {
|
device.addOnOffListener((value, oldValue) => {
|
||||||
|
LOGGER.debug(
|
||||||
|
`OnOff Event for device ${haEntity.entity_id}, ${JSON.stringify({
|
||||||
|
value,
|
||||||
|
oldValue,
|
||||||
|
})}`
|
||||||
|
);
|
||||||
|
|
||||||
if (value !== oldValue) {
|
if (value !== oldValue) {
|
||||||
haMiddleware.callAService('light', value ? 'turn_on' : 'turn_off', {
|
haMiddleware.callAService('light', value ? 'turn_on' : 'turn_off', {
|
||||||
entity_id: haEntity.entity_id,
|
entity_id: haEntity.entity_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user