Skip to content

Commit

Permalink
Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Mar 6, 2022
1 parent 56d7e2a commit c93b6d8
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 23 deletions.
2 changes: 0 additions & 2 deletions custom_components/yi_hack/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
CONF_TOPIC_STATUS, CONF_WILL_MSG, DEFAULT_BRAND, DOMAIN,
MSTAR, SONOFF, V5)

ICON = "mdi:update"

_LOGGER = logging.getLogger(__name__)


Expand Down
11 changes: 7 additions & 4 deletions custom_components/yi_hack/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import requests
from requests.auth import HTTPBasicAuth

from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
CONF_USERNAME,
)
from homeassistant.util import dt as dt_util

from .const import (
Expand All @@ -19,9 +25,6 @@

_LOGGER = logging.getLogger(__name__)

#device_is_on = None
#end_of_power_off = None
#end_of_power_on = None

def get_status(config):
"""Get system status from camera."""
Expand Down
51 changes: 38 additions & 13 deletions custom_components/yi_hack/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,46 @@
import requests
from requests.auth import HTTPBasicAuth

from homeassistant.components.media_player import (DEVICE_CLASS_SPEAKER,
MediaPlayerEntity)
from homeassistant.components.media_player.const import (MEDIA_TYPE_MUSIC,
SUPPORT_PLAY_MEDIA,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON)
from homeassistant.const import (CONF_HOST, CONF_MAC, CONF_NAME, CONF_PASSWORD,
CONF_PORT, CONF_USERNAME, STATE_IDLE,
STATE_OFF, STATE_ON, STATE_PLAYING)
from homeassistant.components.media_player import (
DEVICE_CLASS_SPEAKER,
MediaPlayerEntity
)
from homeassistant.components.media_player.const import (
MEDIA_TYPE_MUSIC,
SUPPORT_PLAY_MEDIA,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON
)
from homeassistant.const import (
CONF_HOST,
CONF_MAC,
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
CONF_USERNAME,
STATE_IDLE,
STATE_OFF,
STATE_ON,
STATE_PLAYING
)
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC

from .common import (get_privacy, set_power_off_in_progress,
set_power_on_in_progress, set_privacy)
from .const import (ALLWINNER, ALLWINNERV2, CONF_BOOST_SPEAKER, CONF_HACK_NAME,
DEFAULT_BRAND, DOMAIN, HTTP_TIMEOUT, MSTAR)
from .common import (
get_privacy,
set_power_off_in_progress,
set_power_on_in_progress,
set_privacy
)
from .const import (
ALLWINNER,
ALLWINNERV2,
CONF_BOOST_SPEAKER,
CONF_HACK_NAME,
DEFAULT_BRAND,
DOMAIN,
HTTP_TIMEOUT,
MSTAR
)

SUPPORT_YIHACK_MEDIA = (
SUPPORT_PLAY_MEDIA
Expand Down
4 changes: 0 additions & 4 deletions custom_components/yi_hack/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def update(self):
(CONF_USERNAME, self._user),
(CONF_PASSWORD, self._password),
])
#self._state = self.hass.async_add_executor_job(get_privacy, self.hass, conf)
#self.hass.async_add_executor_job(set_privacy, self.hass, self._state)
self._state = get_privacy(self.hass, self._device_name, conf)
set_privacy(self.hass, self._device_name, self._state)

Expand All @@ -54,7 +52,6 @@ def turn_off(self):
(CONF_USERNAME, self._user),
(CONF_PASSWORD, self._password),
])
#privacy = self.hass.async_add_executor_job(get_privacy, self.hass)
if get_privacy(self.hass, self._device_name):
_LOGGER.debug("Turn off privacy, camera %s", self._name)
set_power_off_in_progress(self.hass, self._device_name)
Expand All @@ -70,7 +67,6 @@ def turn_on(self):
(CONF_USERNAME, self._user),
(CONF_PASSWORD, self._password),
])
#privacy = self.hass.async_add_executor_job(get_privacy, self.hass)
if not get_privacy(self.hass, self._device_name):
_LOGGER.debug("Turn on privacy, camera %s", self._name)
set_power_on_in_progress(self.hass, self._device_name)
Expand Down

0 comments on commit c93b6d8

Please sign in to comment.