Skip to content

Commit

Permalink
Merge pull request #39 from natekspencer/dev
Browse files Browse the repository at this point in the history
Distinguish Pura 4 from Pura 3
  • Loading branch information
natekspencer authored Dec 9, 2023
2 parents 32424a7 + afc6cd7 commit f7be59d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions custom_components/pura/entity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Pura entities."""
from __future__ import annotations

from typing import Any

from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.device_registry import (
CONNECTION_BLUETOOTH,
Expand All @@ -16,7 +18,15 @@

UPDATE_INTERVAL = 30

PURA_MODEL_MAP = {1: "Pura 3", "car": "Pura Car"}
PURA_MODEL_MAP = {1: "Wall", 2: "Car", "car": "Car", 3: "Plus", 4: "Mini"}


def determine_pura_model(data: dict[str, Any]) -> str | None:
"""Determine pura device model."""
if (model := PURA_MODEL_MAP.get(m := data.get("model"), m)) == "Wall":
version = data.get("hwVersion", "3").split(".", 1)[0]
model = "3" if version in ("1", "2") else version
return f"Pura {model}"


def has_fragrance(data: dict, bay: int) -> bool:
Expand Down Expand Up @@ -58,7 +68,7 @@ def __init__(
},
identifiers={(DOMAIN, device_id)},
manufacturer="Pura",
model=PURA_MODEL_MAP.get(model := device.get("model"), model),
model=determine_pura_model(device),
name=f"{name} Diffuser",
suggested_area=name if device_type == "wall" else None,
sw_version=first_key_value(device, ("fw_version", "fwVersion")),
Expand Down

0 comments on commit f7be59d

Please sign in to comment.