感谢大神们的辛苦劳作
- 去掉定时功能
- Easylink配网
-
MiCO Cube
pip install mico-cube
mico config --global MICODER D:\Workspace\MiCoder_v1.1.Win32\MiCoder
git clone https://github.com/qianjinfeng/TC1.git
cd TC1
git checkout dev1.0
mico deploy
mico make TC1@MK3031@moc
GND/3v3/clk/dio <----> Jlink's GND/3v3/clk/dio
手持也可以。只是有点累!
- 下载easylink
- easylink App 启动发送
- 按住TC1按钮,插上电源,进入配网模式,松开按钮
- 灯短闪几下后,长亮,配网成功
使用UDP工具与插座通信
-
udp receive 插座ip 10181
监听插座的消息,配网成功有消息发出来 -
udp send 插座ip 10182
发送下面消息,配置mqtt broker, etc.
{"mac":"macaddress","setting":{"mqtt_uri":"mqtt broker","mqtt_port":1883,"mqtt_user":"username","mqtt_password":"password"}}
** 长按10s, 可清空mqtt, wifi连接信息 **
- 安装Configurator
- 修改configuration.yaml,增加如下信息,自动发现插座实体
mqtt:
#MQTT Broker的IP地址或者域名
broker: xx
#MQTT Broker的端口号,缺省为1883
port: xx
#用户名
username: xx
#密码
password: xx
#自动发现
discovery: true
#自动发现topic前缀,与固件user_mqtt_client的一致
discovery_prefix: homeassistant
- 手动修改configuration.yaml配置插座实体 (不推荐,好处name不是自动生成)
sensor:
- platform: mqtt
name: "tc1_1_power"
state_topic: "homeassistant/sensor/macxxxx/power/state"
icon: 'mdi:gauge'
unit_of_measurement: 'W'
value_template: '{{ value_json.power }}'
switch:
- platform: mqtt
name: 'tc1_1_plug_0'
state_topic: "homeassistant/switch/macxxxx/plug_0/state"
command_topic: "cmnd/tc1_macxxxx"
payload_on: "{\"mac\":\"macxxxx\",\"plug_0\":1}"
payload_off: "{\"mac\":\"macxxxx\",\"plug_0\":0}"
qos: 0
retain: true
搭建http-server
npm install http-server -g
cd .\build\TC1@MK3031@moc\binary
copy TC1@MK3031@moc.ota.bin ota.bin
htt-server
udp send 插座ip 10182
{"mac":"macaddress","setting":{"ota":"http://httpserveripaddress:8080/ota.bin"}}