找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 15895|回复: 145

[其他设备] TC1 刷机, homeassistant可控制

 火.. [复制链接]
发表于 2019-9-24 12:18 | 显示全部楼层 |阅读模式
本帖最后由 guy.feng 于 2019-11-8 20:39 编辑

参考几位大神的文章,自己买了个TC1刷机成功,没去要激活码,不能APP控制,但是MQTT支持后,homeassistant可控制开关!
代码在git,你懂的!

# TC1

## 参考
感谢大神们的辛苦劳作
- [a2633063](https://github.com/a2633063/zTC1)
- [ljr.im](https://ljr.im/articles/streamline-the-fibonacci-tc1-firmware/)

## 主要变化
- 去掉定时功能
- Easylink配网

## 开发环境

-  [Python, Git, MiCoder Tool](http://developer.mxchip.com/handbooks/102#%E5%AE%89%E8%A3%85)

-  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
## [烧录固件](https://github.com/a2633063/zTC1 ... 6%E7%83%A7%E5%BD%95)
GND/3v3/clk/dio <----> Jlink's GND/3v3/clk/dio  
手持也可以。只是有点累!

## 使用
#### 插座wifi设置
- 下载[easylink](http://developer.mxchip.com/downloads/8)  
- easylink App 启动发送
- 按住TC1按钮,插上电源,进入配网模式,松开按钮
- 灯短闪几下后,长亮,配网成功

#### 配置MQTT到插座
使用[UDP工具](http://developer.mxchip.com/hand ... 5%E5%B7%A5%E5%85%B7)与插座通信  

- 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连接信息 \*\*  

#### HomeAssistant配置
- 安装[Configurator](https://www.home-assistant.io/do ... -for-home-assistant)  
- 修改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
```

#### OTA
搭建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"}}
```







评分

参与人数 1恩山币 +1 收起 理由
irockyi + 1 感谢楼主,小白没看明白,需要自己编译架服务器?

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
发表于 2019-9-24 12:42 | 显示全部楼层
不错,感谢分享。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 12:50 | 显示全部楼层
如果您要查看本帖隐藏内容请回复
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 13:11 | 显示全部楼层
不错,感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 13:15 | 显示全部楼层
好用,感谢分享。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 13:24 | 显示全部楼层
感谢分享

点评

学习一下,可以试试  详情 回复 发表于 2019-10-10 08:48
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 13:46 | 显示全部楼层
学习一下,可以试试
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 13:48 | 显示全部楼层
如果您要查看本帖隐藏内容请回复
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 13:49 | 显示全部楼层
tc1什么情况啊
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 14:10 | 显示全部楼层
学习了
谢谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2019-9-24 14:38 | 显示全部楼层
在windows (我win10)编译固件成功,刷固件也在windows上。 控制开关   1:可以通过UDP发送特定消息,2: homeassistant, 3: 其他大神的app

点评

D:\Workspace\MiCoder_v1.1.Win32\MiCoder\TC1>mico make TC1@MK3031@moc Making config file for first time processing components: TC1 MK3031 mocOS mocIP mocSSL MiCO Unknown component: TC1 - directory o  详情 回复 发表于 2019-11-4 10:30
a2633063大神的app挺好用的,可惜就是没有ios端的。  详情 回复 发表于 2019-9-24 15:06
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 15:02 | 显示全部楼层
看下大神操作
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 15:06 | 显示全部楼层
guy.feng 发表于 2019-9-24 14:38
在windows (我win10)编译固件成功,刷固件也在windows上。 控制开关   1:可以通过UDP发送特定消息,2: home ...

a2633063大神的app挺好用的,可惜就是没有ios端的。

点评

没办法 想要开发就先给苹果交100美金..... 这是我一直用安卓不用苹果的原因....  详情 回复 发表于 2019-9-26 12:23
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 15:10 | 显示全部楼层
感谢分享,学习一下!
来自微站
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-24 22:00 | 显示全部楼层
来学习一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-20 05:03

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表