From 1ca1815866f260fd19490b65cb286b1d2502c469 Mon Sep 17 00:00:00 2001 From: Ruslan Sayfutdinov Date: Thu, 11 Mar 2021 16:56:35 +0000 Subject: [PATCH] Fix no-member warning (#84) --- custom_components/google_home/entity.py | 35 +++++++------------------ custom_components/google_home/sensor.py | 30 ++------------------- pyproject.toml | 1 - 3 files changed, 12 insertions(+), 54 deletions(-) diff --git a/custom_components/google_home/entity.py b/custom_components/google_home/entity.py index 7b18e2fed..265b417d0 100644 --- a/custom_components/google_home/entity.py +++ b/custom_components/google_home/entity.py @@ -17,9 +17,9 @@ class GoogleHomeDeviceEntity(CoordinatorEntity): - def __init__(self, coordinator, config_entry): + def __init__(self, coordinator, device_name): super().__init__(coordinator) - self.config_entry = config_entry + self.device_name = device_name @property def device_info(self): @@ -45,11 +45,6 @@ def icon(self): """Return the icon of the sensor.""" return ICON_TOKEN - @property - def state(self): - """Return the state of the sensor.""" - return self._state - @property def device_class(self): """Return de device class of the sensor.""" @@ -57,9 +52,9 @@ def device_class(self): class GoogleHomeAlarmEntity(CoordinatorEntity): - def __init__(self, coordinator, config_entry): + def __init__(self, coordinator, device_name): super().__init__(coordinator) - self.config_entry = config_entry + self.device_name = device_name @property def device_info(self): @@ -85,16 +80,11 @@ def icon(self): """Icon to use in the frontend, if any.""" return ICON_ALARMS - @property - def state(self): - """Return the state of the sensor.""" - return self._state - class GoogleHomeNextAlarmEntity(CoordinatorEntity): - def __init__(self, coordinator, config_entry): + def __init__(self, coordinator, device_name): super().__init__(coordinator) - self.config_entry = config_entry + self.device_name = device_name @property def device_info(self): @@ -122,9 +112,9 @@ def icon(self): class GoogleHomeTimersEntity(CoordinatorEntity): - def __init__(self, coordinator, config_entry): + def __init__(self, coordinator, device_name): super().__init__(coordinator) - self.config_entry = config_entry + self.device_name = device_name @property def name(self): @@ -150,16 +140,11 @@ def icon(self): """Icon to use in the frontend, if any.""" return ICON_TIMERS - @property - def state(self): - """Return the state of the sensor.""" - return self._state - class GoogleHomeNextTimerEntity(CoordinatorEntity): - def __init__(self, coordinator, config_entry): + def __init__(self, coordinator, device_name): super().__init__(coordinator) - self.config_entry = config_entry + self.device_name = device_name @property def device_info(self): diff --git a/custom_components/google_home/sensor.py b/custom_components/google_home/sensor.py index 7afd83bf3..4894bff0d 100644 --- a/custom_components/google_home/sensor.py +++ b/custom_components/google_home/sensor.py @@ -23,7 +23,6 @@ async def async_setup_entry(hass, entry, async_add_devices): sensors.append( GoogleHomeDeviceSensor( coordinator, - entry, device.name, device.auth_token, ) @@ -32,22 +31,18 @@ async def async_setup_entry(hass, entry, async_add_devices): sensors += [ GoogleHomeAlarmSensor( coordinator, - entry, device.name, ), GoogleHomeNextAlarmSensor( coordinator, - entry, device.name, ), GoogleHomeTimerSensor( coordinator, - entry, device.name, ), GoogleHomeNextTimerSensor( coordinator, - entry, device.name, ), ] @@ -76,10 +71,9 @@ def as_dict(obj_list): class GoogleHomeDeviceSensor(GoogleHomeSensorMixin, GoogleHomeDeviceEntity): """GoogleHome Device Sensor class.""" - def __init__(self, coordinator, entry, device_name, auth_token): + def __init__(self, coordinator, device_name, auth_token): """Initialize the sensor.""" - super().__init__(coordinator, entry) - self.device_name = device_name + super().__init__(coordinator, device_name) self.auth_token = auth_token @property @@ -119,11 +113,6 @@ def get_device_attributes(device): class GoogleHomeAlarmSensor(GoogleHomeSensorMixin, GoogleHomeAlarmEntity): """Representation of a Sensor.""" - def __init__(self, coordinator, entry, device_name): - """Initialize the sensor.""" - super().__init__(coordinator, entry) - self.device_name = device_name - @property def state(self): alarms = self._get_alarms_data() @@ -147,11 +136,6 @@ def _get_alarms_data(self): class GoogleHomeNextAlarmSensor(GoogleHomeSensorMixin, GoogleHomeNextAlarmEntity): """Representation of a Sensor.""" - def __init__(self, coordinator, entry, device_name): - """Initialize the sensor.""" - super().__init__(coordinator, entry) - self.device_name = device_name - @property def state(self): alarm = self._get_next_alarm() @@ -179,11 +163,6 @@ def _get_next_alarm(self): class GoogleHomeTimerSensor(GoogleHomeSensorMixin, GoogleHomeTimersEntity): """Representation of a Sensor.""" - def __init__(self, coordinator, entry, device_name): - """Initialize the sensor.""" - super().__init__(coordinator, entry) - self.device_name = device_name - @property def state(self): timers = self._get_timers_data() @@ -206,11 +185,6 @@ def _get_timers_data(self): class GoogleHomeNextTimerSensor(GoogleHomeSensorMixin, GoogleHomeNextTimerEntity): """Representation of a Sensor.""" - def __init__(self, coordinator, entry, device_name): - """Initialize the sensor.""" - super().__init__(coordinator, entry) - self.device_name = device_name - @property def state(self): timer = self._get_next_timer() diff --git a/pyproject.toml b/pyproject.toml index 85f788d65..919a9c2c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ disable = [ "missing-class-docstring", "missing-function-docstring", "missing-module-docstring", - "no-member", "too-few-public-methods", "too-many-arguments", "too-many-instance-attributes",