Skip to content

Commit

Permalink
[senechome] issue openhab#10679: Extend with additional channels; ref…
Browse files Browse the repository at this point in the history
…actor and various improvements (openhab#10687)

* [senechome] Extend with additional channels; refactor; improve error handling (openhab#10679). Merged PR 9535 (rename batteryState to system state)

- charge/discharge energy/current/voltage/min/maxCellVoltage/load cycles per battery pack
- current/power/voltage per MPP
- liveHouseConsumption/livePowerGenerator
- battery,case,MCU temperature
- wallbox1: state, charging power/current, liveEnergy
- improve error handling, catch malformed JSON exception to prevent crashing the binding
- merged PR: 9535 (rename batteryState to systemState)
- renamed SenecHomeLimitation to SenecHomePower and added more channels
- refactored SenecHomeHandler to reduce code duplication (added some nice helper methods)

Signed-off-by: Erwin Guib <[email protected]>
  • Loading branch information
eguib authored and thinkingstone committed Nov 7, 2021
1 parent 4a359ec commit 141b6bf
Show file tree
Hide file tree
Showing 18 changed files with 1,222 additions and 285 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
/bundles/org.openhab.binding.samsungtv/ @paulianttila
/bundles/org.openhab.binding.satel/ @druciak
/bundles/org.openhab.binding.semsportal/ @itb3
/bundles/org.openhab.binding.senechome/ @vctender @KorbinianP
/bundles/org.openhab.binding.senechome/ @vctender @KorbinianP @eguib
/bundles/org.openhab.binding.seneye/ @nikotanghe
/bundles/org.openhab.binding.sensebox/ @hakan42
/bundles/org.openhab.binding.sensibo/ @seime
Expand Down
81 changes: 68 additions & 13 deletions bundles/org.openhab.binding.senechome/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ Examples: Lights, pool filters, wash machines, ...

| Thing type id | Name |
|----------------------|-----------------------------------------------|
| senechome | Senec Home Lithium Battery, V2.0, V2.1 and V3 |
| senechome | Senec Home Lithium Battery, V2.0, V2.1, V3 and V3duo |

**Note:** Not all channels are available for all Senec Home types. E.g.

* only V3, V3duo have a power generator and thus MPPs (V3 has 2 MPP, V3duo has 3 MPP)
* not equipped battery packs will return 0 for all ...Pack channels
* currently channels for the first wallbox are implemented (senec could handle 4 wallboxes)

## Thing Configuration

Expand All @@ -34,12 +39,23 @@ The property `limitationTresholdValue` is used as threshold for channel `powerLi
|-----------------------|-----------|--------------------------------------------------------------------------|
| powerLimitation | percent | How much is your pv generator limited (0% if not limited anyway) |
| powerLimitationState | ON/OFF | Power limitation active (based on configuration) |
| currentMPP1 | ampere | PV generator current on MPP1 |
| currentMPP2 | ampere | PV generator current on MPP2 |
| currentMPP3 | ampere | PV generator current on MPP3 |
| powerMPP1 | watt | PV generator power on MPP1 |
| powerMPP2 | watt | PV generator power on MPP2 |
| powerMPP3 | watt | PV generator power on MPP3 |
| voltageMPP1 | volt | PV generator voltage on MPP1 |
| voltageMPP2 | volt | PV generator voltage on MPP2 |
| voltageMPP3 | volt | PV generator voltage on MPP3 |
| houseConsumption | watt | Current power consumption of your house/living |
| energyProduction | watt | Energy generated by your pv / inverter |
| batteryPower | watt | Energy processed by batterie itself, for example while charging |
| batteryPower | watt | Energy processed by battery negative discharge, positive charge |
| batteryCurrent | ampere | Battery current negative discharge, positive charge |
| batteryVoltage | volt | Battery Voltage |
| batteryFuelCharge | percent | Fuel charge of your battery (0 - 100%) |
| batteryState | | Text describing current action of battery (e.g. CHARGE) |
| batteryStateValue | | Value describing current action of battery (e.g. 14) |
| systemState | | Text describing current action of the senec home system (e.g. CHARGE) |
| systemStateValue | | Value describing current action of the senec home system (e.g. 14) |
| gridPower | watt | Grid power level, negative for supply, positive values for drawing power |
| gridPowerDraw | watt | Absolute power level of power draw, zero while supplying |
| gridPowerSupply | watt | Absolute power level of power supply, zero while drawing |
Expand All @@ -53,11 +69,50 @@ The property `limitationTresholdValue` is used as threshold for channel `powerLi
| gridVoltagePhase2 | volt | Grid voltage on Phase 2 |
| gridVoltagePhase3 | volt | Grid voltage on Phase 3 |
| gridFrequency | hertz | Grid frequency |
| SenecBatteryVoltage | volt | Battery Voltage |
| SenecLiveBatCharge | watt hour | Live Bat Charge |
| SenecLiveBatDischarge | watt hour | Live Bat Discharge |
| SenecLiveGridImport | watt hour | Live Grid Import |
| SenecLiveGridExport | watt hour | Live Grid Export |
| liveBatCharge | kilo watt hour | Live Total Bat Charge |
| liveBatDischarge | kilo watt hour | Live Total Bat Discharge |
| liveGridImport | kilo watt hour | Live Total Grid Import |
| liveGridExport | kilo watt hour | Live Total Grid Export |
| liveHouseConsumption | kilo watt hour | Live Total House Consumption (without WB) |
| livePowerGenerator | kilo watt hour | Live Total PV generator generated energy |
| liveEnergyWallbox1 | kilo watt hour | Live Total Wallbox 1 charged energy |
| chargedEnergyPack1 | kilo watt hour | total charged energy battery pack 1 |
| chargedEnergyPack2 | kilo watt hour | total charged energy battery pack 2 |
| chargedEnergyPack3 | kilo watt hour | total charged energy battery pack 3 |
| chargedEnergyPack4 | kilo watt hour | total charged energy battery pack 4 |
| dischargedEnergyPack1 | kilo watt hour | total discharged energy battery pack 1 |
| dischargedEnergyPack2 | kilo watt hour | total discharged energy battery pack 2 |
| dischargedEnergyPack3 | kilo watt hour | total discharged energy battery pack 3 |
| dischargedEnergyPack4 | kilo watt hour | total discharged energy battery pack 4 |
| cyclesPack1 | | battery charge/discharge cycles pack 1 |
| cyclesPack2 | | battery charge/discharge cycles pack 2 |
| cyclesPack3 | | battery charge/discharge cycles pack 3 |
| cyclesPack4 | | battery charge/discharge cycles pack 4 |
| currentPack1 | ampere | battery current pack 1 |
| currentPack2 | ampere | battery current pack 2 |
| currentPack3 | ampere | battery current pack 3 |
| currentPack4 | ampere | battery current pack 4 |
| voltagePack1 | volt | battery voltage pack 1 |
| voltagePack2 | volt | battery voltage pack 2 |
| voltagePack3 | volt | battery voltage pack 3 |
| voltagePack4 | volt | battery voltage pack 4 |
| maxCellVoltagePack1 | volt | maximum cell voltage battery pack 1 |
| maxCellVoltagePack2 | volt | maximum cell voltage battery pack 2 |
| maxCellVoltagePack3 | volt | maximum cell voltage battery pack 3 |
| maxCellVoltagePack4 | volt | maximum cell voltage battery pack 4 |
| minCellVoltagePack1 | volt | minimum cell voltage battery pack 1 |
| minCellVoltagePack2 | volt | minimum cell voltage battery pack 2 |
| minCellVoltagePack3 | volt | minimum cell voltage battery pack 3 |
| minCellVoltagePack4 | volt | minimum cell voltage battery pack 4 |
| batteryTemperature | celsius | battery temperature (maximum of all battery packs) |
| caseTemperature | celsius | case temperature |
| mcuTemperature | celsius | MCU (main control unit) temperature |
| wallbox1State | | Wallbox 1 state as Text (e.g. Charging) |
| wallbox1StateValue | | Wallbox 1 state as value (e.g. 194) |
| wallbox1ChargingCurrentPhase1 | ampere | Wallbox 1 charging current Phase 1 |
| wallbox1ChargingCurrentPhase2 | ampere | Wallbox 1 charging current Phase 2 |
| wallbox1ChargingCurrentPhase3 | ampere | Wallbox 1 charging current Phase 3 |
| wallbox1ChargingPower | watt | Wallbox 1 charging power |

## Items

Expand All @@ -70,8 +125,8 @@ Number SenecHouseConsumption "Current power consumption [%d W]" <e
Number SenecEnergyProduction "Energy generated by pv [%d W]" <energy> { channel="senechome:senechome:pvbattery:energyProduction" }
Number SenecBatteryPower "Energy processed by battery [%d W]" <energy> { channel="senechome:senechome:pvbattery:batteryPower" }
Number SenecBatteryFuelCharge "State of Charge [%d %%]" <batterylevel> { channel="senechome:senechome:pvbattery:batteryFuelCharge" }
String SenecBatteryState "Current action [%s]" <text> { channel="senechome:senechome:pvbattery:batteryState" }
Number SenecBatteryStateValue "Current action [%d]" <text> { channel="senechome:senechome:pvbattery:batteryStateValue" }
String SenecSystemState "Current system state [%s]" <text> { channel="senechome:senechome:pvbattery:systemState" }
Number SenecSystemStateValue "Current system state [%d]" <text> { channel="senechome:senechome:pvbattery:systemStateValue" }
Number SenecGridPower "Grid power level [%d W]" <energy> { channel="senechome:senechome:pvbattery:gridPower" }
Number SenecGridPowerDraw "Power draw from grid [%d W]" <energy> { channel="senechome:senechome:pvbattery:gridPowerDraw" }
Number SenecGridPowerSupply "Power supply to grid [%d W]" <energy> { channel="senechome:senechome:pvbattery:gridPowerSupply" }
Expand Down Expand Up @@ -105,8 +160,8 @@ Text label="Power Grid"{
Default item=SenecEnergyProduction
Default item=SenecBatteryPower
Default item=SenecBatteryFuelCharge
Default item=SenecBatteryState
Default item=SenecBatteryStateValue
Default item=SenecSystemState
Default item=SenecSystemStateValue
Default item=SenecGridPower
Default item=SenecGridPowerDraw
Default item=SenecGridPowerSupply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public void setHostname(String hostname) {
*
* To receive new values, just modify the Json objects and add them to the thing channels
*
* @param hostname Hostname or ip address of senec battery
* @return Instance of SenecHomeResponse
* @throws MalformedURLException Configuration/URL is wrong
* @throws IOException Communication failed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,30 @@ public class SenecHomeBindingConstants {
private static final String THING_BASE_ID = "senechome";
public static final ThingTypeUID THING_TYPE_SENEC_HOME_BATTERY = new ThingTypeUID(BINDING_ID, THING_BASE_ID);

// SenecHomePower
public static final String CHANNEL_SENEC_POWER_LIMITATION = "powerLimitation";
public static final String CHANNEL_SENEC_POWER_LIMITATION_STATE = "powerLimitationState";
public static final String CHANNEL_SENEC_BATTERY_STATE = "batteryState";
public static final String CHANNEL_SENEC_BATTERY_STATE_VALUE = "batteryStateValue";
public static final String CHANNEL_SENEC_CURRENT_MPP1 = "currentMpp1";
public static final String CHANNEL_SENEC_CURRENT_MPP2 = "currentMpp2";
public static final String CHANNEL_SENEC_CURRENT_MPP3 = "currentMpp3";
public static final String CHANNEL_SENEC_POWER_MPP1 = "powerMpp1";
public static final String CHANNEL_SENEC_POWER_MPP2 = "powerMpp2";
public static final String CHANNEL_SENEC_POWER_MPP3 = "powerMpp3";
public static final String CHANNEL_SENEC_VOLTAGE_MPP1 = "voltageMpp1";
public static final String CHANNEL_SENEC_VOLTAGE_MPP2 = "voltageMpp2";
public static final String CHANNEL_SENEC_VOLTAGE_MPP3 = "voltageMpp3";

// SenecHomeEnergy
public static final String CHANNEL_SENEC_SYSTEM_STATE = "systemState";
public static final String CHANNEL_SENEC_SYSTEM_STATE_VALUE = "systemStateValue";
public static final String CHANNEL_SENEC_POWER_CONSUMPTION = "houseConsumption";
public static final String CHANNEL_SENEC_ENERGY_PRODUCTION = "energyProduction";
public static final String CHANNEL_SENEC_BATTERY_POWER = "batteryPower";
public static final String CHANNEL_SENEC_BATTERY_FUEL_CHARGE = "batteryFuelCharge";
public static final String CHANNEL_SENEC_BATTERY_VOLTAGE = "batteryVoltage";
public static final String CHANNEL_SENEC_BATTERY_CURRENT = "batteryCurrent";

// SenecHomeGrid
public static final String CHANNEL_SENEC_GRID_POWER = "gridPower";
public static final String CHANNEL_SENEC_GRID_POWER_SUPPLY = "gridPowerSupply";
public static final String CHANNEL_SENEC_GRID_POWER_DRAW = "gridPowerDraw";
Expand All @@ -48,9 +64,56 @@ public class SenecHomeBindingConstants {
public static final String CHANNEL_SENEC_GRID_VOLTAGE_PH2 = "gridVoltagePhase2";
public static final String CHANNEL_SENEC_GRID_VOLTAGE_PH3 = "gridVoltagePhase3";
public static final String CHANNEL_SENEC_GRID_FREQUENCY = "gridFrequency";

// SenecHomeStatistics
public static final String CHANNEL_SENEC_LIVE_BAT_CHARGE = "liveBatCharge";
public static final String CHANNEL_SENEC_LIVE_BAT_DISCHARGE = "liveBatDischarge";
public static final String CHANNEL_SENEC_LIVE_GRID_IMPORT = "liveGridImport";
public static final String CHANNEL_SENEC_LIVE_GRID_EXPORT = "liveGridExport";
public static final String CHANNEL_SENEC_BATTERY_VOLTAGE = "batteryVoltage";
public static final String CHANNEL_SENEC_LIVE_HOUSE_CONSUMPTION = "liveHouseConsumption";
public static final String CHANNEL_SENEC_LIVE_POWER_GENERATOR = "livePowerGenerator";
public static final String CHANNEL_SENEC_LIVE_ENERGY_WALLBOX1 = "liveEnergyWallbox1";

// SenecHomeBattery
public static final String CHANNEL_SENEC_CHARGED_ENERGY_PACK1 = "chargedEnergyPack1";
public static final String CHANNEL_SENEC_CHARGED_ENERGY_PACK2 = "chargedEnergyPack2";
public static final String CHANNEL_SENEC_CHARGED_ENERGY_PACK3 = "chargedEnergyPack3";
public static final String CHANNEL_SENEC_CHARGED_ENERGY_PACK4 = "chargedEnergyPack4";
public static final String CHANNEL_SENEC_DISCHARGED_ENERGY_PACK1 = "dischargedEnergyPack1";
public static final String CHANNEL_SENEC_DISCHARGED_ENERGY_PACK2 = "dischargedEnergyPack2";
public static final String CHANNEL_SENEC_DISCHARGED_ENERGY_PACK3 = "dischargedEnergyPack3";
public static final String CHANNEL_SENEC_DISCHARGED_ENERGY_PACK4 = "dischargedEnergyPack4";
public static final String CHANNEL_SENEC_CYCLES_PACK1 = "cyclesPack1";
public static final String CHANNEL_SENEC_CYCLES_PACK2 = "cyclesPack2";
public static final String CHANNEL_SENEC_CYCLES_PACK3 = "cyclesPack3";
public static final String CHANNEL_SENEC_CYCLES_PACK4 = "cyclesPack4";
public static final String CHANNEL_SENEC_CURRENT_PACK1 = "currentPack1";
public static final String CHANNEL_SENEC_CURRENT_PACK2 = "currentPack2";
public static final String CHANNEL_SENEC_CURRENT_PACK3 = "currentPack3";
public static final String CHANNEL_SENEC_CURRENT_PACK4 = "currentPack4";
public static final String CHANNEL_SENEC_VOLTAGE_PACK1 = "voltagePack1";
public static final String CHANNEL_SENEC_VOLTAGE_PACK2 = "voltagePack2";
public static final String CHANNEL_SENEC_VOLTAGE_PACK3 = "voltagePack3";
public static final String CHANNEL_SENEC_VOLTAGE_PACK4 = "voltagePack4";
public static final String CHANNEL_SENEC_MAX_CELL_VOLTAGE_PACK1 = "maxCellVoltagePack1";
public static final String CHANNEL_SENEC_MAX_CELL_VOLTAGE_PACK2 = "maxCellVoltagePack2";
public static final String CHANNEL_SENEC_MAX_CELL_VOLTAGE_PACK3 = "maxCellVoltagePack3";
public static final String CHANNEL_SENEC_MAX_CELL_VOLTAGE_PACK4 = "maxCellVoltagePack4";
public static final String CHANNEL_SENEC_MIN_CELL_VOLTAGE_PACK1 = "minCellVoltagePack1";
public static final String CHANNEL_SENEC_MIN_CELL_VOLTAGE_PACK2 = "minCellVoltagePack2";
public static final String CHANNEL_SENEC_MIN_CELL_VOLTAGE_PACK3 = "minCellVoltagePack3";
public static final String CHANNEL_SENEC_MIN_CELL_VOLTAGE_PACK4 = "minCellVoltagePack4";

// SenecHomeTemperature
public static final String CHANNEL_SENEC_BATTERY_TEMPERATURE = "batteryTemperature";
public static final String CHANNEL_SENEC_CASE_TEMPERATURE = "caseTemperature";
public static final String CHANNEL_SENEC_MCU_TEMPERATURE = "mcuTemperature";

// SenecHomeWallbox
public static final String CHANNEL_SENEC_WALLBOX1_STATE = "wallbox1State";
public static final String CHANNEL_SENEC_WALLBOX1_STATE_VALUE = "wallbox1StateValue";
public static final String CHANNEL_SENEC_WALLBOX1_CHARGING_CURRENT_PH1 = "wallbox1ChargingCurrentPhase1";
public static final String CHANNEL_SENEC_WALLBOX1_CHARGING_CURRENT_PH2 = "wallbox1ChargingCurrentPhase2";
public static final String CHANNEL_SENEC_WALLBOX1_CHARGING_CURRENT_PH3 = "wallbox1ChargingCurrentPhase3";
public static final String CHANNEL_SENEC_WALLBOX1_CHARGING_POWER = "wallbox1ChargingPower";
}
Loading

0 comments on commit 141b6bf

Please sign in to comment.