@enyo-energy/energy-app-sdk 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +216 -0
- package/dist/cjs/connect-ems-api.cjs +2 -0
- package/dist/cjs/connect-ems-api.d.cts +30 -0
- package/dist/cjs/connect-ems-permission.enum.cjs +7 -0
- package/dist/cjs/connect-ems-permission.enum.d.cts +3 -0
- package/dist/cjs/connect-ems-permission.type.cjs +2 -0
- package/dist/cjs/connect-ems-permission.type.d.cts +1 -0
- package/dist/cjs/connect-package-definition.cjs +14 -0
- package/dist/cjs/connect-package-definition.d.cts +57 -0
- package/dist/cjs/energy-app-appliance-type.enum.cjs +14 -0
- package/dist/cjs/energy-app-appliance-type.enum.d.cts +10 -0
- package/dist/cjs/energy-app-package-configuration.cjs +2 -0
- package/dist/cjs/energy-app-package-configuration.d.cts +30 -0
- package/dist/cjs/energy-app-package-definition.cjs +30 -0
- package/dist/cjs/energy-app-package-definition.d.cts +123 -0
- package/dist/cjs/energy-app-permission.type.cjs +21 -0
- package/dist/cjs/energy-app-permission.type.d.cts +18 -0
- package/dist/cjs/enyo-energy-app-sdk.cjs +12 -0
- package/dist/cjs/enyo-energy-app-sdk.d.cts +67 -0
- package/dist/cjs/hems-one-energy-app-sdk.cjs +12 -0
- package/dist/cjs/hems-one-energy-app-sdk.d.cts +64 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusBattery.cjs +388 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusBattery.d.cts +59 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusConnectionHealth.cjs +37 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusConnectionHealth.d.cts +15 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusDataTypeConverter.cjs +130 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusDataTypeConverter.d.cts +41 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusFaultTolerantReader.cjs +49 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusFaultTolerantReader.d.cts +10 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusInverter.cjs +348 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusInverter.d.cts +56 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusMeter.cjs +199 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusMeter.d.cts +26 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusRegisterMapper.cjs +98 -0
- package/dist/cjs/implementations/modbus/EnergyAppModbusRegisterMapper.d.cts +13 -0
- package/dist/cjs/implementations/modbus/interfaces.cjs +29 -0
- package/dist/cjs/implementations/modbus/interfaces.d.cts +202 -0
- package/dist/cjs/implementations/ocpp/ocpp-common.cjs +337 -0
- package/dist/cjs/implementations/ocpp/ocpp-common.d.cts +75 -0
- package/dist/cjs/implementations/ocpp/ocpp16.cjs +51 -0
- package/dist/cjs/implementations/ocpp/ocpp16.d.cts +137 -0
- package/dist/cjs/implementations/ocpp/ocpp201.cjs +84 -0
- package/dist/cjs/implementations/ocpp/ocpp201.d.cts +215 -0
- package/dist/cjs/index.cjs +117 -0
- package/dist/cjs/index.d.cts +56 -0
- package/dist/cjs/mockConnectEmsApi.cjs +167 -0
- package/dist/cjs/mockConnectEmsApi.d.cts +10 -0
- package/dist/cjs/packages/connect-appliance.cjs +2 -0
- package/dist/cjs/packages/connect-appliance.d.cts +24 -0
- package/dist/cjs/packages/connect-http-api.cjs +2 -0
- package/dist/cjs/packages/connect-http-api.d.cts +15 -0
- package/dist/cjs/packages/connect-interval.cjs +2 -0
- package/dist/cjs/packages/connect-interval.d.cts +15 -0
- package/dist/cjs/packages/connect-modbus.cjs +2 -0
- package/dist/cjs/packages/connect-modbus.d.cts +60 -0
- package/dist/cjs/packages/connect-network-devices.cjs +2 -0
- package/dist/cjs/packages/connect-network-devices.d.cts +40 -0
- package/dist/cjs/packages/connect-storage.cjs +2 -0
- package/dist/cjs/packages/connect-storage.d.cts +14 -0
- package/dist/cjs/packages/energy-app-appliance.cjs +2 -0
- package/dist/cjs/packages/energy-app-appliance.d.cts +17 -0
- package/dist/cjs/packages/energy-app-authentication.cjs +2 -0
- package/dist/cjs/packages/energy-app-authentication.d.cts +52 -0
- package/dist/cjs/packages/energy-app-charge.cjs +2 -0
- package/dist/cjs/packages/energy-app-charge.d.cts +13 -0
- package/dist/cjs/packages/energy-app-charging-card.cjs +2 -0
- package/dist/cjs/packages/energy-app-charging-card.d.cts +11 -0
- package/dist/cjs/packages/energy-app-data-bus.cjs +2 -0
- package/dist/cjs/packages/energy-app-data-bus.d.cts +12 -0
- package/dist/cjs/packages/energy-app-electricity-prices.cjs +2 -0
- package/dist/cjs/packages/energy-app-electricity-prices.d.cts +59 -0
- package/dist/cjs/packages/energy-app-interval.cjs +2 -0
- package/dist/cjs/packages/energy-app-interval.d.cts +15 -0
- package/dist/cjs/packages/energy-app-modbus.cjs +2 -0
- package/dist/cjs/packages/energy-app-modbus.d.cts +46 -0
- package/dist/cjs/packages/energy-app-network-device.cjs +2 -0
- package/dist/cjs/packages/energy-app-network-device.d.cts +25 -0
- package/dist/cjs/packages/energy-app-notification.cjs +2 -0
- package/dist/cjs/packages/energy-app-notification.d.cts +50 -0
- package/dist/cjs/packages/energy-app-ocpp.cjs +16 -0
- package/dist/cjs/packages/energy-app-ocpp.d.cts +52 -0
- package/dist/cjs/packages/energy-app-settings.cjs +2 -0
- package/dist/cjs/packages/energy-app-settings.d.cts +47 -0
- package/dist/cjs/packages/energy-app-storage.cjs +2 -0
- package/dist/cjs/packages/energy-app-storage.d.cts +14 -0
- package/dist/cjs/packages/energy-app-vehicle.cjs +2 -0
- package/dist/cjs/packages/energy-app-vehicle.d.cts +11 -0
- package/dist/cjs/permission-not-granted.cjs +18 -0
- package/dist/cjs/permission-not-granted.d.cts +8 -0
- package/dist/cjs/types/connect-appliance-type.enum.cjs +10 -0
- package/dist/cjs/types/connect-appliance-type.enum.d.cts +6 -0
- package/dist/cjs/types/energy-app-settings.cjs +2 -0
- package/dist/cjs/types/energy-app-settings.d.cts +74 -0
- package/dist/cjs/types/enyo-appliance.cjs +33 -0
- package/dist/cjs/types/enyo-appliance.d.cts +81 -0
- package/dist/cjs/types/enyo-authentication.cjs +9 -0
- package/dist/cjs/types/enyo-authentication.d.cts +69 -0
- package/dist/cjs/types/enyo-battery-appliance.cjs +2 -0
- package/dist/cjs/types/enyo-battery-appliance.d.cts +6 -0
- package/dist/cjs/types/enyo-charge.cjs +15 -0
- package/dist/cjs/types/enyo-charge.d.cts +82 -0
- package/dist/cjs/types/enyo-charger-appliance.cjs +41 -0
- package/dist/cjs/types/enyo-charger-appliance.d.cts +49 -0
- package/dist/cjs/types/enyo-charging-card.cjs +2 -0
- package/dist/cjs/types/enyo-charging-card.d.cts +11 -0
- package/dist/cjs/types/enyo-data-bus-value.cjs +78 -0
- package/dist/cjs/types/enyo-data-bus-value.d.cts +379 -0
- package/dist/cjs/types/enyo-electricity-prices.cjs +2 -0
- package/dist/cjs/types/enyo-electricity-prices.d.cts +63 -0
- package/dist/cjs/types/enyo-energy-tariff.cjs +2 -0
- package/dist/cjs/types/enyo-energy-tariff.d.cts +70 -0
- package/dist/cjs/types/enyo-heatpump-appliance.cjs +19 -0
- package/dist/cjs/types/enyo-heatpump-appliance.d.cts +34 -0
- package/dist/cjs/types/enyo-inverter-appliance.cjs +2 -0
- package/dist/cjs/types/enyo-inverter-appliance.d.cts +3 -0
- package/dist/cjs/types/enyo-meter-appliance.cjs +10 -0
- package/dist/cjs/types/enyo-meter-appliance.d.cts +10 -0
- package/dist/cjs/types/enyo-network-device.cjs +2 -0
- package/dist/cjs/types/enyo-network-device.d.cts +31 -0
- package/dist/cjs/types/enyo-notification.cjs +2 -0
- package/dist/cjs/types/enyo-notification.d.cts +48 -0
- package/dist/cjs/types/enyo-settings.cjs +2 -0
- package/dist/cjs/types/enyo-settings.d.cts +74 -0
- package/dist/cjs/types/enyo-source.enum.cjs +8 -0
- package/dist/cjs/types/enyo-source.enum.d.cts +4 -0
- package/dist/cjs/types/enyo-vehicle.cjs +2 -0
- package/dist/cjs/types/enyo-vehicle.d.cts +12 -0
- package/dist/cjs/types/enyo-websocket-connection.cjs +2 -0
- package/dist/cjs/types/enyo-websocket-connection.d.cts +8 -0
- package/dist/cjs/types/hems-one-appliance.cjs +33 -0
- package/dist/cjs/types/hems-one-appliance.d.cts +81 -0
- package/dist/cjs/types/hems-one-authentication.cjs +9 -0
- package/dist/cjs/types/hems-one-authentication.d.cts +69 -0
- package/dist/cjs/types/hems-one-battery-appliance.cjs +2 -0
- package/dist/cjs/types/hems-one-battery-appliance.d.cts +6 -0
- package/dist/cjs/types/hems-one-charge.cjs +15 -0
- package/dist/cjs/types/hems-one-charge.d.cts +82 -0
- package/dist/cjs/types/hems-one-charger-appliance.cjs +41 -0
- package/dist/cjs/types/hems-one-charger-appliance.d.cts +49 -0
- package/dist/cjs/types/hems-one-charging-card.cjs +2 -0
- package/dist/cjs/types/hems-one-charging-card.d.cts +11 -0
- package/dist/cjs/types/hems-one-data-bus-command.cjs +9 -0
- package/dist/cjs/types/hems-one-data-bus-command.d.cts +34 -0
- package/dist/cjs/types/hems-one-data-bus-value.cjs +78 -0
- package/dist/cjs/types/hems-one-data-bus-value.d.cts +379 -0
- package/dist/cjs/types/hems-one-electricity-prices.cjs +2 -0
- package/dist/cjs/types/hems-one-electricity-prices.d.cts +63 -0
- package/dist/cjs/types/hems-one-energy-tariff.cjs +2 -0
- package/dist/cjs/types/hems-one-energy-tariff.d.cts +70 -0
- package/dist/cjs/types/hems-one-heatpump-appliance.cjs +19 -0
- package/dist/cjs/types/hems-one-heatpump-appliance.d.cts +34 -0
- package/dist/cjs/types/hems-one-inverter-appliance.cjs +2 -0
- package/dist/cjs/types/hems-one-inverter-appliance.d.cts +3 -0
- package/dist/cjs/types/hems-one-meter-appliance.cjs +10 -0
- package/dist/cjs/types/hems-one-meter-appliance.d.cts +10 -0
- package/dist/cjs/types/hems-one-network-device.cjs +2 -0
- package/dist/cjs/types/hems-one-network-device.d.cts +31 -0
- package/dist/cjs/types/hems-one-source.enum.cjs +8 -0
- package/dist/cjs/types/hems-one-source.enum.d.cts +4 -0
- package/dist/cjs/types/hems-one-vehicle.cjs +2 -0
- package/dist/cjs/types/hems-one-vehicle.d.cts +12 -0
- package/dist/cjs/types/hems-one-websocket-connection.cjs +2 -0
- package/dist/cjs/types/hems-one-websocket-connection.d.cts +8 -0
- package/dist/cjs/version.cjs +19 -0
- package/dist/cjs/version.d.cts +13 -0
- package/dist/connect-ems-api.d.ts +30 -0
- package/dist/connect-ems-api.js +1 -0
- package/dist/connect-ems-permission.enum.d.ts +3 -0
- package/dist/connect-ems-permission.enum.js +4 -0
- package/dist/connect-ems-permission.type.d.ts +1 -0
- package/dist/connect-ems-permission.type.js +1 -0
- package/dist/connect-package-definition.d.ts +57 -0
- package/dist/connect-package-definition.js +10 -0
- package/dist/energy-app-appliance-type.enum.d.ts +10 -0
- package/dist/energy-app-appliance-type.enum.js +11 -0
- package/dist/energy-app-package-configuration.d.ts +30 -0
- package/dist/energy-app-package-configuration.js +1 -0
- package/dist/energy-app-package-definition.d.ts +123 -0
- package/dist/energy-app-package-definition.js +26 -0
- package/dist/energy-app-permission.type.d.ts +18 -0
- package/dist/energy-app-permission.type.js +18 -0
- package/dist/enyo-energy-app-sdk.d.ts +67 -0
- package/dist/enyo-energy-app-sdk.js +9 -0
- package/dist/hems-one-energy-app-sdk.d.ts +67 -0
- package/dist/hems-one-energy-app-sdk.js +9 -0
- package/dist/implementations/modbus/EnergyAppModbusBattery.d.ts +59 -0
- package/dist/implementations/modbus/EnergyAppModbusBattery.js +384 -0
- package/dist/implementations/modbus/EnergyAppModbusConnectionHealth.d.ts +15 -0
- package/dist/implementations/modbus/EnergyAppModbusConnectionHealth.js +33 -0
- package/dist/implementations/modbus/EnergyAppModbusDataTypeConverter.d.ts +41 -0
- package/dist/implementations/modbus/EnergyAppModbusDataTypeConverter.js +126 -0
- package/dist/implementations/modbus/EnergyAppModbusFaultTolerantReader.d.ts +10 -0
- package/dist/implementations/modbus/EnergyAppModbusFaultTolerantReader.js +45 -0
- package/dist/implementations/modbus/EnergyAppModbusInverter.d.ts +56 -0
- package/dist/implementations/modbus/EnergyAppModbusInverter.js +344 -0
- package/dist/implementations/modbus/EnergyAppModbusMeter.d.ts +26 -0
- package/dist/implementations/modbus/EnergyAppModbusMeter.js +195 -0
- package/dist/implementations/modbus/EnergyAppModbusRegisterMapper.d.ts +13 -0
- package/dist/implementations/modbus/EnergyAppModbusRegisterMapper.js +94 -0
- package/dist/implementations/modbus/interfaces.d.ts +202 -0
- package/dist/implementations/modbus/interfaces.js +23 -0
- package/dist/implementations/ocpp/ocpp-common.d.ts +75 -0
- package/dist/implementations/ocpp/ocpp-common.js +328 -0
- package/dist/implementations/ocpp/ocpp16.d.ts +137 -0
- package/dist/implementations/ocpp/ocpp16.js +48 -0
- package/dist/implementations/ocpp/ocpp201.d.ts +215 -0
- package/dist/implementations/ocpp/ocpp201.js +81 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +99 -0
- package/dist/mockConnectEmsApi.d.ts +10 -0
- package/dist/mockConnectEmsApi.js +160 -0
- package/dist/packages/connect-appliance.d.ts +24 -0
- package/dist/packages/connect-appliance.js +1 -0
- package/dist/packages/connect-http-api.d.ts +15 -0
- package/dist/packages/connect-http-api.js +1 -0
- package/dist/packages/connect-interval.d.ts +15 -0
- package/dist/packages/connect-interval.js +1 -0
- package/dist/packages/connect-modbus.d.ts +60 -0
- package/dist/packages/connect-modbus.js +1 -0
- package/dist/packages/connect-network-devices.d.ts +40 -0
- package/dist/packages/connect-network-devices.js +1 -0
- package/dist/packages/connect-storage.d.ts +14 -0
- package/dist/packages/connect-storage.js +1 -0
- package/dist/packages/energy-app-appliance.d.ts +17 -0
- package/dist/packages/energy-app-appliance.js +1 -0
- package/dist/packages/energy-app-authentication.d.ts +52 -0
- package/dist/packages/energy-app-authentication.js +1 -0
- package/dist/packages/energy-app-charge.d.ts +13 -0
- package/dist/packages/energy-app-charge.js +1 -0
- package/dist/packages/energy-app-charging-card.d.ts +11 -0
- package/dist/packages/energy-app-charging-card.js +1 -0
- package/dist/packages/energy-app-data-bus.d.ts +12 -0
- package/dist/packages/energy-app-data-bus.js +1 -0
- package/dist/packages/energy-app-electricity-prices.d.ts +59 -0
- package/dist/packages/energy-app-electricity-prices.js +1 -0
- package/dist/packages/energy-app-interval.d.ts +15 -0
- package/dist/packages/energy-app-interval.js +1 -0
- package/dist/packages/energy-app-modbus.d.ts +46 -0
- package/dist/packages/energy-app-modbus.js +1 -0
- package/dist/packages/energy-app-network-device.d.ts +25 -0
- package/dist/packages/energy-app-network-device.js +1 -0
- package/dist/packages/energy-app-notification.d.ts +50 -0
- package/dist/packages/energy-app-notification.js +1 -0
- package/dist/packages/energy-app-ocpp.d.ts +52 -0
- package/dist/packages/energy-app-ocpp.js +13 -0
- package/dist/packages/energy-app-settings.d.ts +47 -0
- package/dist/packages/energy-app-settings.js +1 -0
- package/dist/packages/energy-app-storage.d.ts +14 -0
- package/dist/packages/energy-app-storage.js +1 -0
- package/dist/packages/energy-app-vehicle.d.ts +11 -0
- package/dist/packages/energy-app-vehicle.js +1 -0
- package/dist/permission-not-granted.d.ts +8 -0
- package/dist/permission-not-granted.js +14 -0
- package/dist/types/connect-appliance-type.enum.d.ts +6 -0
- package/dist/types/connect-appliance-type.enum.js +7 -0
- package/dist/types/energy-app-settings.d.ts +74 -0
- package/dist/types/energy-app-settings.js +1 -0
- package/dist/types/enyo-appliance.d.ts +81 -0
- package/dist/types/enyo-appliance.js +30 -0
- package/dist/types/enyo-authentication.d.ts +69 -0
- package/dist/types/enyo-authentication.js +6 -0
- package/dist/types/enyo-battery-appliance.d.ts +6 -0
- package/dist/types/enyo-battery-appliance.js +1 -0
- package/dist/types/enyo-charge.d.ts +82 -0
- package/dist/types/enyo-charge.js +12 -0
- package/dist/types/enyo-charger-appliance.d.ts +49 -0
- package/dist/types/enyo-charger-appliance.js +38 -0
- package/dist/types/enyo-charging-card.d.ts +11 -0
- package/dist/types/enyo-charging-card.js +1 -0
- package/dist/types/enyo-data-bus-value.d.ts +379 -0
- package/dist/types/enyo-data-bus-value.js +75 -0
- package/dist/types/enyo-electricity-prices.d.ts +63 -0
- package/dist/types/enyo-electricity-prices.js +1 -0
- package/dist/types/enyo-energy-tariff.d.ts +70 -0
- package/dist/types/enyo-energy-tariff.js +1 -0
- package/dist/types/enyo-heatpump-appliance.d.ts +34 -0
- package/dist/types/enyo-heatpump-appliance.js +16 -0
- package/dist/types/enyo-inverter-appliance.d.ts +3 -0
- package/dist/types/enyo-inverter-appliance.js +1 -0
- package/dist/types/enyo-meter-appliance.d.ts +10 -0
- package/dist/types/enyo-meter-appliance.js +7 -0
- package/dist/types/enyo-network-device.d.ts +31 -0
- package/dist/types/enyo-network-device.js +1 -0
- package/dist/types/enyo-notification.d.ts +48 -0
- package/dist/types/enyo-notification.js +1 -0
- package/dist/types/enyo-settings.d.ts +74 -0
- package/dist/types/enyo-settings.js +1 -0
- package/dist/types/enyo-source.enum.d.ts +4 -0
- package/dist/types/enyo-source.enum.js +5 -0
- package/dist/types/enyo-vehicle.d.ts +12 -0
- package/dist/types/enyo-vehicle.js +1 -0
- package/dist/types/enyo-websocket-connection.d.ts +8 -0
- package/dist/types/enyo-websocket-connection.js +1 -0
- package/dist/types/hems-one-appliance.d.ts +81 -0
- package/dist/types/hems-one-appliance.js +30 -0
- package/dist/types/hems-one-authentication.d.ts +69 -0
- package/dist/types/hems-one-authentication.js +6 -0
- package/dist/types/hems-one-battery-appliance.d.ts +6 -0
- package/dist/types/hems-one-battery-appliance.js +1 -0
- package/dist/types/hems-one-charge.d.ts +82 -0
- package/dist/types/hems-one-charge.js +12 -0
- package/dist/types/hems-one-charger-appliance.d.ts +49 -0
- package/dist/types/hems-one-charger-appliance.js +38 -0
- package/dist/types/hems-one-charging-card.d.ts +11 -0
- package/dist/types/hems-one-charging-card.js +1 -0
- package/dist/types/hems-one-data-bus-command.d.ts +34 -0
- package/dist/types/hems-one-data-bus-command.js +6 -0
- package/dist/types/hems-one-data-bus-value.d.ts +379 -0
- package/dist/types/hems-one-data-bus-value.js +75 -0
- package/dist/types/hems-one-electricity-prices.d.ts +63 -0
- package/dist/types/hems-one-electricity-prices.js +1 -0
- package/dist/types/hems-one-energy-tariff.d.ts +70 -0
- package/dist/types/hems-one-energy-tariff.js +1 -0
- package/dist/types/hems-one-heatpump-appliance.d.ts +34 -0
- package/dist/types/hems-one-heatpump-appliance.js +16 -0
- package/dist/types/hems-one-inverter-appliance.d.ts +3 -0
- package/dist/types/hems-one-inverter-appliance.js +1 -0
- package/dist/types/hems-one-meter-appliance.d.ts +10 -0
- package/dist/types/hems-one-meter-appliance.js +7 -0
- package/dist/types/hems-one-network-device.d.ts +31 -0
- package/dist/types/hems-one-network-device.js +1 -0
- package/dist/types/hems-one-source.enum.d.ts +4 -0
- package/dist/types/hems-one-source.enum.js +5 -0
- package/dist/types/hems-one-vehicle.d.ts +12 -0
- package/dist/types/hems-one-vehicle.js +1 -0
- package/dist/types/hems-one-websocket-connection.d.ts +8 -0
- package/dist/types/hems-one-websocket-connection.js +1 -0
- package/dist/version.d.ts +13 -0
- package/dist/version.js +15 -0
- package/package.json +43 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { EnergyAppInterval } from "./packages/energy-app-interval.cjs";
|
|
2
|
+
import { EnergyAppModbus } from "./packages/energy-app-modbus.cjs";
|
|
3
|
+
import { EnergyAppStorage } from "./packages/energy-app-storage.cjs";
|
|
4
|
+
import { EnergyAppAppliance } from "./packages/energy-app-appliance.cjs";
|
|
5
|
+
import { EnergyAppNetworkDevice } from "./packages/energy-app-network-device.cjs";
|
|
6
|
+
import { EnergyAppDataBus } from "./packages/energy-app-data-bus.cjs";
|
|
7
|
+
import { EnergyAppOcpp } from "./packages/energy-app-ocpp.cjs";
|
|
8
|
+
import { EnergyAppCharge } from "./packages/energy-app-charge.cjs";
|
|
9
|
+
import { EnergyAppVehicle } from "./packages/energy-app-vehicle.cjs";
|
|
10
|
+
import { EnergyAppChargingCard } from "./packages/energy-app-charging-card.cjs";
|
|
11
|
+
import { EnergyAppAuthentication } from "./packages/energy-app-authentication.cjs";
|
|
12
|
+
import { EnergyAppSettings } from "./packages/energy-app-settings.cjs";
|
|
13
|
+
import { EnergyAppElectricityPrices } from "./packages/energy-app-electricity-prices.cjs";
|
|
14
|
+
import { EnergyAppNotification } from "./packages/energy-app-notification.cjs";
|
|
15
|
+
export declare enum EnergyAppStateEnum {
|
|
16
|
+
Launching = "launching",
|
|
17
|
+
Running = "running",
|
|
18
|
+
/** This state tells the user that a configuration is required which blocks the energy app from running*/
|
|
19
|
+
ConfigurationRequired = "configuration-required",
|
|
20
|
+
/** This state tells the user that an internet connection of the system is required which blocks the energy app from running*/
|
|
21
|
+
InternetConnectionRequired = "internet-connection-required"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Main API interface for enyo Energy App packages.
|
|
25
|
+
* Provides access to all system capabilities including lifecycle management,
|
|
26
|
+
* network operations, storage, and device communication.
|
|
27
|
+
*/
|
|
28
|
+
export interface EnyoEnergyAppSdk {
|
|
29
|
+
/** Register a callback that gets called when the package is initialized */
|
|
30
|
+
register: (callback: (packageName: string, version: number) => void) => void;
|
|
31
|
+
/** Register a callback that gets called when the system is shutting down */
|
|
32
|
+
onShutdown: (callback: () => Promise<void>) => void;
|
|
33
|
+
/** Update the state of the Energy App. Default state set is launching*/
|
|
34
|
+
updateEnergyAppState: (state: EnergyAppStateEnum) => void;
|
|
35
|
+
/** Check if the system is currently online */
|
|
36
|
+
isSystemOnline: () => boolean;
|
|
37
|
+
/** Get the fetch API for HTTP requests */
|
|
38
|
+
useFetch: () => typeof fetch;
|
|
39
|
+
/** Get the interval management API */
|
|
40
|
+
useInterval: () => EnergyAppInterval;
|
|
41
|
+
/** Get the Modbus communication API */
|
|
42
|
+
useModbus: () => EnergyAppModbus;
|
|
43
|
+
/** Get the network device discovery API */
|
|
44
|
+
useNetworkDevices: () => EnergyAppNetworkDevice;
|
|
45
|
+
/** Get the persistent storage API */
|
|
46
|
+
useStorage: () => EnergyAppStorage;
|
|
47
|
+
/** Get the Appliance API */
|
|
48
|
+
useAppliances: () => EnergyAppAppliance;
|
|
49
|
+
/** Get the Data Bus API */
|
|
50
|
+
useDataBus: () => EnergyAppDataBus;
|
|
51
|
+
/** Get the OCPP API */
|
|
52
|
+
useOcpp: () => EnergyAppOcpp;
|
|
53
|
+
/** Get the Charge API*/
|
|
54
|
+
useCharge: () => EnergyAppCharge;
|
|
55
|
+
/** Get the Vehicle API*/
|
|
56
|
+
useVehicle: () => EnergyAppVehicle;
|
|
57
|
+
/** Get the Charging Card API*/
|
|
58
|
+
useChargingCard: () => EnergyAppChargingCard;
|
|
59
|
+
/** Get the Authentication API */
|
|
60
|
+
useAuthentication: () => EnergyAppAuthentication;
|
|
61
|
+
/** Get the Settings API */
|
|
62
|
+
useSettings: () => EnergyAppSettings;
|
|
63
|
+
/** Get the Electricity Prices API */
|
|
64
|
+
useElectricityPrices: () => EnergyAppElectricityPrices;
|
|
65
|
+
/** Get the Notification API */
|
|
66
|
+
useNotification: () => EnergyAppNotification;
|
|
67
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnergyAppStateEnum = void 0;
|
|
4
|
+
var EnergyAppStateEnum;
|
|
5
|
+
(function (EnergyAppStateEnum) {
|
|
6
|
+
EnergyAppStateEnum["Launching"] = "launching";
|
|
7
|
+
EnergyAppStateEnum["Running"] = "running";
|
|
8
|
+
/** This state tells the user that a configuration is required which blocks the energy app from running*/
|
|
9
|
+
EnergyAppStateEnum["ConfigurationRequired"] = "configuration-required";
|
|
10
|
+
/** This state tells the user that an internet connection of the system is required which blocks the energy app from running*/
|
|
11
|
+
EnergyAppStateEnum["InternetConnectionRequired"] = "internet-connection-required";
|
|
12
|
+
})(EnergyAppStateEnum || (exports.EnergyAppStateEnum = EnergyAppStateEnum = {}));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { EnergyAppInterval } from "./packages/energy-app-interval.cjs";
|
|
2
|
+
import { EnergyAppModbus } from "./packages/energy-app-modbus.cjs";
|
|
3
|
+
import { EnergyAppStorage } from "./packages/energy-app-storage.cjs";
|
|
4
|
+
import { EnergyAppAppliance } from "./packages/energy-app-appliance.cjs";
|
|
5
|
+
import { EnergyAppNetworkDevice } from "./packages/energy-app-network-device.cjs";
|
|
6
|
+
import { EnergyAppDataBus } from "./packages/energy-app-data-bus.cjs";
|
|
7
|
+
import { EnergyAppOcpp } from "./packages/energy-app-ocpp.cjs";
|
|
8
|
+
import { EnergyAppCharge } from "./packages/energy-app-charge.cjs";
|
|
9
|
+
import { EnergyAppVehicle } from "./packages/energy-app-vehicle.cjs";
|
|
10
|
+
import { EnergyAppChargingCard } from "./packages/energy-app-charging-card.cjs";
|
|
11
|
+
import { EnergyAppAuthentication } from "./packages/energy-app-authentication.cjs";
|
|
12
|
+
import { EnergyAppSettings } from "./packages/energy-app-settings.cjs";
|
|
13
|
+
import { EnergyAppElectricityPrices } from "./packages/energy-app-electricity-prices.cjs";
|
|
14
|
+
export declare enum EnergyAppStateEnum {
|
|
15
|
+
Launching = "launching",
|
|
16
|
+
Running = "running",
|
|
17
|
+
/** This state tells the user that a configuration is required which blocks the energy app from running*/
|
|
18
|
+
ConfigurationRequired = "configuration-required",
|
|
19
|
+
/** This state tells the user that an internet connection of the system is required which blocks the energy app from running*/
|
|
20
|
+
InternetConnectionRequired = "internet-connection-required"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Main API interface for HEMS One Energy App packages.
|
|
24
|
+
* Provides access to all system capabilities including lifecycle management,
|
|
25
|
+
* network operations, storage, and device communication.
|
|
26
|
+
*/
|
|
27
|
+
export interface HemsOneEnergyAppSdk {
|
|
28
|
+
/** Register a callback that gets called when the package is initialized */
|
|
29
|
+
register: (callback: (packageName: string, version: number) => void) => void;
|
|
30
|
+
/** Register a callback that gets called when the system is shutting down */
|
|
31
|
+
onShutdown: (callback: () => Promise<void>) => void;
|
|
32
|
+
/** Update the state of the Energy App. Default state set is launching*/
|
|
33
|
+
updateEnergyAppState: (state: EnergyAppStateEnum) => void;
|
|
34
|
+
/** Check if the system is currently online */
|
|
35
|
+
isSystemOnline: () => boolean;
|
|
36
|
+
/** Get the fetch API for HTTP requests */
|
|
37
|
+
useFetch: () => typeof fetch;
|
|
38
|
+
/** Get the interval management API */
|
|
39
|
+
useInterval: () => EnergyAppInterval;
|
|
40
|
+
/** Get the Modbus communication API */
|
|
41
|
+
useModbus: () => EnergyAppModbus;
|
|
42
|
+
/** Get the network device discovery API */
|
|
43
|
+
useNetworkDevices: () => EnergyAppNetworkDevice;
|
|
44
|
+
/** Get the persistent storage API */
|
|
45
|
+
useStorage: () => EnergyAppStorage;
|
|
46
|
+
/** Get the Appliance API */
|
|
47
|
+
useAppliances: () => EnergyAppAppliance;
|
|
48
|
+
/** Get the Data Bus API */
|
|
49
|
+
useDataBus: () => EnergyAppDataBus;
|
|
50
|
+
/** Get the OCPP API */
|
|
51
|
+
useOcpp: () => EnergyAppOcpp;
|
|
52
|
+
/** Get the Charge API*/
|
|
53
|
+
useCharge: () => EnergyAppCharge;
|
|
54
|
+
/** Get the Vehicle API*/
|
|
55
|
+
useVehicle: () => EnergyAppVehicle;
|
|
56
|
+
/** Get the Charging Card API*/
|
|
57
|
+
useChargingCard: () => EnergyAppChargingCard;
|
|
58
|
+
/** Get the Authentication API */
|
|
59
|
+
useAuthentication: () => EnergyAppAuthentication;
|
|
60
|
+
/** Get the Settings API */
|
|
61
|
+
useSettings: () => EnergyAppSettings;
|
|
62
|
+
/** Get the Electricity Prices API */
|
|
63
|
+
useElectricityPrices: () => EnergyAppElectricityPrices;
|
|
64
|
+
}
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnergyAppModbusBattery = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const enyo_appliance_js_1 = require("../../types/enyo-appliance.cjs");
|
|
6
|
+
const enyo_appliance_js_2 = require("../../types/enyo-appliance.cjs");
|
|
7
|
+
const enyo_data_bus_value_js_1 = require("../../types/enyo-data-bus-value.cjs");
|
|
8
|
+
const enyo_source_enum_js_1 = require("../../types/enyo-source.enum.cjs");
|
|
9
|
+
const interfaces_js_1 = require("./interfaces.cjs");
|
|
10
|
+
const EnergyAppModbusRegisterMapper_js_1 = require("./EnergyAppModbusRegisterMapper.cjs");
|
|
11
|
+
const EnergyAppModbusFaultTolerantReader_js_1 = require("./EnergyAppModbusFaultTolerantReader.cjs");
|
|
12
|
+
class EnergyAppModbusBattery {
|
|
13
|
+
client;
|
|
14
|
+
config;
|
|
15
|
+
inverter;
|
|
16
|
+
_registerMapper;
|
|
17
|
+
_appliance;
|
|
18
|
+
_batteryMetadata;
|
|
19
|
+
constructor(client, config) {
|
|
20
|
+
this.client = client;
|
|
21
|
+
this.config = config;
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.client = client;
|
|
24
|
+
this.inverter = config.inverter;
|
|
25
|
+
this._registerMapper = new EnergyAppModbusRegisterMapper_js_1.EnergyAppModbusRegisterMapper();
|
|
26
|
+
// Validate configuration
|
|
27
|
+
const validation = this._registerMapper.validateRegisterMap(config.registers);
|
|
28
|
+
if (!validation.valid) {
|
|
29
|
+
throw new interfaces_js_1.EnergyAppModbusConfigurationError(`Invalid battery configuration: ${validation.errors.join(', ')}`);
|
|
30
|
+
}
|
|
31
|
+
if (!config.inverter) {
|
|
32
|
+
throw new interfaces_js_1.EnergyAppModbusConfigurationError('Battery requires an inverter reference');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
get appliance() {
|
|
36
|
+
if (!this._appliance) {
|
|
37
|
+
throw new Error('Battery appliance not initialized. Call connect() first.');
|
|
38
|
+
}
|
|
39
|
+
return this._appliance;
|
|
40
|
+
}
|
|
41
|
+
get networkDevice() {
|
|
42
|
+
if (!this.inverter) {
|
|
43
|
+
throw new Error('Battery requires an inverter reference');
|
|
44
|
+
}
|
|
45
|
+
return this.inverter.networkDevice;
|
|
46
|
+
}
|
|
47
|
+
async connect() {
|
|
48
|
+
if (!this.inverter) {
|
|
49
|
+
throw new Error('Battery requires an inverter reference');
|
|
50
|
+
}
|
|
51
|
+
if (!this.inverter.isConnected()) {
|
|
52
|
+
throw new Error('Inverter must be connected before connecting battery');
|
|
53
|
+
}
|
|
54
|
+
console.log(`Connecting battery to inverter ${this.config.name[0]?.name}...`);
|
|
55
|
+
// Discover battery metadata during connection
|
|
56
|
+
this._batteryMetadata = await this._discoverBatteryMetadata();
|
|
57
|
+
// Initialize appliance
|
|
58
|
+
await this._initializeAppliance();
|
|
59
|
+
console.log(`Successfully connected battery ${this.config.name[0]?.name}`);
|
|
60
|
+
}
|
|
61
|
+
async disconnect() {
|
|
62
|
+
try {
|
|
63
|
+
await this.inverter?.disconnect();
|
|
64
|
+
console.log(`Disconnected from battery at ${this.networkDevice.hostname}`);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.warn(`Error disconnecting from battery: ${error.message}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
isConnected() {
|
|
71
|
+
return this.inverter?.isConnected() || false;
|
|
72
|
+
}
|
|
73
|
+
async updateData() {
|
|
74
|
+
if (!this.inverter || !this.inverter.isConnected() || !this._appliance) {
|
|
75
|
+
throw new Error('Battery not connected. Call connect() first.');
|
|
76
|
+
}
|
|
77
|
+
// Use the inverter's modbus instance
|
|
78
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
79
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
80
|
+
if (!modbusInstance) {
|
|
81
|
+
throw new Error('Inverter modbus instance not available');
|
|
82
|
+
}
|
|
83
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
84
|
+
const registerData = await this._registerMapper.readMultipleRegisters(reader, this.config.registers);
|
|
85
|
+
// Extract battery data
|
|
86
|
+
const batteryCurrent = registerData.current || undefined;
|
|
87
|
+
const batteryVoltage = registerData.voltage || undefined;
|
|
88
|
+
const batterySoC = registerData.soc || undefined;
|
|
89
|
+
const batteryPowerW = await this.getPower();
|
|
90
|
+
// Read current battery state if available
|
|
91
|
+
let batteryState;
|
|
92
|
+
try {
|
|
93
|
+
batteryState = await this.getBatteryState() || undefined;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.warn(`Failed to read battery state: ${error.message}`);
|
|
97
|
+
}
|
|
98
|
+
const message = {
|
|
99
|
+
type: 'message',
|
|
100
|
+
source: enyo_source_enum_js_1.EnyoSourceEnum.Device,
|
|
101
|
+
id: (0, node_crypto_1.randomUUID)(),
|
|
102
|
+
timestampIso: new Date().toISOString(),
|
|
103
|
+
message: enyo_data_bus_value_js_1.EnyoDataBusMessageEnum.BatteryValuesUpdateV1,
|
|
104
|
+
applianceId: this._appliance.id,
|
|
105
|
+
data: {
|
|
106
|
+
state: batteryState,
|
|
107
|
+
batteryPowerW: batteryPowerW ?? undefined,
|
|
108
|
+
batterySoC
|
|
109
|
+
},
|
|
110
|
+
resolution: '10s'
|
|
111
|
+
};
|
|
112
|
+
console.log(`Battery Data (${this.config.name[0]?.name}): State=${batteryState || 'N/A'}, Power=${batteryPowerW}W, SoC=${batterySoC}%, Current=${batteryCurrent}A, Voltage=${batteryVoltage}V`);
|
|
113
|
+
return [message];
|
|
114
|
+
}
|
|
115
|
+
// Convenience methods for accessing specific register values
|
|
116
|
+
async getSoc() {
|
|
117
|
+
if (!this.inverter || !this.config.registers.soc) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
121
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
122
|
+
if (!modbusInstance) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
126
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.soc);
|
|
127
|
+
return result.success ? result.value : null;
|
|
128
|
+
}
|
|
129
|
+
async getCurrent() {
|
|
130
|
+
if (!this.inverter || !this.config.registers.current) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
134
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
135
|
+
if (!modbusInstance) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
139
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.current);
|
|
140
|
+
return result.success ? result.value : null;
|
|
141
|
+
}
|
|
142
|
+
async getPower() {
|
|
143
|
+
if (!this.inverter) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
// Priority 1: Direct power register
|
|
147
|
+
if (this.config.registers.power) {
|
|
148
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
149
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
150
|
+
if (!modbusInstance) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
154
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.power);
|
|
155
|
+
if (result.success && result.value !== undefined) {
|
|
156
|
+
return result.value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Priority 2: Calculate from percentage registers
|
|
160
|
+
if (this.config.registers.drainPercentage || this.config.registers.loadPercentage) {
|
|
161
|
+
const drainPercentage = await this.getDrainPercentage();
|
|
162
|
+
const loadPercentage = await this.getLoadPercentage();
|
|
163
|
+
const maxCapacityWh = this._batteryMetadata?.maxCapacityWh || null;
|
|
164
|
+
const percentagePower = this._calculatePowerFromPercentages(drainPercentage, loadPercentage, maxCapacityWh);
|
|
165
|
+
if (percentagePower !== null) {
|
|
166
|
+
return percentagePower;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Priority 3: Calculate from current and voltage
|
|
170
|
+
const current = await this.getCurrent();
|
|
171
|
+
const voltage = await this.getVoltage();
|
|
172
|
+
if (current !== null && voltage !== null) {
|
|
173
|
+
return current * voltage;
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
async getVoltage() {
|
|
178
|
+
if (!this.inverter || !this.config.registers.voltage) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
182
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
183
|
+
if (!modbusInstance) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
187
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.voltage);
|
|
188
|
+
return result.success ? result.value : null;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Reads the drain percentage from modbus register.
|
|
192
|
+
* Drain percentage represents the percentage of maximum capacity being discharged.
|
|
193
|
+
*
|
|
194
|
+
* @returns Drain percentage (0-100), or null if not available
|
|
195
|
+
*/
|
|
196
|
+
async getDrainPercentage() {
|
|
197
|
+
if (!this.inverter || !this.config.registers.drainPercentage) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
201
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
202
|
+
if (!modbusInstance) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
206
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.drainPercentage);
|
|
207
|
+
return result.success ? result.value : null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Reads the load percentage from modbus register.
|
|
211
|
+
* Load percentage represents the percentage of maximum capacity being charged.
|
|
212
|
+
*
|
|
213
|
+
* @returns Load percentage (0-100), or null if not available
|
|
214
|
+
*/
|
|
215
|
+
async getLoadPercentage() {
|
|
216
|
+
if (!this.inverter || !this.config.registers.loadPercentage) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
220
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
221
|
+
if (!modbusInstance) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
225
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.loadPercentage);
|
|
226
|
+
return result.success ? result.value : null;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Reads the current battery state from modbus registers.
|
|
230
|
+
* Maps the register value to EnyoBatteryApplianceStateEnum using the configured value mapping.
|
|
231
|
+
*/
|
|
232
|
+
async getBatteryState() {
|
|
233
|
+
if (!this.inverter || !this.config.registers.state) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
237
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
238
|
+
if (!modbusInstance) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
243
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.state);
|
|
244
|
+
if (!result.success || result.value === undefined) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
// Use configured value mapping if available
|
|
248
|
+
if (this.config.registers.state.valueMapping) {
|
|
249
|
+
const mapping = this.config.registers.state.valueMapping.find(m => m.value === result.value);
|
|
250
|
+
if (mapping) {
|
|
251
|
+
return mapping.mappedState;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
console.warn(`No mapping found for battery state value: ${result.value}. Available mappings: ${this.config.registers.state.valueMapping.map(m => m.value).join(', ')}`);
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
console.warn('Battery state register configured without value mapping. Please configure valueMapping in register config.');
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
console.warn(`Failed to read battery state: ${error.message}`);
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Calculates battery power from drain and load percentages.
|
|
270
|
+
*
|
|
271
|
+
* @param drainPercentage - Percentage of max capacity being drained (discharging, positive power)
|
|
272
|
+
* @param loadPercentage - Percentage of max capacity being loaded (charging, negative power)
|
|
273
|
+
* @param maxCapacityWh - Maximum battery capacity in Wh
|
|
274
|
+
* @returns Power in watts (positive for discharging, negative for charging), or null if calculation not possible
|
|
275
|
+
*/
|
|
276
|
+
_calculatePowerFromPercentages(drainPercentage, loadPercentage, maxCapacityWh) {
|
|
277
|
+
if (!maxCapacityWh) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
// Priority: drain percentage takes precedence over load percentage
|
|
281
|
+
if (drainPercentage !== null && drainPercentage !== undefined) {
|
|
282
|
+
// Discharging: positive power value
|
|
283
|
+
return (drainPercentage / 100) * maxCapacityWh;
|
|
284
|
+
}
|
|
285
|
+
if (loadPercentage !== null && loadPercentage !== undefined) {
|
|
286
|
+
// Charging: negative power value
|
|
287
|
+
return -(loadPercentage / 100) * maxCapacityWh;
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Discovers and caches battery metadata from modbus registers during connection.
|
|
293
|
+
* This method reads static metadata like max capacity and power limits once
|
|
294
|
+
* and stores them for later use in appliance creation.
|
|
295
|
+
*/
|
|
296
|
+
async _discoverBatteryMetadata() {
|
|
297
|
+
if (!this.inverter || !this.inverter.isConnected()) {
|
|
298
|
+
throw new Error('Inverter must be connected before discovering battery metadata');
|
|
299
|
+
}
|
|
300
|
+
const modbusInstance = this.inverter._modbusInstance;
|
|
301
|
+
const connectionHealth = this.inverter._connectionHealth;
|
|
302
|
+
if (!modbusInstance) {
|
|
303
|
+
throw new Error('Inverter modbus instance not available');
|
|
304
|
+
}
|
|
305
|
+
const reader = new EnergyAppModbusFaultTolerantReader_js_1.EnergyAppModbusFaultTolerantReader(modbusInstance, connectionHealth);
|
|
306
|
+
const metadata = {};
|
|
307
|
+
try {
|
|
308
|
+
// Read max capacity if configured
|
|
309
|
+
if (this.config.registers.maxCapacityWh) {
|
|
310
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.maxCapacityWh);
|
|
311
|
+
if (result.success && result.value !== undefined) {
|
|
312
|
+
metadata.maxCapacityWh = result.value;
|
|
313
|
+
console.log(`Discovered battery max capacity: ${result.value} Wh`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// Read max discharge power if configured
|
|
317
|
+
if (this.config.registers.maxDischargePowerW) {
|
|
318
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.maxDischargePowerW);
|
|
319
|
+
if (result.success && result.value !== undefined) {
|
|
320
|
+
metadata.maxDischargePowerW = result.value;
|
|
321
|
+
console.log(`Discovered battery max discharge power: ${result.value} W`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// Read max charging power if configured
|
|
325
|
+
if (this.config.registers.maxChargingPowerW) {
|
|
326
|
+
const result = await this._registerMapper.readRegister(reader, this.config.registers.maxChargingPowerW);
|
|
327
|
+
if (result.success && result.value !== undefined) {
|
|
328
|
+
metadata.maxChargingPowerW = result.value;
|
|
329
|
+
console.log(`Discovered battery max charging power: ${result.value} W`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// Set connected appliance ID to the inverter's appliance ID if available
|
|
333
|
+
if (this.inverter.appliance?.id) {
|
|
334
|
+
metadata.connectedToApplianceId = this.inverter.appliance.id;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
console.warn(`Warning: Failed to discover some battery metadata: ${error.message}`);
|
|
339
|
+
}
|
|
340
|
+
return metadata;
|
|
341
|
+
}
|
|
342
|
+
async _initializeAppliance() {
|
|
343
|
+
if (!this.inverter) {
|
|
344
|
+
throw new Error('Battery requires an inverter reference');
|
|
345
|
+
}
|
|
346
|
+
const appliances = await this.client.useAppliances().list();
|
|
347
|
+
let existingAppliance = appliances.find(a => a.networkDeviceIds.includes(this.inverter.networkDevice.id) &&
|
|
348
|
+
a.type === enyo_appliance_js_2.EnyoApplianceTypeEnum.Storage);
|
|
349
|
+
if (!existingAppliance) {
|
|
350
|
+
// Create new appliance
|
|
351
|
+
existingAppliance = {
|
|
352
|
+
id: (0, node_crypto_1.randomUUID)(),
|
|
353
|
+
type: enyo_appliance_js_2.EnyoApplianceTypeEnum.Storage,
|
|
354
|
+
networkDeviceIds: [this.inverter.networkDevice.id],
|
|
355
|
+
name: this.config.name,
|
|
356
|
+
metadata: {
|
|
357
|
+
state: enyo_appliance_js_2.EnyoApplianceStateEnum.Connected,
|
|
358
|
+
connectionType: enyo_appliance_js_1.EnyoApplianceConnectionType.Connector,
|
|
359
|
+
...this.config.options?.topology && { topology: this.config.options.topology }
|
|
360
|
+
},
|
|
361
|
+
battery: this._batteryMetadata
|
|
362
|
+
};
|
|
363
|
+
await this.client.useAppliances().save(existingAppliance, undefined);
|
|
364
|
+
console.log(`Created new battery appliance: ${this.config.name[0]?.name}`);
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
// Update existing appliance
|
|
368
|
+
existingAppliance = {
|
|
369
|
+
...existingAppliance,
|
|
370
|
+
name: this.config.name,
|
|
371
|
+
metadata: {
|
|
372
|
+
...existingAppliance.metadata,
|
|
373
|
+
state: enyo_appliance_js_2.EnyoApplianceStateEnum.Connected,
|
|
374
|
+
connectionType: enyo_appliance_js_1.EnyoApplianceConnectionType.Connector,
|
|
375
|
+
...this.config.options?.topology && { topology: this.config.options.topology }
|
|
376
|
+
},
|
|
377
|
+
battery: this._batteryMetadata
|
|
378
|
+
};
|
|
379
|
+
await this.client.useAppliances().save(existingAppliance, existingAppliance.id);
|
|
380
|
+
console.log(`Updated existing battery appliance: ${this.config.name[0]?.name}`);
|
|
381
|
+
}
|
|
382
|
+
this._appliance = existingAppliance;
|
|
383
|
+
}
|
|
384
|
+
modbusClient() {
|
|
385
|
+
return this.inverter?.modbusClient();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
exports.EnergyAppModbusBattery = EnergyAppModbusBattery;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EnyoAppliance } from "../../types/enyo-appliance.cjs";
|
|
2
|
+
import { EnyoBatteryStateEnum, type EnyoDataBusMessage } from "../../types/enyo-data-bus-value.cjs";
|
|
3
|
+
import { type EnergyAppModbusDevice, type EnergyAppModbusBatteryConfig, type IEnergyAppModbusInverter } from './interfaces.cjs';
|
|
4
|
+
import { EnergyApp } from "../../index.cjs";
|
|
5
|
+
export declare class EnergyAppModbusBattery implements EnergyAppModbusDevice {
|
|
6
|
+
readonly client: EnergyApp;
|
|
7
|
+
readonly config: EnergyAppModbusBatteryConfig;
|
|
8
|
+
readonly inverter?: IEnergyAppModbusInverter;
|
|
9
|
+
private readonly _registerMapper;
|
|
10
|
+
private _appliance?;
|
|
11
|
+
private _batteryMetadata?;
|
|
12
|
+
constructor(client: EnergyApp, config: EnergyAppModbusBatteryConfig);
|
|
13
|
+
get appliance(): EnyoAppliance;
|
|
14
|
+
get networkDevice(): import("../../types/enyo-network-device.cjs").EnyoNetworkDevice;
|
|
15
|
+
connect(): Promise<void>;
|
|
16
|
+
disconnect(): Promise<void>;
|
|
17
|
+
isConnected(): boolean;
|
|
18
|
+
updateData(): Promise<EnyoDataBusMessage[]>;
|
|
19
|
+
getSoc(): Promise<number | null>;
|
|
20
|
+
getCurrent(): Promise<number | null>;
|
|
21
|
+
getPower(): Promise<number | null>;
|
|
22
|
+
getVoltage(): Promise<number | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Reads the drain percentage from modbus register.
|
|
25
|
+
* Drain percentage represents the percentage of maximum capacity being discharged.
|
|
26
|
+
*
|
|
27
|
+
* @returns Drain percentage (0-100), or null if not available
|
|
28
|
+
*/
|
|
29
|
+
getDrainPercentage(): Promise<number | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Reads the load percentage from modbus register.
|
|
32
|
+
* Load percentage represents the percentage of maximum capacity being charged.
|
|
33
|
+
*
|
|
34
|
+
* @returns Load percentage (0-100), or null if not available
|
|
35
|
+
*/
|
|
36
|
+
getLoadPercentage(): Promise<number | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Reads the current battery state from modbus registers.
|
|
39
|
+
* Maps the register value to EnyoBatteryApplianceStateEnum using the configured value mapping.
|
|
40
|
+
*/
|
|
41
|
+
getBatteryState(): Promise<EnyoBatteryStateEnum | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Calculates battery power from drain and load percentages.
|
|
44
|
+
*
|
|
45
|
+
* @param drainPercentage - Percentage of max capacity being drained (discharging, positive power)
|
|
46
|
+
* @param loadPercentage - Percentage of max capacity being loaded (charging, negative power)
|
|
47
|
+
* @param maxCapacityWh - Maximum battery capacity in Wh
|
|
48
|
+
* @returns Power in watts (positive for discharging, negative for charging), or null if calculation not possible
|
|
49
|
+
*/
|
|
50
|
+
private _calculatePowerFromPercentages;
|
|
51
|
+
/**
|
|
52
|
+
* Discovers and caches battery metadata from modbus registers during connection.
|
|
53
|
+
* This method reads static metadata like max capacity and power limits once
|
|
54
|
+
* and stores them for later use in appliance creation.
|
|
55
|
+
*/
|
|
56
|
+
private _discoverBatteryMetadata;
|
|
57
|
+
private _initializeAppliance;
|
|
58
|
+
modbusClient(): import("../../packages/energy-app-modbus.cjs").EnergyAppModbusInstance | undefined;
|
|
59
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnergyAppModbusConnectionHealth = void 0;
|
|
4
|
+
class EnergyAppModbusConnectionHealth {
|
|
5
|
+
_consecutiveFailures = 0;
|
|
6
|
+
_lastError;
|
|
7
|
+
_lastSuccessTime = new Date();
|
|
8
|
+
_maxFailures = 5;
|
|
9
|
+
_staleThresholdMs = 5 * 60 * 1000; // 5 minutes
|
|
10
|
+
recordSuccess() {
|
|
11
|
+
this._consecutiveFailures = 0;
|
|
12
|
+
this._lastError = undefined;
|
|
13
|
+
this._lastSuccessTime = new Date();
|
|
14
|
+
}
|
|
15
|
+
recordFailure(error) {
|
|
16
|
+
this._consecutiveFailures++;
|
|
17
|
+
this._lastError = error;
|
|
18
|
+
}
|
|
19
|
+
isHealthy() {
|
|
20
|
+
const isNotFailing = this._consecutiveFailures < this._maxFailures;
|
|
21
|
+
const isNotStale = (Date.now() - this._lastSuccessTime.getTime()) < this._staleThresholdMs;
|
|
22
|
+
return isNotFailing && isNotStale;
|
|
23
|
+
}
|
|
24
|
+
getConsecutiveFailures() {
|
|
25
|
+
return this._consecutiveFailures;
|
|
26
|
+
}
|
|
27
|
+
getLastError() {
|
|
28
|
+
return this._lastError;
|
|
29
|
+
}
|
|
30
|
+
getLastSuccessTime() {
|
|
31
|
+
return new Date(this._lastSuccessTime);
|
|
32
|
+
}
|
|
33
|
+
isStale() {
|
|
34
|
+
return (Date.now() - this._lastSuccessTime.getTime()) > this._staleThresholdMs;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.EnergyAppModbusConnectionHealth = EnergyAppModbusConnectionHealth;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IConnectionHealth } from './interfaces.cjs';
|
|
2
|
+
export declare class EnergyAppModbusConnectionHealth implements IConnectionHealth {
|
|
3
|
+
private _consecutiveFailures;
|
|
4
|
+
private _lastError?;
|
|
5
|
+
private _lastSuccessTime;
|
|
6
|
+
private readonly _maxFailures;
|
|
7
|
+
private readonly _staleThresholdMs;
|
|
8
|
+
recordSuccess(): void;
|
|
9
|
+
recordFailure(error: Error): void;
|
|
10
|
+
isHealthy(): boolean;
|
|
11
|
+
getConsecutiveFailures(): number;
|
|
12
|
+
getLastError(): Error | undefined;
|
|
13
|
+
getLastSuccessTime(): Date;
|
|
14
|
+
isStale(): boolean;
|
|
15
|
+
}
|