Skip to content

Commit

Permalink
Fixed User Menu Lock
Browse files Browse the repository at this point in the history
  • Loading branch information
veista committed Dec 22, 2022
1 parent 7133d20 commit d302203
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
12 changes: 12 additions & 0 deletions custom_components/nilan/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2572,6 +2572,18 @@ async def set_pre_heater_temp_set(self, mode: int) -> bool:
return True
return False

async def set_user_menu_state(self, mode: int) -> bool:
"""set User Menu Access."""
if mode in (0, 1, 2):
await self._modbus.async_pymodbus_call(
self._unit_id,
CTS602HoldingRegisters.user_user_menu_open,
mode,
"write_registers",
)
return True
return False

async def set_air_heat_select(self, mode: int) -> bool:
"""set air heating."""
if mode in (0, 1, 2, 3, 4):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/nilan/device_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@
"supported_devices": (None,),
},
"get_user_menu_state": {
"entity_type": "sensor",
"entity_type": "select",
"min_bus_version": 19, # PH
"supported_devices": ("all",),
},
Expand Down
2 changes: 1 addition & 1 deletion custom_components/nilan/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "nilan",
"name": "Nilan",
"version": "1.1.7",
"version": "1.1.8",
"config_flow": true,
"documentation": "https://github.com/veista/nilan",
"requirements": ["pymodbus==2.5.3"],
Expand Down
22 changes: 22 additions & 0 deletions custom_components/nilan/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@
"Continuous": 1,
}

NUMBER_TO_USER_MENU_STATE = {
0: "Locked",
1: "Open",
2: "Disable Off Key",
}

USER_MENU_STATE_TO_NUMBER = {
"Locked": 0,
"Open": 1,
"Disable Off Key": 2,
}


NUMBER_TO_DEFROST_VENTILATION = {0: "None", 1: "Constant Flow", 2: "Low Flow"}

Expand Down Expand Up @@ -437,6 +449,16 @@
"mdi:pump",
)
],
"get_user_menu_state": [
Map(
"User Menu Lock",
"set_user_menu_state",
EntityCategory.CONFIG,
USER_MENU_STATE_TO_NUMBER,
NUMBER_TO_USER_MENU_STATE,
"mdi:menu",
)
],
}


Expand Down
16 changes: 0 additions & 16 deletions custom_components/nilan/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@
3: "Water",
}

USER_MENU_STATES = {
0: "Closed",
1: "Open",
2: "No Off Key",
}

ANODE_STATES = {
0: "Off",
Expand Down Expand Up @@ -406,17 +401,6 @@
VENTILATION_STATES,
)
],
"get_user_menu_state": [
Map(
"User Menu State",
None,
None,
SensorStateClass.MEASUREMENT,
None,
None,
USER_MENU_STATES,
)
],
"get_anode_state": [
Map(
"Anode State",
Expand Down

0 comments on commit d302203

Please sign in to comment.