Add unique_id to WOL integration (#49604)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Doomic 2021-04-26 15:55:41 +02:00 committed by GitHub
parent a7393cd8b4
commit 41d6d64ca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -14,6 +14,7 @@ from homeassistant.const import (
CONF_MAC, CONF_MAC,
CONF_NAME, CONF_NAME,
) )
from homeassistant.helpers import device_registry as dr
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.script import Script from homeassistant.helpers.script import Script
@ -87,6 +88,7 @@ class WolSwitch(SwitchEntity):
) )
self._state = False self._state = False
self._assumed_state = host is None self._assumed_state = host is None
self._unique_id = dr.format_mac(mac_address)
@property @property
def is_on(self): def is_on(self):
@ -108,6 +110,11 @@ class WolSwitch(SwitchEntity):
"""Return false if assumed state is true.""" """Return false if assumed state is true."""
return not self._assumed_state return not self._assumed_state
@property
def unique_id(self):
"""Return the unique id of this switch."""
return self._unique_id
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
"""Turn the device on.""" """Turn the device on."""
service_kwargs = {} service_kwargs = {}