Skip to content

Commit

Permalink
Change identifier from serial number to mac address
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Sep 15, 2021
1 parent 5513d63 commit 2508337
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
5 changes: 2 additions & 3 deletions custom_components/yi_hack/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .const import (ALLWINNER, ALLWINNERV2, CONF_AI_HUMAN_DETECTION_START_MSG,
CONF_AI_HUMAN_DETECTION_STOP_MSG, CONF_BABY_CRYING_MSG,
CONF_BIRTH_MSG, CONF_HACK_NAME, CONF_MOTION_START_MSG,
CONF_MOTION_STOP_MSG, CONF_MQTT_PREFIX, CONF_SERIAL,
CONF_MOTION_STOP_MSG, CONF_MQTT_PREFIX,
CONF_SOUND_DETECTION_MSG, CONF_TOPIC_AI_HUMAN_DETECTION,
CONF_TOPIC_BABY_CRYING, CONF_TOPIC_MOTION_DETECTION,
CONF_TOPIC_SOUND_DETECTION, CONF_TOPIC_STATUS,
Expand Down Expand Up @@ -60,7 +60,6 @@ def __init__(self, config: ConfigEntry, sensor_type):
"""Initialize the sensor."""
self._state = False
self._device_name = config.data[CONF_NAME]
self._serial_number = config.data[CONF_SERIAL]
self._mac = config.data[CONF_MAC]
self._mqtt_subscription = None
self._delay_listener = None
Expand Down Expand Up @@ -184,7 +183,7 @@ def device_info(self):
return {
"name": self._device_name,
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
"identifiers": {(DOMAIN, self._serial_number)},
"identifiers": {(DOMAIN, self._mac)},
"manufacturer": DEFAULT_BRAND,
"model": DOMAIN,
}
10 changes: 4 additions & 6 deletions custom_components/yi_hack/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from .common import (get_privacy, set_power_off_in_progress,
set_power_on_in_progress, set_privacy)
from .const import (ALLWINNER, ALLWINNERV2, CONF_HACK_NAME, CONF_MQTT_PREFIX,
CONF_PTZ, CONF_SERIAL, CONF_TOPIC_MOTION_DETECTION_IMAGE,
DEFAULT_BRAND, DOMAIN, HTTP_TIMEOUT, LINK_HIGH_RES_STREAM,
CONF_PTZ, CONF_TOPIC_MOTION_DETECTION_IMAGE, DEFAULT_BRAND,
DOMAIN, HTTP_TIMEOUT, LINK_HIGH_RES_STREAM,
LINK_LOW_RES_STREAM, MSTAR, SERVICE_PTZ, SERVICE_SPEAK)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -113,7 +113,6 @@ def __init__(self, hass, config):
self._name = self._device_name + "_cam"
self._unique_id = self._device_name + "_caca"
self._mac = config.data[CONF_MAC]
self._serial_number = config.data[CONF_SERIAL]
self._host = config.data[CONF_HOST]
self._port = config.data[CONF_PORT]
self._user = config.data[CONF_USERNAME]
Expand Down Expand Up @@ -349,7 +348,7 @@ def device_info(self):
return {
"name": self._device_name,
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
"identifiers": {(DOMAIN, self._serial_number)},
"identifiers": {(DOMAIN, self._mac)},
"manufacturer": DEFAULT_BRAND,
"model": DOMAIN,
}
Expand All @@ -365,7 +364,6 @@ def __init__(self, hass: HomeAssistant, config):
self._name = self._device_name + "_motion_detection_cam"
self._unique_id = self._device_name + "_camd"
self._mac = config.data[CONF_MAC]
self._serial_number = config.data[CONF_SERIAL]
self._state_topic = config.data[CONF_MQTT_PREFIX] + "/" + config.data[CONF_TOPIC_MOTION_DETECTION_IMAGE]
self._last_image = None
self._mqtt_subscription = None
Expand Down Expand Up @@ -432,7 +430,7 @@ def device_info(self):
return {
"name": self._device_name,
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
"identifiers": {(DOMAIN, self._serial_number)},
"identifiers": {(DOMAIN, self._mac)},
"manufacturer": DEFAULT_BRAND,
"model": DOMAIN,
}
5 changes: 2 additions & 3 deletions custom_components/yi_hack/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from .common import (get_privacy, set_power_off_in_progress,
set_power_on_in_progress, set_privacy)
from .const import CONF_SERIAL, DEFAULT_BRAND, DOMAIN, HTTP_TIMEOUT
from .const import DEFAULT_BRAND, DOMAIN, HTTP_TIMEOUT

SUPPORT_YIHACK_MEDIA = (
SUPPORT_PLAY_MEDIA
Expand All @@ -44,7 +44,6 @@ def __init__(self, config):
self._name = self._device_name + "_media_player"
self._unique_id = self._device_name + "_mpca"
self._mac = config.data[CONF_MAC]
self._serial_number = config.data[CONF_SERIAL]
self._host = config.data[CONF_HOST]
self._port = config.data[CONF_PORT]
self._user = config.data[CONF_USERNAME]
Expand Down Expand Up @@ -89,7 +88,7 @@ def device_info(self):
return {
"name": self._device_name,
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
"identifiers": {(DOMAIN, self._serial_number)},
"identifiers": {(DOMAIN, self._mac)},
"manufacturer": DEFAULT_BRAND,
"model": DOMAIN,
}
Expand Down
5 changes: 2 additions & 3 deletions custom_components/yi_hack/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from .common import (get_privacy, set_power_off_in_progress,
set_power_on_in_progress, set_privacy)
from .const import CONF_SERIAL, DEFAULT_BRAND, DOMAIN
from .const import DEFAULT_BRAND, DOMAIN

_LOGGER = logging.getLogger(__name__)

Expand All @@ -27,7 +27,6 @@ def __init__(self, hass, config):
self._name = self._device_name + "_privacy"
self._unique_id = self._device_name + "_swpr"
self._mac = config.data[CONF_MAC]
self._serial_number = config.data[CONF_SERIAL]
self._host = config.data[CONF_HOST]
self._port = config.data[CONF_PORT]
self._user = config.data[CONF_USERNAME]
Expand Down Expand Up @@ -105,7 +104,7 @@ def device_info(self):
return {
"name": self._device_name,
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
"identifiers": {(DOMAIN, self._serial_number)},
"identifiers": {(DOMAIN, self._mac)},
"manufacturer": DEFAULT_BRAND,
"model": DOMAIN,
}

0 comments on commit 2508337

Please sign in to comment.