Skip to content

Commit

Permalink
Release 0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Jun 25, 2024
1 parent 93aab36 commit d4f7f4c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
### Added

- [color]: Added ColorControl cluster to shelly device with rgb.
- [current]: Added the current value to EveHistory electrical cluster.

### Fixed

Expand Down
19 changes: 19 additions & 0 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ export class ShellyPlatform extends MatterbridgeDynamicPlatform {
// this.log.warn(`Added EveHistory cluster to ${device.id} component ${key}`);
}

// TODO: Add the WindowCovering attributes
/*
"pos_control": true,
"current_pos": 0
*/
// Set the WindowCovering attributes
mbDevice.setWindowCoveringTargetAsCurrentAndStopped(child);
// Add command handlers
Expand Down Expand Up @@ -733,13 +738,27 @@ export class ShellyPlatform extends MatterbridgeDynamicPlatform {
const cluster = endpoint.getClusterServer(EveHistoryCluster.with(EveHistory.Feature.EveEnergy));
cluster?.setConsumptionAttribute(value as number);
if (cluster) shellyDevice.log.info(`${db}Update endpoint ${or}${endpoint.number}${db} attribute ${hk}EveHistory-consumption${db} ${YELLOW}${value as number}${db}`);
const voltage = shellyComponent.getValue('voltage') as number;
if (voltage) {
const current = (value as number) / voltage;
cluster?.setCurrentAttribute(current as number);
shellyDevice.log.info(`${db}Update endpoint ${or}${endpoint.number}${db} attribute ${hk}EveHistory-current${db} ${YELLOW}${current as number}${db}`);
}
}
if (property === 'total') {
const cluster = endpoint.getClusterServer(EveHistoryCluster.with(EveHistory.Feature.EveEnergy));
cluster?.setTotalConsumptionAttribute((value as number) / 1000); // convert to kWh
if (cluster)
shellyDevice.log.info(`${db}Update endpoint ${or}${endpoint.number}${db} attribute ${hk}EveHistory-totalConsumption${db} ${YELLOW}${(value as number) / 1000}${db}`);
}
if (property === 'aenergy') {
const cluster = endpoint.getClusterServer(EveHistoryCluster.with(EveHistory.Feature.EveEnergy));
cluster?.setTotalConsumptionAttribute(((value as ShellyData).total as number) / 1000); // convert to kWh
if (cluster)
shellyDevice.log.info(
`${db}Update endpoint ${or}${endpoint.number}${db} attribute ${hk}EveHistory-totalConsumption${db} ${YELLOW}${((value as ShellyData).total as number) / 1000}${db}`,
);
}
if (property === 'voltage') {
const cluster = endpoint.getClusterServer(EveHistoryCluster.with(EveHistory.Feature.EveEnergy));
cluster?.setVoltageAttribute(value as number);
Expand Down

0 comments on commit d4f7f4c

Please sign in to comment.