diff --git a/homeassistant/components/numato/binary_sensor.py b/homeassistant/components/numato/binary_sensor.py index 47ab248d383..a369be43b43 100644 --- a/homeassistant/components/numato/binary_sensor.py +++ b/homeassistant/components/numato/binary_sensor.py @@ -97,7 +97,7 @@ class NumatoGpioBinarySensor(BinarySensorEntity): def __init__(self, name, device_id, port, invert_logic, api): """Initialize the Numato GPIO based binary sensor object.""" - self._name = name or DEVICE_DEFAULT_NAME + self._attr_name = name or DEVICE_DEFAULT_NAME self._device_id = device_id self._port = port self._invert_logic = invert_logic @@ -120,11 +120,6 @@ class NumatoGpioBinarySensor(BinarySensorEntity): self._state = level self.async_write_ha_state() - @property - def name(self): - """Return the name of the sensor.""" - return self._name - @property def is_on(self): """Return the state of the entity.""" diff --git a/homeassistant/components/numato/sensor.py b/homeassistant/components/numato/sensor.py index ef71e00bc73..99ef69baa7b 100644 --- a/homeassistant/components/numato/sensor.py +++ b/homeassistant/components/numato/sensor.py @@ -74,38 +74,22 @@ class NumatoGpioAdc(SensorEntity): def __init__(self, name, device_id, port, src_range, dst_range, dst_unit, api): """Initialize the sensor.""" - self._name = name + self._attr_name = name self._device_id = device_id self._port = port self._src_range = src_range self._dst_range = dst_range - self._state = None - self._unit_of_measurement = dst_unit + self._attr_native_unit_of_measurement = dst_unit self._api = api - @property - def name(self): - """Return the name of the sensor.""" - return self._name - - @property - def native_value(self): - """Return the state of the sensor.""" - return self._state - - @property - def native_unit_of_measurement(self): - """Return the unit the value is expressed in.""" - return self._unit_of_measurement - def update(self) -> None: """Get the latest data and updates the state.""" try: adc_val = self._api.read_adc_input(self._device_id, self._port) adc_val = self._clamp_to_source_range(adc_val) - self._state = self._linear_scale_to_dest_range(adc_val) + self._attr_native_value = self._linear_scale_to_dest_range(adc_val) except NumatoGpioError as err: - self._state = None + self._attr_native_value = None _LOGGER.error( "Failed to update Numato device %s ADC-port %s: %s", self._device_id, diff --git a/homeassistant/components/numato/switch.py b/homeassistant/components/numato/switch.py index 37d1229e0b2..0a7522c8b11 100644 --- a/homeassistant/components/numato/switch.py +++ b/homeassistant/components/numato/switch.py @@ -73,30 +73,20 @@ class NumatoGpioSwitch(SwitchEntity): def __init__(self, name, device_id, port, invert_logic, api): """Initialize the port.""" - self._name = name or DEVICE_DEFAULT_NAME + self._attr_name = name or DEVICE_DEFAULT_NAME self._device_id = device_id self._port = port self._invert_logic = invert_logic - self._state = False + self._attr_is_on = False self._api = api - @property - def name(self): - """Return the name of the switch.""" - return self._name - - @property - def is_on(self): - """Return true if port is turned on.""" - return self._state - def turn_on(self, **kwargs: Any) -> None: """Turn the port on.""" try: self._api.write_output( self._device_id, self._port, 0 if self._invert_logic else 1 ) - self._state = True + self._attr_is_on = True self.schedule_update_ha_state() except NumatoGpioError as err: _LOGGER.error( @@ -112,7 +102,7 @@ class NumatoGpioSwitch(SwitchEntity): self._api.write_output( self._device_id, self._port, 1 if self._invert_logic else 0 ) - self._state = False + self._attr_is_on = False self.schedule_update_ha_state() except NumatoGpioError as err: _LOGGER.error(