Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ light:
host: 192.168.130.67
token: da548d86f55996413d82eea94279d2ff
model: philips.light.bulb
unique_id: 12345
- platform: xiaomi_miio_philipslight
name: Xiaomi Philips Smart LED Ceiling Lamp
host: 192.168.130.68
Expand All @@ -123,6 +124,7 @@ Configuration variables:
- **token** (*Required*): The API token of your light.
- **name** (*Optional*): The name of your light.
- **model** (*Optional*): The model of your light. Valid values are `philips.light.sread1`, `philips.light.ceiling`, `philips.light.zyceiling`, `philips.light.moonlight`, `philips.light.bulb`, `philips.light.candle`, `philips.light.candle2`, `philips.light.mono1` and `philips.light.downlight`. This setting can be used to bypass the device model detection and is recommended if your device isn't always available.
- **unique_id** (*Optional*): Unique ID of your device. It probably can be set to any reasonable value - such as serial number or mac address. Used to create device from entity in the UI. Without the ID one cannot do that.

## Debugging

Expand Down
5 changes: 3 additions & 2 deletions custom_components/xiaomi_miio_philipslight/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ColorMode,
LightEntity,
)
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_TOKEN
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_TOKEN, CONF_UNIQUE_ID
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Black would make changes.

from homeassistant.exceptions import PlatformNotReady
from homeassistant.util import color, dt
from miio import (
Expand Down Expand Up @@ -60,6 +60,7 @@
]
),
vol.Optional(CONF_AUTO_MIDNIGHT_MODE, default=True): cv.boolean,
vol.Optional(CONF_UNIQUE_ID): cv.string,
}
)

Expand Down Expand Up @@ -133,12 +134,12 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
token = config[CONF_TOKEN]
name = config[CONF_NAME]
model = config.get(CONF_MODEL)
unique_id = config[CONF_UNIQUE_ID]
auto_midnight_mode = config.get(CONF_AUTO_MIDNIGHT_MODE)

_LOGGER.info("Initializing with host %s (token %s...)", host, token[:5])

devices = []
unique_id = None

if model is None:
try:
Expand Down