torbennehmer / hacs-e3dc

Homeassistant E3DC Integration
GNU Affero General Public License v3.0
70 stars 8 forks source link

SmartGrid Support #128

Open tobiby opened 8 months ago

tobiby commented 8 months ago

Checklist

Is your feature request related to a problem? Please describe.

The S10 mini offers the possibility to control a heat pump via two switches (SmartGrid). It would be nice if it were possible to read out the status of this switches in the Home Assistant, as this would allow you to recognize whether there is a certain amount of excess power and thus switch on consumers

Describe the solution you'd like

Instead of transferring the status of each individual switch, it might be possible to translate the status of the switches directly into the associated SmartGrid states. State 1 - Blocked operation (1:0): Operation for the heat pump is blocked for a maximum of two hours per day. State 2 - Normal operation (0:0): The heat pump runs in energy-efficient normal operation. State 3 - Switch-on recommendation (0:1): Heat pump operation is stimulated to increase electricity consumption for heating and hot water. State 4 - Start-up command (1:1): The heat pump is prompted to operate. This state supports two variants, which must be set on the controller for different tariff and usage models: i) the heat pump is switched on ii) the heat pump is switched on AND the hot water temperature is increased

Describe alternatives you've considered

Provide the state of the switches (0/1) as two separate entities in the system

Additional context

If python-e3dc is used the function poll_switches() can be used to get the state of the switches

Diagnostics dump

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2024.3.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.12.2", "docker": true, "arch": "aarch64", "timezone": "Europe/Berlin", "os_name": "Linux", "os_version": "6.1.73-haos-raspi", "supervisor": "2024.03.1", "host_os": "Home Assistant OS 12.1", "docker_version": "24.0.7", "chassis": "embedded", "run_as_root": true }, "custom_components": { "e3dc_rscp": { "version": "v3.6.2", "requirements": [ "pye3dc==0.9.1" ] }, "homematicip_local": { "version": "1.58.0", "requirements": [ "hahomematic==2024.3.1" ] }, "hacs": { "version": "1.34.0", "requirements": [ "aiogithubapi>=22.10.1" ] } }, "integration_manifest": { "domain": "e3dc_rscp", "name": "E3DC Remote Storage Control Protocol (Git)", "codeowners": [ "@torbennehmer" ], "config_flow": true, "dependencies": [], "documentation": "https://github.com/torbennehmer/hacs-e3dc", "homekit": {}, "integration_type": "device", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/torbennehmer/hacs-e3dc/issues", "requirements": [ "pye3dc==0.9.1" ], "ssdp": [], "version": "v3.6.2", "zeroconf": [], "is_built_in": false }, "data": { "current_data": { "system-derate-percent": 69.9999988079071, "system-derate-power": 5544.0, "system-additional-source-available": false, "system-battery-installed-capacity": 6526, "system-battery-installed-peak": 7920, "system-ac-maxpower": 4600, "system-battery-charge-max": 1500, "system-battery-discharge-max": 1500, "system-mac": "24:", "model": "S10_Mini", "system-battery-discharge-minimum-default": 65, "e3dc_timezone": "Europe/Berlin", "additional-production": 0, "autarky": 71.67776489257812, "battery-charge": 0, "battery-discharge": 1545, "battery-netchange": -1545, "grid-consumption": 570, "grid-netchange": 570, "grid-production": 0, "house-consumption": 2115, "selfconsumption": 99.9999771118164, "soc": 81, "solar-production": 0, "wallbox-consumption": 0, "pset-limit-charge": 1500, "pset-limit-discharge": 1500, "pset-limit-discharge-minimum": 65, "pset-limit-enabled": false, "pset-powersaving-enabled": true, "pset-weatherregulationenabled": true, "manual-charge-active": false, "manual-charge-energy": 0, "db-day-autarky": 81.6178970336914, "db-day-battery-charge": 4053.0, "db-day-battery-discharge": 3682.0, "db-day-grid-consumption": 1080.5, "db-day-grid-production": 1127.0, "db-day-house-consumption": 5878.0, "db-day-selfconsumption": 80.977294921875, "db-day-solar-production": 7782.0, "db-day-startts": 1711929600 }, "get_system_info": { "deratePercent": 69.9999988079071, "deratePower": 5544.0, "externalSourceAvailable": 0, "installedBatteryCapacity": 6526, "installedPeakPower": 7920, "maxAcPower": 4600, "macAddress": "24:", "maxBatChargePower": 1500, "maxBatDischargePower": 1500, "model": "S10_Mini", "release": "S10_2023_06", "serial": "532" }, "get_system_status": { "dcdcAlive": true, "powerMeterAlive": true, "batteryModuleAlive": true, "pvModuleAlive": true, "pvInverterInited": true, "serverConnectionAlive": true, "pvDerated": false, "emsAlive": true, "acModeBlocked": false, "sysConfChecked": false, "emergencyPowerStarted": false, "emergencyPowerOverride": false, "wallBoxAlive": false, "powerSaveEnabled": false, "chargeIdlePeriodActive": false, "dischargeIdlePeriodActive": false, "waitForWeatherBreakthrough": false, "rescueBatteryEnabled": false, "emergencyReserveReached": false, "socSyncRequested": false }, "get_powermeters": [ { "index": 6, "type": 1, "typeName": "PM_TYPE_ROOT" } ], "e3dc_config": { "powermeters": [ { "index": 6, "type": 1, "typeName": "PM_TYPE_ROOT", "name": "Root PM", "key": "root-pm", "total-state-class": "total", "negate-measure": false } ] }, "poll": { "autarky": 71.69123840332031, "consumption": { "battery": -1545, "house": 2112, "wallbox": 0 }, "production": { "solar": 0, "add": 0, "grid": 567 }, "selfConsumption": 99.9999771118164, "stateOfCharge": 80, "time": "2024-04-01T19:35:24.000838+00:00" }, "switches": [ { "id": 7, "type": 74, "name": "SG0", "status": 48 }, { "id": 8, "type": 75, "name": "SG1", "status": 48 } ], "get_pvis_data": [ { "acMaxApparentPower": 4600.0, "cosPhi": { "active": null, "value": null, "excited": null }, "deviceState": { "connected": true, "working": true, "inService": false }, "frequency": { "under": null, "over": null }, "index": 0, "lastError": "3 0x0", "maxPhaseCount": 3, "maxStringCount": 2, "onGrid": true, "phases": { "0": { "power": 1429.0, "voltage": 235.5, "current": 6.110000133514404, "apparentPower": 1434.0, "reactivePower": 0.0, "energyAll": 14561002.0, "energyGridConsumption": 3564.0 } }, "powerMode": 1, "serialNumber": "E3E", "state": "0x103f231d", "strings": { "0": { "power": 0.0, "voltage": 38.0, "current": 0.0, "energyAll": 8544629.0 }, "1": { "power": 0.0, "voltage": 39.0, "current": 0.0, "energyAll": 7318887.0 } }, "systemMode": 2, "temperature": { "max": 130.0, "min": -30.0, "values": [ 29.399999618530273, 33.099998474121094, 40.70000076293945, 38.70000076293945 ] }, "type": 4, "version": " MAIN HW0D 2.060", "voltageMonitoring": { "thresholdTop": null, "thresholdBottom": null, "slopeUp": null, "slopeDown": null } } ], "get_powermeters_data": [ { "activePhases": "111", "energy": { "L1": -9019446.11, "L2": 9894991.61, "L3": -10286008.28 }, "index": 6, "maxPhasePower": 24000.0, "mode": 1, "power": { "L1": 67.0, "L2": 1860.0, "L3": -1360.0 }, "type": 1, "voltage": { "L1": 233.83999633789062, "L2": 232.83999633789062, "L3": 235.05999755859375 } } ], "get_batteries_data": [ { "asoc": 89.9000015258789, "chargeCycles": 854, "current": -28.399999618530273, "dcbCount": 1, "dcbs": { "0": { "current": -28.399999618530273, "currentAvg30s": -28.399980545043945, "cycleCount": 854, "designCapacity": 126.0, "designVoltage": 51.79999923706055, "deviceName": "EM048126P3S", "endOfDischarge": 44.5, "error": 0, "fullChargeCapacity": 126.0, "fwVersion": 260, "manufactureDate": 0, "manufactureName": "LG", "maxChargeCurrent": 63.0, "maxChargeTemperature": 45.0, "maxChargeVoltage": 58.79999923706055, "maxDischargeCurrent": 63.0, "minChargeTemperature": -10.0, "parallelCellCount": 0, "sensorCount": 2, "seriesCellCount": 0, "pcbVersion": 8, "protocolVersion": 16, "remainingCapacity": 98.0, "serialCode": "191", "serialNo": 1912270797, "soc": 77.80000305175781, "soh": 89.9000015258789, "status": 352, "temperatures": [ 24.399999618530273, 24.5 ], "voltage": 54.5, "voltageAvg30s": 54.50832748413086, "voltages": [], "warning": 0 } }, "designCapacity": 126.0, "deviceConnected": true, "deviceInService": false, "deviceName": "LG_BAT", "deviceWorking": true, "eodVoltage": 41.0, "errorCode": 0, "fcc": 126.0, "index": 0, "maxBatVoltage": 57.9739990234375, "maxChargeCurrent": 63.0, "maxDischargeCurrent": 63.0, "maxDcbCellTemp": 24.5, "minDcbCellTemp": 24.399999618530273, "moduleVoltage": 54.5, "rc": 98.0, "readyForShutdown": true, "rsoc": 80.96992492675781, "rsocReal": 77.80000305175781, "statusCode": 0, "terminalVoltage": 54.5, "totalUseTime": 0, "totalDischargeTime": 0, "trainingMode": 0, "usuableCapacity": 114.02999877929688, "usuableRemainingCapacity": 86.02999877929688 } ], "get_idle_periods": null, "get_power_settings": { "dischargeStartPower": 65, "maxChargePower": 1500, "maxDischargePower": 1500, "powerLimitsUsed": false, "powerSaveEnabled": true, "weatherForecastMode": 1, "weatherRegulatedChargeEnabled": true }, "EMS_REQ_GET_MANUAL_CHARGE": { "exception": [ "Traceback (most recent call last):\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_e3dc_rscp_local.py\", line 102, in sendRequest\n receive = self._receive()\n ^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_e3dc_rscp_local.py\", line 76, in _receive\n decData = rscpDecode(self.encdec.decrypt(data))[0]\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_rscpLib.py\", line 263, in rscpDecode\n return rscpDecode(rscpFrameDecode(data)[0])\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_rscpLib.py\", line 279, in rscpDecode\n innerData, usedLength = rscpDecode(data[curByte:])\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_rscpLib.py\", line 270, in rscpDecode\n strTag = getStrRscpTag(hexTag)\n ^^^^^^^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_rscpTags.py\", line 3692, in getStrRscpTag\n tag = RscpTag(tag)\n ^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/enum.py\", line 744, in call\n return cls.new(cls, value)\n ^^^^^^^^^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/enum.py\", line 1158, in new\n raise ve_exc\n", "ValueError: 16777278 is not a valid RscpTag\n", "\nDuring handling of the above exception, another exception occurred:\n\n", "Traceback (most recent call last):\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_e3dc.py\", line 226, in sendRequest\n result = self.rscp.sendRequest(request)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_e3dc_rscp_local.py\", line 108, in sendRequest\n raise CommunicationError\n", "e3dc._e3dc_rscp_local.CommunicationError\n", "\nDuring handling of the above exception, another exception occurred:\n\n", "Traceback (most recent call last):\n", " File \"/config/custom_components/e3dc_rscp/diagnostics.py\", line 116, in _query_data_for_dump\n tmp = call()\n ^^^^^^\n", " File \"/config/custom_components/e3dc_rscp/diagnostics.py\", line 85, in \n lambda: self.e3dc.sendRequestTag(\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_e3dc.py\", line 263, in sendRequestTag\n return self.sendRequest(\n ^^^^^^^^^^^^^^^^^\n", " File \"/usr/local/lib/python3.12/site-packages/e3dc/_e3dc.py\", line 237, in sendRequest\n raise SendError(\"Max retries reached\")\n", "e3dc._e3dc.SendError: Max retries reached\n" ] }, "DB_REQ_HISTORY_DATA_DAY": [ "DB_HISTORY_DATA_DAY", "Container", [ [ "DB_SUM_CONTAINER", "Container", [ [ "DB_GRAPH_INDEX", "Float32", -1.0 ], [ "DB_BAT_POWER_IN", "Float32", 4053.0 ], [ "DB_BAT_POWER_OUT", "Float32", 3682.0 ], [ "DB_DC_POWER", "Float32", 7782.0 ], [ "DB_GRID_POWER_IN", "Float32", 1127.0 ], [ "DB_GRID_POWER_OUT", "Float32", 1080.5 ], [ "DB_CONSUMPTION", "Float32", 5878.0 ], [ "DB_PM_0_POWER", "Float32", 0.0 ], [ "DB_PM_1_POWER", "Float32", 0.0 ], [ "DB_BAT_CHARGE_LEVEL", "Float32", 80.0790023803711 ], [ "DB_BAT_CYCLE_COUNT", "Int32", 0 ], [ "DB_CONSUMED_PRODUCTION", "Float32", 80.977294921875 ], [ "DB_AUTARKY", "Float32", 81.6178970336914 ] ] ], [ "DB_VALUE_CONTAINER", "Container", [ [ "DB_GRAPH_INDEX", "Float32", 0.8958332538604736 ], [ "DB_BAT_POWER_IN", "Float32", 188.51162719726562 ], [ "DB_BAT_POWER_OUT", "Float32", 171.2558135986328 ], [ "DB_DC_POWER", "Float32", 361.9534912109375 ], [ "DB_GRID_POWER_IN", "Float32", 52.41860580444336 ], [ "DB_GRID_POWER_OUT", "Float32", 50.25581359863281 ], [ "DB_CONSUMPTION", "Float32", 273.3953552246094 ], [ "DB_PM_0_POWER", "Float32", 0.0 ], [ "DB_PM_1_POWER", "Float32", 0.0 ], [ "DB_BAT_CHARGE_LEVEL", "Float32", 80.0790023803711 ], [ "DB_BAT_CYCLE_COUNT", "Int32", 0 ], [ "DB_CONSUMED_PRODUCTION", "Float32", 80.977294921875 ], [ "DB_AUTARKY", "Float32", 100.0 ] ] ] ] ] } }

torbennehmer commented 8 months ago

Hi @tobiby, please add a diagnostic dump. Torben

tobiby commented 8 months ago

Hi Thorben, I don't have a diagnostic dumb because it would be a new feature . Grüße, Tobias

torbennehmer @.***> schrieb am Fr., 29. März 2024, 08:29:

Hi @tobiby https://github.com/tobiby, please add a diagnostic dump. Torben

— Reply to this email directly, view it on GitHub https://github.com/torbennehmer/hacs-e3dc/issues/128#issuecomment-2026805339, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2EIMHVMGZ42UYK6P6KO33Y2UC3JAVCNFSM6AAAAABFMIP4KOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRWHAYDKMZTHE . You are receiving this because you were mentioned.Message ID: @.***>

torbennehmer commented 8 months ago

@tobiby yes, you do. The dump stores a lot of data retrieved from the e3dc, including your switch setup. I need that to implement something like this as I don't have any switches. So please add it (always, whatever you do), I ask for a reason, not for fun.

tobiby commented 8 months ago

Diagnistic dump attached in inital comment.

tobiby commented 6 months ago

Created a PR for solving this issue: #147

torbennehmer commented 2 months ago

Please fix all comments and run the linter over it as well, it should give you hints about incorrect indentations etc.

tobiby commented 2 months ago

unfortunately i am not familiar with the tools and have no idea how to get the linter running. If someone could support me I would be happy, if not I would just keep the changes in my fork and cancel the pull request

torbennehmer commented 2 months ago

in your de container, you should be able to run python -m ruff check . custom_components/e3dc_rscp/*py (ignore the config errors it currently throws, that's still on my list). Please check the other comments in the PR as well. Thanks!

tobiby commented 2 months ago

grafik

Checks passed. The other comments related to translation i saw and i try to fix like suggested. But i still ask for support because of my lack of knowlegde.