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
4 changes: 3 additions & 1 deletion components/miot_ylkg0xyl/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Yeelight Smart Bluetooth Wireless Dimmer Wall Light Switch Remote Control (YLKG08YL/YLKG07YL)
# Yeelight Smart Bluetooth Wireless Dimmer Wall Light Switch Remote Control (YLKG08YL/YLKG07YL/MJGDYK01YL)

Sample configuration:

Expand All @@ -12,6 +12,8 @@ sensor:
mac_address: !secret device_mac_address
# String, (Optional), device bind key. Will use "xiaomi_account" from "miot" if absent to automatically get the bindkey.
bindkey: !secret device_bind_key
# Number (Optional), device product ID. Use 0x15CE for MJGDYK01YL, leave unset for YLKG07YL/YLKG08YL
# product_id: 0x15CE
# List, Automation (Optional), The automation activated when you make specified action
on_short_press:
# List, Any automation
Expand Down
1 change: 1 addition & 0 deletions components/miot_ylkg0xyl/automation.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum MiotYLKG0XYLEvent {
class MiotYLKG0XYLTrigger : public Trigger<uint8_t>, public miot::MiotListener {
public:
explicit MiotYLKG0XYLTrigger(MiotYLKG0XYLEvent event) : event_(event) { this->product_id_ = PRODUCT_ID_YLKG0xYL; }
MiotYLKG0XYLTrigger(MiotYLKG0XYLEvent event, uint16_t product_id) : event_(event) { this->product_id_ = product_id; }

protected:
MiotYLKG0XYLEvent event_;
Expand Down
14 changes: 13 additions & 1 deletion components/miot_ylkg0xyl/miot_ylkg0xyl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ namespace miot_ylkg0xyl {

static const char *const TAG = "miot_ylkg0xyl";

void MiotYLKG0XYL::dump_config() { this->dump_config_(TAG, "YLKG07YL/YLKG08YL"); }
void MiotYLKG0XYL::dump_config() {
const char* device_name;
switch (this->product_id_) {
case PRODUCT_ID_MJGDYK01YL:
device_name = "MJGDYK01YL";
break;
case PRODUCT_ID_YLKG0xYL:
default:
device_name = "YLKG07YL/YLKG08YL";
break;
}
this->dump_config_(TAG, device_name);
}

bool MiotYLKG0XYL::process_object_(const miot::BLEObject &obj) {
switch (obj.id) {
Expand Down
2 changes: 2 additions & 0 deletions components/miot_ylkg0xyl/miot_ylkg0xyl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ namespace esphome {
namespace miot_ylkg0xyl {

#define PRODUCT_ID_YLKG0xYL 0x03B6
#define PRODUCT_ID_MJGDYK01YL 0x15CE

class MiotYLKG0XYL : public miot::MiotComponent {
public:
MiotYLKG0XYL() { this->product_id_ = PRODUCT_ID_YLKG0xYL; }
MiotYLKG0XYL(uint16_t product_id) { this->product_id_ = product_id; }

void dump_config() override;

Expand Down
7 changes: 6 additions & 1 deletion components/miot_ylkg0xyl/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
CONFIG_SCHEMA = cv.Schema(
{
# cv.GenerateID(): cv.declare_id(MiotYLKG0XYL),
cv.Optional(miot.CONF_PRODUCT_ID): cv.uint16_t,
cv.Optional(CONF_ON_SHORT_PRESS): automation.validate_automation(
cv.Schema(
{cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(MiotYLKG0XYLTrigger)}
Expand Down Expand Up @@ -59,8 +60,12 @@


async def configure_event_trigger_(config, param, enum):
product_id = config.get(miot.CONF_PRODUCT_ID)
for conf in config.get(param, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], enum)
if product_id is not None:
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], enum, product_id)
else:
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], enum)
await miot.register_miot_device(trigger, config)
await miot.setup_device_core_(trigger, config)
await automation.build_automation(trigger, [(cg.uint8, "x")], conf)
Expand Down
3 changes: 2 additions & 1 deletion components/miot_ylxx0xyl_pair/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Supported models are:

- Remote (YLYK01YL)
- Dimmer (YLKG07YL/YLKG08YL)
- Monitor Light Bar Remote (MJGDYK01YL)
- Bathroom Heater Remote (YLYB01YL-BHFRC)
- Fan Remote (YLYK01YL-VENFAN)
- Ventilator Fan Remote (YLYK01YL-FANCL)
Expand All @@ -27,7 +28,7 @@ text_sensor:
# Sesnor (Optional), sensor do display version.
version:
name: miot_ylxx0xyl_pair Version
# uint16 (Optional), product id to pair. defaults to 0, means auto for one of 0x0153, 0x03B6, 0x03BF, 0x04E6, 0x068E
# uint16 (Optional), product id to pair. defaults to 0, means auto for one of 0x0153, 0x03B6, 0x15CE, 0x03BF, 0x04E6, 0x068E
# can be used to obtain beakonkey from unsupported devices.
#product_id: 0
```
1 change: 1 addition & 0 deletions components/miot_ylxx0xyl_pair/miot_ylxx0xyl_pair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static bool is_ylxx0xyl(uint16_t product_id) {
case 0x03BF: // YLYB01YL-BHFRC Bathroom Heater Remote
case 0x04E6: // YLYK01YL-VENFAN Fan Remote
case 0x068E: // YLYK01YL-FANCL Ventilator Fan Remote
case 0x15CE: // MJGDYK01YL Monitor Light Bar 1S Remote
return true;
}
return false;
Expand Down