mystrom: Add MAC and Config URL to devices (#120271)
* Add MAC address to mystrom switch devices * Add configuration URL to mystrom switch devices
This commit is contained in:
parent
19f97a3e53
commit
66b91a84f9
2 changed files with 10 additions and 1 deletions
|
@ -10,7 +10,7 @@ from pymystrom.exceptions import MyStromConnectionError
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo, format_mac
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN, MANUFACTURER
|
from .const import DOMAIN, MANUFACTURER
|
||||||
|
@ -43,6 +43,8 @@ class MyStromSwitch(SwitchEntity):
|
||||||
name=name,
|
name=name,
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
sw_version=self.plug.firmware,
|
sw_version=self.plug.firmware,
|
||||||
|
connections={("mac", format_mac(self.plug.mac))},
|
||||||
|
configuration_url=self.plug.uri,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
|
|
|
@ -173,3 +173,10 @@ class MyStromSwitchMock(MyStromDeviceMock):
|
||||||
if not self._requested_state:
|
if not self._requested_state:
|
||||||
return None
|
return None
|
||||||
return self._state["temperature"]
|
return self._state["temperature"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def uri(self) -> str | None:
|
||||||
|
"""Return the URI."""
|
||||||
|
if not self._requested_state:
|
||||||
|
return None
|
||||||
|
return f"http://{self._state["ip"]}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue