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

add light mode for yeelink.bhf_light.v1/v2 #1278

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 12 additions & 1 deletion custom_components/xiaomi_miot/core/miio2miot_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,14 +1434,25 @@ def cbk(prop, params, props, **kwargs):
},
},
'yeelink.bhf_light.v2': {
'miio_props': ['light_mode', 'nl_br'],
'miio_specs': {
'prop.2.1': {'prop': 'power', 'setter': True, 'format': 'onoff'},
'prop.2.2': {'prop': 'bright', 'setter': True, 'set_template': '{{ [value,"smooth",500] }}'},
'prop.2.2': {
'prop': 'bright',
'setter': True,
'set_template': '{{ [value,"smooth",500] }}',
'template': '{{ value if props.light_mode == "daylight" else props.nl_br|default(value)|int }}',
},
'prop.2.101': {
'prop': 'delayoff',
'setter': 'set_scene',
'set_template': '{{ ["auto_delay_off",props.bright|default(100)|int,value] }}',
},
'prop.2.103': {
'prop': 'light_mode',
'setter': 'set_power',
'set_template': '{{ ["on", "smooth", 500, 5 if value == 5 else 1 ] }}',
},
'prop.3.1': {
'prop': 'bh_mode',
'setter': True,
Expand Down
17 changes: 16 additions & 1 deletion custom_components/xiaomi_miot/core/miot_specs_extend.json
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@
]
}
],

"yeelink.bhf_light.v1": "yeelink.bhf_light.v2",
"yeelink.bhf_light.v2": [
{
"iid": 2,
Expand All @@ -1075,6 +1075,21 @@
}
]
},
{
"iid": 2,
"properties": [
{
"iid": 103,
"type": "urn:miot-spec-v2:property:mode",
"format": "uint8",
"access": ["read", "write"],
"value-list": [
{"value": 1, "description": "daylight"},
{"value": 5, "description": "nightlight"}
Copy link
Owner

Choose a reason for hiding this comment

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

建议这里的描述使用Day/Night,能够支持本地化翻译。

"light": {
"light": {
"state_attributes": {
"effect_list": {
"state": {
"Day": "日光",
"Night": "夜光",
"Color": "彩光",
"Scene": "场景",
"Music": "音乐"
}
}
}
}
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,多谢修正。

我之前理解有误,以为这里只能填经由 miio_props 拿到的 light_mode 的值

]
}
]
},
{
"iid": 3,
"properties": [
Expand Down