Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #158 from Thomas55555/split-headlight-and-ch
Browse files Browse the repository at this point in the history
split command headlight and cuttingheight
  • Loading branch information
Thomas55555 authored Dec 13, 2021
2 parents 68b9c7b + e28a867 commit a25514a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
12 changes: 1 addition & 11 deletions custom_components/husqvarna_automower/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,11 @@ def entity_category(self) -> str:

async def async_set_value(self, value: float) -> None:
"""Change the value."""
mower_attributes = self.__get_mower_attributes()
try:
hl_mode = mower_attributes["headlight"]["mode"] ## return of the websocket
except KeyError:
hl_mode = mower_attributes["settings"]["headlight"][
"mode"
] ## return from REST, just for start-up
command_type = "settings"
string = {
"data": {
"type": "settings",
"attributes": {
"cuttingHeight": value,
"headlight": {"mode": hl_mode},
},
"attributes": {"cuttingHeight": value},
}
}
payload = json.dumps(string)
Expand Down
12 changes: 1 addition & 11 deletions custom_components/husqvarna_automower/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,11 @@ def entity_category(self) -> str:

async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
mower_attributes = self.__get_mower_attributes()
try:
c_height = mower_attributes["cuttingHeight"] ## return of the websocket
except KeyError:
c_height = mower_attributes["settings"][
"cuttingHeight"
] ## return from REST, just for start-up
command_type = "settings"
string = {
"data": {
"type": "settings",
"attributes": {
"cuttingHeight": c_height, ##if only changing the headlight_mode it gives an Bad request. Husqvarna is informed about that
"headlight": {"mode": option},
},
"attributes": {"headlight": {"mode": option}},
}
}
payload = json.dumps(string)
Expand Down

0 comments on commit a25514a

Please sign in to comment.