Back to page

− Links

 Print 

ミンティア[MINTIA] で WiFi 6ボタンスイッチを作った :: XOOPS マニア

UsersWiki:nao-pon/blog/2021-06-15


RSS of nao-pon/blog[5]
Tue 15 Jun 2021
 

ミンティア[MINTIA] で WiFi 6ボタンスイッチを作った :-D anchor.png[6]

Tag: WiFi[7] ESP-32[8] DIY[9] HomeAssistant[10] Hass.io[11] ESPHome[12]

Google Home や Alexa と HomeAssistant を統合しているので、声で大体のことはできる・・・けど。
声を発声して、アシスタントに認識させるのが、面倒くさいと感じる。なんてわがままな! :lol:
だって、正しく認識してくれないと、もう一度言い直したり、見当違いのスイッチを ON/OFF されたり・・・

そこで、やっぱり物理ボタンですよ!

ちょうど手元にミンティアとESP-32が転がっていて・・・。ん?これ入るんじゃね?って思ったところ。

おぉー!やっぱりピッタリじゃないですか!厚みが若干きついけど。

で、結果こうなりました。やっぱりボタンで操作できるのは快適です。USB電源はいるけどね。

DSC_3857.JPG[13]DSC_3856.JPG[14]

ボタンの穴あけを少し失敗したけど、今度作るときはもう少しきちんと作ろう!

ボタンを押すと青いLEDが光ります。

Page Top

いるもの *1 anchor.png[15]

Page Top

ESPHome の設定 anchor.png[18]

esp32_ble_tracker は、手元に Qmote-S があったので、うまく使えないかな?と思って試してみたけど、検知範囲が狭くてほぼ使えなかった。残念。

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
substitutions:
  devicename: switch_box_11
 
esphome:
  name: $devicename
  platform: ESP32
  board: wemos_d1_mini32
  on_boot:
    - priority: 1000
      then:
        - while:
            condition:
              not:
                api.connected:
            then:
            - switch.turn_on: led
            - delay: 500ms 
            - switch.turn_off: led
            - delay: 500ms
 
wifi:
  networks: !include common/wifi.networks.yaml
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap: !include common/wifi.ap.yaml
 
  manual_ip:
    static_ip: 192.168.1.xx
    gateway: 192.168.1.1
    subnet: 255.255.255.0
 
captive_portal:
 
# Enable logging
logger:
 
# Enable Home Assistant API
api:
 
ota:
 
esp32_ble_tracker:
  id: ble_tracker
 
  on_ble_manufacturer_data_advertise:
    - mac_address: 88:4A:XX:XX:DE:52
      manufacturer_id: 004C
      then:
        - lambda: |-
            if (id(qmote_de52_click).state == false) {
              id(qmote_de52_click).publish_state(true);
              id(qmote_de52_click).publish_state(false);
            }
    - mac_address: 88:4A:XX:XX:99:BB
      manufacturer_id: 004C
      then:
        - lambda: |-
            if (id(qmote_99bb_click).state == false) {
              id(qmote_99bb_click).publish_state(true);
              id(qmote_99bb_click).publish_state(false);
            }
    - mac_address: 88:4A:XX:XX:9F:03
      manufacturer_id: 004C
      then:
        - lambda: |-
            if (id(qmote_9f03_click).state == false) {
              id(qmote_9f03_click).publish_state(true);
              id(qmote_9f03_click).publish_state(false);
            }
  
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO23
      inverted: True
      mode: INPUT_PULLUP
    name: "$devicename btn1"
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
  - platform: gpio
    pin:
      number: GPIO19
      inverted: True
      mode: INPUT_PULLUP
    name: "$devicename btn2"
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
  - platform: gpio
    pin:
      number: GPIO18
      inverted: True
      mode: INPUT_PULLUP
    name: "$devicename btn3"
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
  - platform: gpio
    pin:
      number: GPIO33
      inverted: True
      mode: INPUT_PULLUP
    name: "$devicename btn4"
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
  - platform: gpio
    pin:
      number: GPIO05
      inverted: True
      mode: INPUT_PULLUP
    name: "$devicename btn5"
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
  - platform: gpio
    pin:
      number: GPIO26
      inverted: True
      mode: INPUT_PULLUP
    name: "$devicename btn6"
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
  - platform: template
    id: qmote_de52_click
    name: "$devicename Qmote de52 Click"
    filters:
      delayed_off: 800ms
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
  - platform: template
    id: qmote_99bb_click
    name: "$devicename Qmote 99bb Click"
    filters:
      delayed_off: 800ms
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
  - platform: template
    id: qmote_9f03_click
    name: "$devicename Qmote 9f03 Click"
    filters:
      delayed_off: 800ms
    on_press:
      then:
        - switch.turn_on: led
    on_release:
      then:
        - switch.turn_off: led
 
sensor:
  - platform: wifi_signal
    name: "$devicename WiFi"
    update_interval: 60s
    unit_of_measurement: "%"
    filters:
      - lambda: x = 2 * (x + 100); if (x < 0) {x = 0;} else if (x > 100) {x = 100;} return x;
 
switch:
  - platform: restart
    name: "$devicename Restart"
  - platform: gpio
    pin:
      number: GPIO2
    name: "$devicename LED"
    id: led


*1 価格は購入時のもの
*2 Aliexpress で買ったけど、技適マークはついていました。

Last-modified: 2021-06-15 (Tue) 11:06:01 (JST) (1208d) by nao-pon