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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
此项目为 [Home Assistant](https://www.home-assistant.io/) 的[巴法云](https://cloud.bemfa.com/)插件。
## 修复
修复高版本HA的mqtt版本不兼容导致的bemfa插件失效问题 25/09/10
修复参考(https://bbs.hassbian.com/thread-29794-1-1.html)帖子和评论

修复core 2025.11.0 CAMERA_DOMAIN不兼容的问题




## 功能
将 Home Assistant 实体同步至巴法云,并使用小爱同学/天猫精灵/小度音箱控制。
Expand Down
2 changes: 1 addition & 1 deletion custom_components/bemfa/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Final

from homeassistant.backports.enum import StrEnum
from enum import StrEnum

DOMAIN: Final = "bemfa"

Expand Down
6 changes: 3 additions & 3 deletions custom_components/bemfa/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"homekit": {},
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/larry-wong/bemfa/issues",
"requirements": ["paho-mqtt==1.6.1"],
"requirements": ["paho-mqtt==2.1.0"],
"ssdp": [],
"version": "1.4.0",
"version": "1.4.2",
"zeroconf": []
}
}
3 changes: 2 additions & 1 deletion custom_components/bemfa/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def __init__(
self._hass = hass

# Init MQTT connection
self._mqttc = mqtt.Client(uid, mqtt.MQTTv311)
#self._mqttc = mqtt.Client(uid, mqtt.MQTTv311)
self._mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, client_id=uid, protocol=mqtt.MQTTv311)

self._topic_to_sync: dict[str, Sync] = {}

Expand Down
14 changes: 7 additions & 7 deletions custom_components/bemfa/sync_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_BRIGHTNESS_PCT,
ATTR_COLOR_TEMP,
ATTR_MAX_MIREDS,
ATTR_MIN_MIREDS,
ATTR_COLOR_TEMP_KELVIN,
ATTR_MIN_COLOR_TEMP_KELVIN,
ATTR_MAX_COLOR_TEMP_KELVIN,
ATTR_RGB_COLOR,
ATTR_SUPPORTED_COLOR_MODES,
DOMAIN,
Expand Down Expand Up @@ -45,8 +45,8 @@ def _msg_generators(
lambda state, attributes: round(attributes[ATTR_BRIGHTNESS] / 2.55)
if has_key(attributes, ATTR_BRIGHTNESS)
else "",
lambda state, attributes: 1000000 // attributes[ATTR_COLOR_TEMP]
if has_key(attributes, ATTR_COLOR_TEMP)
lambda state, attributes: 1000000 // attributes[ATTR_COLOR_TEMP_KELVIN]
if has_key(attributes, ATTR_COLOR_TEMP_KELVIN)
else attributes[ATTR_RGB_COLOR][0] * 256 * 256
+ attributes[ATTR_RGB_COLOR][1] * 256
+ attributes[ATTR_RGB_COLOR][2]
Expand Down Expand Up @@ -76,8 +76,8 @@ def _msg_resolvers(
{
ATTR_BRIGHTNESS_PCT: msg[1],
ATTR_COLOR_TEMP: min(
max(1000000 // msg[2], attributes[ATTR_MIN_MIREDS]),
attributes[ATTR_MAX_MIREDS],
max(1000000 // msg[2], attributes[ATTR_MAX_COLOR_TEMP_KELVIN]),
attributes[ATTR_MIN_COLOR_TEMP_KELVIN],
),
}
if len(msg) > 2
Expand Down
1 change: 0 additions & 1 deletion custom_components/bemfa/sync_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
SelectSelectorConfig,
SelectSelectorMode,
)
from homeassistant.helpers.template import area_entities
from .utils import has_key
from .const import (
OPTIONS_CO2,
Expand Down
10 changes: 5 additions & 5 deletions custom_components/bemfa/sync_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from collections.abc import Mapping, Callable
from typing import Any
from homeassistant.components.automation import DOMAIN as AUTOMATION_DOMAIN
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN, STATE_IDLE
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
from homeassistant.components.camera.const import CameraState
from homeassistant.components.group import DOMAIN as GROUP_DOMAIN
from homeassistant.components.humidifier import DOMAIN as HUMIDIFIER_DOMAIN
from homeassistant.components.input_boolean import DOMAIN as INPUT_BOOLEAN_DOMAIN
Expand All @@ -20,16 +21,15 @@
SERVICE_RETURN_TO_BASE,
SERVICE_START,
SERVICE_STOP,
STATE_CLEANING,
VacuumEntityFeature,
VacuumActivity,
)
from homeassistant.const import (
ATTR_SUPPORTED_FEATURES,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
SERVICE_UNLOCK,
SERVICE_LOCK,
STATE_LOCKED,
STATE_ON,
STATE_PLAYING,
)
Expand Down Expand Up @@ -148,7 +148,7 @@ def _supported_domain() -> str:
def _msg_generator(
self,
) -> Callable[[str, ReadOnlyDict[Mapping[str, Any]]], str | int]:
return lambda state, attributes: MSG_OFF if state == STATE_LOCKED else MSG_ON
return lambda state, attributes: MSG_OFF if state == 'locked' else MSG_ON

def _service_names(self) -> tuple[str, str]:
return (SERVICE_UNLOCK, SERVICE_LOCK)
Expand Down Expand Up @@ -193,7 +193,7 @@ def _msg_generator(
) -> Callable[[str, ReadOnlyDict[Mapping[str, Any]]], str | int]:
return (
lambda state, attributes: MSG_ON
if state in [STATE_ON, STATE_CLEANING]
if state in [STATE_ON, VacuumActivity.CLEANING]
else MSG_OFF
)

Expand Down