@@ -283,6 +283,11 @@ export class ShellyPlatform extends MatterbridgeDynamicPlatform {
283283 // this.log.warn(`Added EveHistory cluster to ${device.id} component ${key}`);
284284 }
285285
286+ // TODO: Add the WindowCovering attributes
287+ /*
288+ "pos_control": true,
289+ "current_pos": 0
290+ */
286291 // Set the WindowCovering attributes
287292 mbDevice . setWindowCoveringTargetAsCurrentAndStopped ( child ) ;
288293 // Add command handlers
@@ -733,13 +738,27 @@ export class ShellyPlatform extends MatterbridgeDynamicPlatform {
733738 const cluster = endpoint . getClusterServer ( EveHistoryCluster . with ( EveHistory . Feature . EveEnergy ) ) ;
734739 cluster ?. setConsumptionAttribute ( value as number ) ;
735740 if ( cluster ) shellyDevice . log . info ( `${ db } Update endpoint ${ or } ${ endpoint . number } ${ db } attribute ${ hk } EveHistory-consumption${ db } ${ YELLOW } ${ value as number } ${ db } ` ) ;
741+ const voltage = shellyComponent . getValue ( 'voltage' ) as number ;
742+ if ( voltage ) {
743+ const current = ( value as number ) / voltage ;
744+ cluster ?. setCurrentAttribute ( current as number ) ;
745+ shellyDevice . log . info ( `${ db } Update endpoint ${ or } ${ endpoint . number } ${ db } attribute ${ hk } EveHistory-current${ db } ${ YELLOW } ${ current as number } ${ db } ` ) ;
746+ }
736747 }
737748 if ( property === 'total' ) {
738749 const cluster = endpoint . getClusterServer ( EveHistoryCluster . with ( EveHistory . Feature . EveEnergy ) ) ;
739750 cluster ?. setTotalConsumptionAttribute ( ( value as number ) / 1000 ) ; // convert to kWh
740751 if ( cluster )
741752 shellyDevice . log . info ( `${ db } Update endpoint ${ or } ${ endpoint . number } ${ db } attribute ${ hk } EveHistory-totalConsumption${ db } ${ YELLOW } ${ ( value as number ) / 1000 } ${ db } ` ) ;
742753 }
754+ if ( property === 'aenergy' ) {
755+ const cluster = endpoint . getClusterServer ( EveHistoryCluster . with ( EveHistory . Feature . EveEnergy ) ) ;
756+ cluster ?. setTotalConsumptionAttribute ( ( ( value as ShellyData ) . total as number ) / 1000 ) ; // convert to kWh
757+ if ( cluster )
758+ shellyDevice . log . info (
759+ `${ db } Update endpoint ${ or } ${ endpoint . number } ${ db } attribute ${ hk } EveHistory-totalConsumption${ db } ${ YELLOW } ${ ( ( value as ShellyData ) . total as number ) / 1000 } ${ db } ` ,
760+ ) ;
761+ }
743762 if ( property === 'voltage' ) {
744763 const cluster = endpoint . getClusterServer ( EveHistoryCluster . with ( EveHistory . Feature . EveEnergy ) ) ;
745764 cluster ?. setVoltageAttribute ( value as number ) ;
0 commit comments