本帖最后由 szlww 于 2023-11-26 21:07 编辑
咸鱼买了十几个联想智能插座,esp8266ex芯片,10元/个。
这款插座比较小巧,插在插排上不会和其他插头打架,目前为止少见的小体积并且可以无损拆解的国标五孔插座,已经将家里的大块头智能插座全部替换成这一款了。
超声波焊接工艺,可以无损开盖,免焊接刷机。无损拆机详见前面的帖子:https://bbs.hassbian.com/thread-23429-1-1.html。
免焊接刷机,使用废旧网口里面的四根弹片,GPIO0直接和esp芯片的外壳连接即可,另外需要将第四个弹片弯折90度,探入rx脚的背面与tx脚接触,手扶刷机。
刷机完成之后,塑料盖板的边缘涂上有机硅胶水或者免钉胶,把外壳重新黏合在一起,固化24小时后即可正常插拔使用,效果十分完美。
esphome yaml配置文件如下:
common/common.yaml
esphome:
name: ${node_name}
esp8266:
board: esp01_1m
restore_from_flash: false
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
reboot_timeout: 30min
ap:
ssid: "${node_id} hotspot"
password: !secret ap_password
logger:
level: INFO
api:
password: !secret api_password
reboot_timeout: 1h
ota:
password: !secret ota_password
web_server:
port: 80
include_internal: true
version: 1
text_sensor:
- platform: version
name: '${node_name_friendly}-Version'
id: ${node_id}_platform_version
- platform: wifi_info
ip_address:
name: "${node_name_friendly}-IP"
id: ${node_id}_ip
bssid:
name: "${node_name_friendly}-BSSID"
id: ${node_id}_bssid
mac_address:
name: "${node_name_friendly}-MAC"
id: ${node_id}_mac
- platform: template
name: '${node_name_friendly}-Uptime'
id: ${node_id}_uptime_human
sensor:
- platform: uptime
id: ${node_id}_raw_up_time
update_interval: 15min
internal: true
on_raw_value:
then:
- text_sensor.template.publish:
id: ${node_id}_uptime_human
state: !lambda |-
int seconds = round(id(${node_id}_raw_up_time).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
- platform: wifi_signal
name: "${node_name_friendly}-WifiSignal"
id: ${node_id}_wifi_signal
update_interval: 15min
binary_sensor:
- platform: status
name: "${node_name_friendly}-LinkStatus"
id: ${node_id}_link_status
switch:
- platform: restart
name: "${node_name_friendly}-Restart"
id: ${node_id}_restart
plug-lenovo.yaml
substitutions:
button_pin: GPIO13
relay_pin: GPIO15
led_state_pin: GPIO2
led_relay_pin: GPIO0
node_name: plug-lenovo
node_id: plug_lenovo
node_name_friendly: ${node_name}
packages:
common: !include common/common.yaml
esphome:
name_add_mac_suffix: true
binary_sensor:
- platform: gpio
name: "${node_name}-button"
id: "${node_id}_button"
pin:
number: $button_pin
inverted: true
mode:
input: true
pullup: true
on_press:
then:
- logger.log: "TOGGLE switch..."
- switch.toggle: ${node_id}_switch
light:
- platform: monochromatic
name: ${node_name}-relay-led
id: ${node_id}_relay_led
output: ${node_id}_relay_led_pinout
default_transition_length: 200ms
- platform: status_led
name: ${node_name}-LinkLed
id: ${node_id}_link_led
pin:
number: $led_state_pin
inverted: true
output:
- platform: esp8266_pwm
pin:
number: $led_relay_pin
inverted: true
id: ${node_id}_relay_led_pinout
switch:
- platform: safe_mode
name: ${node_name}-safemode
id: "${node_id}_safemode"
- platform: gpio
pin: $relay_pin
name: "${node_name}-switch"
id: "${node_id}_switch"
on_turn_on:
then:
- light.turn_on: ${node_id}_relay_led
on_turn_off:
then:
- light.turn_off: ${node_id}_relay_led
|