Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Luba sensors pt 4 #16

Merged
merged 16 commits into from
Jul 8, 2024
6 changes: 5 additions & 1 deletion custom_components/mammotion/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from .const import DOMAIN
from .coordinator import MammotionDataUpdateCoordinator
from pyluba.utility.device_type import DeviceType

_LOGGER = logging.getLogger(__name__)

Expand All @@ -25,7 +26,10 @@ def __init__(
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device_name)},
manufacturer="Mammotion",
serial_number=coordinator.device.luba_msg.net.toapp_wifi_iot_status.productkey,
serial_number=device_name.split('-', 1)[-1],
# ToDo: To add in once betterproto is fixed
# sw_version=coordinator.device.luba_msg.net.toapp_devinfo_resp.resp_ids.get(0, {}).get('info', "Loading..."),
model=DeviceType.value_of_str(device_name, coordinator.device.luba_msg.net.toapp_wifi_iot_status.productkey).get_model(),
name=device_name,
suggested_area="Garden",
)
Expand Down
6 changes: 5 additions & 1 deletion custom_components/mammotion/lawn_mower.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from homeassistant.helpers.typing import ConfigType
from pyluba.mammotion.devices.luba import has_field
from pyluba.utility.constant.device_constant import WorkMode
from pyluba.utility.device_type import DeviceType

from .const import DOMAIN
from .coordinator import MammotionDataUpdateCoordinator
Expand Down Expand Up @@ -74,7 +75,10 @@ def __init__(
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device_name)},
manufacturer="Mammotion",
serial_number=coordinator.device.luba_msg.net.toapp_wifi_iot_status.productkey,
serial_number=device_name.split('-', 1)[-1],
# ToDo: To add in once betterproto is fixed
# sw_version=coordinator.device.luba_msg.net.toapp_devinfo_resp.resp_ids.get(0, {}).get('info', "Loading..."),
model=DeviceType.value_of_str(device_name, coordinator.device.luba_msg.net.toapp_wifi_iot_status.productkey).get_model(),
name=device_name,
suggested_area="Garden",
)
Expand Down
1 change: 0 additions & 1 deletion custom_components/mammotion/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class MammotionSensorEntityDescription(SensorEntityDescription):
MammotionSensorEntityDescription(
key="position_mode",
name="RTK Connection",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.ENUM,
native_unit_of_measurement=None,
value_fn=lambda mower_data: str(RTKStatus.from_value(mower_data.sys.toapp_report_data.rtk.status)), # Note: This will not work for Luba2 & Yuka. Only for Luba1
Expand Down