Skip to content

Commit

Permalink
Added IoT Network switches
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrErohin committed Jan 11, 2024
1 parent 5797943 commit 3bca5f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ See [Supported routers](#supports)
- 5Ghz main wifi Enable/Disable
- 2.4Ghz guest wifi Enable/Disable
- 5Ghz guest wifi Enable/Disable
- 2.4Ghz IoT wifi network Enable/Disable
- 5Ghz IoT wifi network Enable/Disable

### Sensors
- Total amount of wired clients
Expand Down
4 changes: 2 additions & 2 deletions custom_components/tplink_router/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"documentation": "https://github.com/AlexandrErohin/home-assistant-tplink-router",
"iot_class": "local_polling",
"issue_tracker": "https://github.com/AlexandrErohin/home-assistant-tplink-router/issues",
"requirements": ["tplinkrouterc6u==1.2.3"],
"version": "1.2.5"
"requirements": ["tplinkrouterc6u==1.3.0"],
"version": "1.3.0"
}

21 changes: 21 additions & 0 deletions custom_components/tplink_router/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ class TPLinkRouterSwitchEntityDescription(SwitchEntityDescription, TPLinkRouterS
property='wifi_5g_enable',
method=lambda coordinator, value: coordinator.set_wifi(Wifi.WIFI_5G, value),
),
TPLinkRouterSwitchEntityDescription(
key="iot_24g",
name="IoT WIFI 2.4G",
icon="mdi:wifi",
entity_category=EntityCategory.CONFIG,
property='iot_2g_enable',
method=lambda coordinator, value: coordinator.set_wifi(Wifi.WIFI_IOT_2G, value),
),
TPLinkRouterSwitchEntityDescription(
key="iot_5g",
name="IoT WIFI 5G",
icon="mdi:wifi",
entity_category=EntityCategory.CONFIG,
property='iot_5g_enable',
method=lambda coordinator, value: coordinator.set_wifi(Wifi.WIFI_IOT_5G, value),
),
)


Expand Down Expand Up @@ -97,6 +113,11 @@ def is_on(self) -> bool:
"""Return true if switch is on."""
return getattr(self.coordinator.status, self.entity_description.property)

@property
def available(self) -> bool:
"""Return True if entity is available."""
return getattr(self.coordinator.status, self.entity_description.property) is not None

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
await self.entity_description.method(self.coordinator, True)
Expand Down
Binary file modified docs/media/sensors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3bca5f2

Please sign in to comment.