The version is under development and will be called v4.0.0
This post has been updated over time
It is highly recommended to make a backup before upgrading!
Why? With the yet another Home Assistant update, the mechanism of creating entities was broken. They only worked when the Home Assistant was started. And became unavailable with any restart of the integration.
Creating entities is a very complicated part of integration. Some may be created on the first connection to the gateway. Some may appear when new devices are connected. If there are no converters for the device - entities can be created when the first data from the device appears.
But the most difficult part is that multiple integrations (gateways) may try to create the same entity. This works for BLE, Mesh, and sometimes even Zigbee devices. This behavior is not supported by the Home Assistant core. And needs to be coded very carefully.
So I decided to rework the entire component once again.
Breaking changes
A lot of things have changed in the integration and something may not work and something has to be manually updated.
Converters
All converters moved to /xiaomi_gateway3/core/devices.py.
All entities descriptions moved to /xiaomi_gateway3/hass/entity_description.py.
Basic converter class simplified
# before
@dataclass
class Converter:
attr: str # hass attribute
domain: Optional[str] = None # hass domain
mi: Optional[str] = None
parent: Optional[str] = None
enabled: Optional[bool] = True # support: True, False, None (lazy setup)
poll: bool = False # hass should_poll
# don't init with dataclass because no type:
childs = None # set or dict? of children attributes
zigbee = None # str or set? with zigbee cluster
# after
@dataclass
class BaseConv:
attr: str
domain: str = None
mi: str | int = None
entity: dict = None
Deprecated enabled=False
Moved to entity.enabled=False param
# before
BoolConv("led", "switch", mi="6.p.6", enabled=False),
# after
BoolConv("led", "switch", mi="6.p.6", entity={"enabled": False}),
Deprecated enabled=None
Moved to entity.lazy=True param
# before
Converter("battery", "sensor", enabled=None), # no in new firmwares
# after
Converter("battery", "sensor", entity={"lazy": True}),
Deprecated parent="..."
Now the entities know what attributes they need to subscribe to
## Stats sensors
Now can be either `sensor` or `binary_sensor`. The sensor data has also changed:
- Many useful info about `uid`, `did`, `mac`, `brand`, `model`, market and cloud names
- List of connected gateways
- Time from last message and info about last gateway
- Total payload from all messages
```yaml
extra:
cloud_fw: 2.1.1_0037
cloud_name: Home Lamp 1
did: '1234567890'
mac: 50:ec:50:aa:bb:cc
market_brand: Xiaomi
market_model: MJDP09YL, yeelink.light.mbulb3
market_name: Mesh Bulb
rssi_54ef44ccddff: -77
rssi_6490c1ccddff: -52
type: mesh
gateways: 54ef44ccddff, 6490c1ccddff
last_decode: 6m8s
last_decode_gw:
fw_ver: 1.5.4_0090
host: 192.168.1.123
mac: 64:90:c1:cc:dd:ff
model: lumi.gateway.mgl03
last_encode: 6m9s
last_report:
light: false
model: 1771
payload:
brightness: 255.0
color_temp: 190
flex_switch: true
light: false
ttl: 20m
uid: 50ec50aabbcc
Log format also have been reworked. Now you can control basic and mqtt logs from:
Integration config (each type of data for each gateway)
Global integration debug logs from Home Assistant Web UI
configuration.yaml
logger:
default: warning
logs:
custom_components.xiaomi_gateway3: warning
custom_components.xiaomi_gateway3.gate: info
custom_components.xiaomi_gateway3.mqtt: info
custom_components.xiaomi_gateway3.gate.192.168.1.123: debug
custom_components.xiaomi_gateway3.mqtt.192.168.1.234: debug
Command select
Now EVERY device has command select. Options list depends to device type:
Device info - shows full device info in the Home Assistant notification. Same info you get in the stats sensors and in device diagnostics
Device update - request state update from device. BLE devices and many battery Zigbee devices can't be requested
Device delete - only Zigbee device option. Sends leave signal to Zigbee device
Cloud Integration
Now supports multiple accounts
Now supports reloading the integration to update data
Shows more information about devices
Fixed name support for new Zigbee devices
Zigbee force pairing
In the default "zigbee pairing" mode you can pair supported MiHome zigbee devices and 3rd party zigbee devices. But you can't pair unsupported MiHome zigbee devices.
In this mode you can pair any zigbee device, but it won't be displayed in the MiHome even if supported.
RSSI
Now supported for BLE and Mesh. Data is logged separately for each gateway.
Mesh groups
Now Mesh groups is another device type. Groups of different models (light, cover) are also supported.
Matter
Support Matter child devices for Xiaomi Miltimode Gateway 2 (EU) on fw 1.0.7_0019.
Device triggers
Was changed from multiple types and multiple actions. To one type - action and multiple states.
If you used device triggers - them should be updated manually.
Delete device
Now deleting Home Assistant device won't delete it from Gateway. For deleting Zigbee device you can use "command select". For deleting other devices you should use MiHome.
Gateway alarm
Now has trigger for enabling and disabling.
Gateway disabling
Now gateways has disable and enable options via "command select". Them just for test, so you can check if your BLE/Mesh devices still can be controlled when some of your gateways down.
IMPORTANT
Why? With the yet another Home Assistant update, the mechanism of creating entities was broken. They only worked when the Home Assistant was started. And became unavailable with any restart of the integration.
Creating entities is a very complicated part of integration. Some may be created on the first connection to the gateway. Some may appear when new devices are connected. If there are no converters for the device - entities can be created when the first data from the device appears.
But the most difficult part is that multiple integrations (gateways) may try to create the same entity. This works for BLE, Mesh, and sometimes even Zigbee devices. This behavior is not supported by the Home Assistant core. And needs to be coded very carefully.
So I decided to rework the entire component once again.
Breaking changes
A lot of things have changed in the integration and something may not work and something has to be manually updated.
Converters
All converters moved to
/xiaomi_gateway3/core/devices.py
. All entities descriptions moved to/xiaomi_gateway3/hass/entity_description.py
.Basic converter class simplified
Deprecated enabled=False
entity.enabled=False
paramDeprecated enabled=None
entity.lazy=True
paramDeprecated parent="..."
Setup entity description inside converter
Multiple models
hhcc.plantmonitor.v1
)after
"lumi.gateway.mgl03": ["Xiaomi", "Multimode Gateway", "ZNDMWG03LM", "ZNDMWG02LM", "YTC4044GL"], "lumi.gateway.mgl001": ["Xiaomi", "Multimode Gateway 2 EU", "ZNDMWG04LM", "BHR6765GL"], 152: ["Xiaomi", "Flower Care", "HHCCJCY01", "hhcc.plantmonitor.v1"], 1371: ["Xiaomi", "TH Sensor 2", "LYWSD03MMC", "miaomiaoce.sensor_ht.t2"],
BLE new converters
MiOT spec buttons
ButtonMIConv("button")
deprecated,ConstConv("action")
should be usedMiOT events
mi="3.e.1012"
changed to"3.e.1012.p.1"
if event has paramsZigbee converters
Now linked to ZHA contants to increase readability
after
from zigpy.zcl.clusters.general import OnOff
class ZOnOffConv(ZBoolConv): cluster_id = OnOff.cluster_id attr_id = OnOff.AttributeDefs.on_off.id
Customize deprecated
xiaomi_gateway3.devices
after
xiaomi_gateway3: devices: "0x00158d00ccddeeff": occupancy_timeout: 180
Stats table
Attributes template
Logging
Log format also have been reworked. Now you can control basic and mqtt logs from:
configuration.yaml
Command select
Now EVERY device has command select. Options list depends to device type:
Cloud Integration
Zigbee force pairing
In the default "zigbee pairing" mode you can pair supported MiHome zigbee devices and 3rd party zigbee devices. But you can't pair unsupported MiHome zigbee devices. In this mode you can pair any zigbee device, but it won't be displayed in the MiHome even if supported.
RSSI
Now supported for BLE and Mesh. Data is logged separately for each gateway.
Mesh groups
Now Mesh groups is another device type. Groups of different models (
light
,cover
) are also supported.Matter
Support Matter child devices for Xiaomi Miltimode Gateway 2 (EU) on fw 1.0.7_0019.
Device triggers
Was changed from multiple types and multiple actions. To one type - action and multiple states. If you used device triggers - them should be updated manually.
Delete device
Now deleting Home Assistant device won't delete it from Gateway. For deleting Zigbee device you can use "command select". For deleting other devices you should use MiHome.
Gateway alarm
Now has trigger for enabling and disabling.
Gateway disabling
Now gateways has disable and enable options via "command select". Them just for test, so you can check if your BLE/Mesh devices still can be controlled when some of your gateways down.