Skip to content

Commit

Permalink
options "must" be lowercase - so we force UPPER/LOWER directly when r…
Browse files Browse the repository at this point in the history
…eading/writing data
  • Loading branch information
marq24 committed Oct 20, 2023
1 parent d7d4462 commit 52af6c1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion custom_components/senec/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
QUERY_PEAK_SHAVING_KEY = "query_peak_shaving"

# Peak Shaving Options
PEAK_SHAVING_OPTIONS = ["DEACTIVATED", "MANUAL", "AUTO"]
PEAK_SHAVING_OPTIONS = ["deactivated", "manual", "auto"]


@dataclass
Expand Down
4 changes: 2 additions & 2 deletions custom_components/senec/pysenec_ha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,7 @@ async def update_peak_shaving(self):
# GET Data from JSON
self._peakShaving_entities["einspeisebegrenzungKwpInPercent"] = r_json[
"einspeisebegrenzungKwpInPercent"]
self._peakShaving_entities["peakShavingMode"] = r_json["peakShavingMode"]
self._peakShaving_entities["peakShavingMode"] = r_json["peakShavingMode"].lower()
self._peakShaving_entities["peakShavingCapacityLimitInPercent"] = r_json[
"peakShavingCapacityLimitInPercent"]
self._peakShaving_entities["peakShavingEndDate"] = datetime.fromtimestamp(
Expand All @@ -2058,7 +2058,7 @@ async def set_peak_shaving(self, new_peak_shaving: dict):
_LOGGER.debug("***** set_peak_shaving(self, new_peak_shaving) ********")

# Senec self allways sends all get-parameter, even if not needed. So we will do it the same way
a_url = f"{self._SENEC_API_SET_PEAK_SHAVING_BASE_URL}{self._master_plant_number}&mode={new_peak_shaving['mode']}&capacityLimit={new_peak_shaving['capacity']}&endzeit={new_peak_shaving['end_time']}"
a_url = f"{self._SENEC_API_SET_PEAK_SHAVING_BASE_URL}{self._master_plant_number}&mode={new_peak_shaving['mode'].upper()}&capacityLimit={new_peak_shaving['capacity']}&endzeit={new_peak_shaving['end_time']}"

async with self.websession.post(a_url, ssl=False) as res:
try:
Expand Down
10 changes: 5 additions & 5 deletions custom_components/senec/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ set_peakshaving:
# Description of the field
description: DEACTIVATED = Peak Shaving is disabled, MANUAL = You can set the parameter (battery capacity, end time), AUTO = Peak Shaving is in automatic mode. Battery capacity and end time will be ignored.
#Example value
example: "AUTO"
example: "auto"
#Default value
default: "AUTO"
default: "auto"
# Options
selector:
select:
mode: "dropdown"
translation_key: "set_peakshaving_mode_options"
options:
- DEACTIVATED
- MANUAL
- AUTO
- deactivated
- manual
- auto
capacity:
required: true
name: Battery capacity limit
Expand Down
14 changes: 7 additions & 7 deletions custom_components/senec/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
},
"set_peakshaving_mode_options": {
"options": {
"DEACTIVATED": "Deaktiviert",
"MANUAL": "Manuell",
"AUTO": "Automatisch"
"deactivated": "Deaktiviert",
"manual": "Manuell",
"auto": "Automatisch"
}
}
},
Expand Down Expand Up @@ -99,7 +99,7 @@
},
"services": {
"set_peakshaving": {
"name": "Set Peak Shaving",
"name": "Peak Shaving setzen",
"description": "Setzt den Peak Shaving Modus, das Batterie-Limit und die Endzeit.",
"fields": {
"mode": {
Expand All @@ -125,9 +125,9 @@
"peakshaving_mode": {
"name": "Peak Shaving Modus",
"state": {
"DEACTIVATED": "Deaktiviert",
"MANUAL": "Manuell",
"AUTO": "Automatisch"
"deactivated": "Deaktiviert",
"manual": "Manuell",
"auto": "Automatisch"
}
},
"peakshaving_capacitylimit": {
Expand Down
12 changes: 6 additions & 6 deletions custom_components/senec/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
},
"set_peakshaving_mode_options": {
"options": {
"DEACTIVATED": "Deactivated",
"MANUAL": "Manual",
"AUTO": "Automatic"
"deactivated": "Deactivated",
"manual": "Manual",
"auto": "Automatic"
}
}
},
Expand Down Expand Up @@ -125,9 +125,9 @@
"peakshaving_mode": {
"name": "Peak Shaving Mode",
"state": {
"DEACTIVATED": "Deactivated",
"MANUAL": "Manual",
"AUTO": "Automatic"
"deactivated": "Deactivated",
"manual": "Manual",
"auto": "Automatic"
}
},
"peakshaving_capacitylimit": {
Expand Down

0 comments on commit 52af6c1

Please sign in to comment.