# Senec Home Binding

Binding to request status information from Senec Home Batteries to allow home automation decisions based on your current energy management.

If your power feed is limited by regulations for example, you can switch on devices if a limited rate was applied by your Senec Home device.
In addition you can switch off devices if the power consumption is getting higher.

Examples: Lights, pool filters, wash machines, ...

Also allows for turning the battery into safe charging mode or storage mode.

## Supported Things

| Thing type id | Name                                                 |
| ------------- | ---------------------------------------------------- |
| 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)
- Senec disables http access at ~30.08.2023
- The chargeMode `STORAGE` also known as Lithium Storage Mode is intended (according to the manual) for disassembly and transport. It is untested if it has any side effects.

## Thing Configuration

demo.things

```java
Thing senechome:senechome:pvbattery [ hostname="192.168.0.128", refreshInterval=60, limitationTresholdValue=70, limitationDuration=60, useHttp=false ]
```

If the Thing goes online then the connection to the web interface is successful.
In case it is offline you should see an error message.
The refresh interval is 15 seconds by default, but you can optionally provide your own value adding the `refreshInterval` key.

The property `limitationThresholdValue` is used as threshold for channel `powerLimitationState`. It is combined with property `limitationDuration` (seconds) to define a stable status for power limitation. Therefore use `powerLimitationState` to trigger events (switches) based on your current power limitation.

## Channels

| Channel                       | Type           | Description                                                               |
|-------------------------------|----------------|---------------------------------------------------------------------------|
| 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 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%).                                   |
| 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).       |
| chargeMode                    | OFF/CHARGE/    | In `CHARGE` mode, the battery will try to fill as quickly as possible     |
|                               | STORAGE        | in `STORAGE` mode, the battery will try to reach 25% SOC.                 |
| 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.                 |
| gridPowerPhase1               | watt           | Grid power level on Phase 1, negative for supply, positive for drawing.   |
| gridPowerPhase2               | watt           | Grid power level on Phase 2, negative for supply, positive for drawing.   |
| gridPowerPhase3               | watt           | Grid power level on Phase 3, negative for supply, positive for drawing.   |
| gridCurrentPhase1             | ampere         | Grid current on Phase 1, always a positive number.                        |
| gridCurrentPhase2             | ampere         | Grid current on Phase 2, always a positive number.                        |
| gridCurrentPhase3             | ampere         | Grid current on Phase 3, always a positive number.                        |
| gridVoltagePhase1             | volt           | Grid voltage on Phase 1.                                                  |
| gridVoltagePhase2             | volt           | Grid voltage on Phase 2.                                                  |
| gridVoltagePhase3             | volt           | Grid voltage on Phase 3.                                                  |
| gridFrequency                 | hertz          | Grid frequency.                                                           |
| 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

Sample:

```java
Number SenecPowerLimitation      "pv generator limit [%d %%]"                <heating> { channel="senechome:senechome:pvbattery:powerLimitation" }
Switch SenecPowerLimitationState "Power limitation active"                    <switch> { channel="senechome:senechome:pvbattery:powerLimitationState" }
Number SenecHouseConsumption     "Current power consumption [%d W]"           <energy> { channel="senechome:senechome:pvbattery:houseConsumption" }
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 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" }
Number SenecGridPowerPh1         "Power draw from grid on Phase 1 [%d W]"     <energy> { channel="senechome:senechome:pvbattery:gridPowerPhase1" }
Number SenecGridPowerPh2         "Power draw from grid on Phase 2 [%d W]"     <energy> { channel="senechome:senechome:pvbattery:gridPowerPhase2" }
Number SenecGridPowerPh3         "Power draw from grid on Phase 3 [%d W]"     <energy> { channel="senechome:senechome:pvbattery:gridPowerPhase3" }
Number SenecGridCurrentPh1       "Current draw from grid on Phase 1 [%.2f A]" <energy> { channel="senechome:senechome:pvbattery:gridCurrentPhase1" }
Number SenecGridCurrentPh2       "Current draw from grid on Phase 2 [%.2f A]" <energy> { channel="senechome:senechome:pvbattery:gridCurrentPhase2" }
Number SenecGridCurrentPh3       "Current draw from grid on Phase 3 [%.2f A]" <energy> { channel="senechome:senechome:pvbattery:gridCurrentPhase3" }
Number SenecGridVoltagePh1       "Voltage Level on Phase 1 [%d V]"            <energy> { channel="senechome:senechome:pvbattery:gridVoltagePhase1" }
Number SenecGridVoltagePh2       "Voltage Level on Phase 2 [%d V]"            <energy> { channel="senechome:senechome:pvbattery:gridVoltagePhase2" }
Number SenecGridVoltagePh3       "Voltage Level on Phase 3 [%d V]"            <energy> { channel="senechome:senechome:pvbattery:gridVoltagePhase3" }
Number SenecGridFrequency        "Grid Frequency [%.2f Hz]"                   <energy> { channel="senechome:senechome:pvbattery:gridFrequency" }
Number SenecBatteryVoltage       "Battery Voltage [%.1f V]"                   <energy> { channel="senechome:senechome:pvbattery:batteryVoltage" }
String SenecBatteryChargeMode    "Battery Charge Mode [%s]"                            { channel="senechome:senechome:pvbattery:chargeMode" }
```

## Sitemap

Sample:

```perl
Text label="Power Grid"{
    Frame label="Photovoltaik" {
        Default item=SenecPowerLimitation
        Default item=SenecPowerLimitationState
        Default item=SenecHouseConsumption
        Default item=SenecEnergyProduction
        Default item=SenecBatteryPower
        Default item=SenecBatteryFuelCharge
        Default item=SenecSystemState
        Default item=SenecSystemStateValue
        Default item=SenecGridPower
        Default item=SenecGridPowerDraw
        Default item=SenecGridPowerSupply
        Default item=SenecGridPowerPh1
        Default item=SenecGridPowerPh2
        Default item=SenecGridPowerPh3
        Default item=SenecGridCurrentPh1
        Default item=SenecGridCurrentPh2
        Default item=SenecGridCurrentPh3
        Default item=SenecGridVoltagePh1
        Default item=SenecGridVoltagePh2
        Default item=SenecGridVoltagePh3
        Default item=SenecGridFrequency
        Default item=SenecBatteryVoltage
        Default item=SenecBatteryChargeMode
    }
}
```
