Olá pessoal
Tenho um dispositivo com Nodemcu ESP32, nele adicionei um sensor dallas (temperatura), um botão de pressão e um display Oled.
Até o momento o que consegui fazer foi deixar o display funcionando direto e mostrando três páginas de informação, conforme pode ser visto no código abaixo.
Também consegui criar quatro cenas de acordo com a quantidade/tempo do clicks no botão.
Preciso de ajuda para fazer o display mostrar informações na tela apenas quando o botão for pressionado com um click rápido, voltando a desligar o display depois de 10s.
captive_portal:
font:
- file: "arial.ttf"
id: font1
size: 15
- file: "ariblk.ttf"
id: font2
size: 20
- file: "ariblk.ttf"
id: font3
size: 15
i2c:
sda: GPIO21
scl: GPIO22
scan: True
text_sensor:
- platform: template
name: "TCP/IP Address"
lambda: 'return {WiFi.localIP().toString().c_str()};'
id: tcp_ip_address
- platform: template
name: Scene Button
id: scene_button
lambda: |-
return {"Botao de Cena"};
dallas:
pin: 15
sensor:
- platform: dallas
name: "Dallas Temperature Sensor"
address: 0x1c0000031edd2a28
id: T
binary_sensor:
- platform: gpio
pin:
number: 16
mode:
input: true
inverted: true
name: "Scene Button 1"
internal: true
filters:
- delayed_on_off: 50ms
on_multi_click:
- timing:
- ON for at least 1s
- OFF for at least 1s
then:
- text_sensor.template.publish:
id: scene_button
state: "Hold"
- delay: 2s
- text_sensor.template.publish:
id: scene_button
state: "Comando enviado"
- timing:
- ON for at most 0.5s
- OFF for at least 1s
then:
- text_sensor.template.publish:
id: scene_button
state: "Click"
- delay: 2s
- text_sensor.template.publish:
id: scene_button
state: "Comando enviado"
- timing:
- ON for at most 0.5s
- OFF for at most 0.5s
- ON for at most 0.5s
- OFF for at least 1s
then:
- text_sensor.template.publish:
id: scene_button
state: "Click Duplo"
- delay: 2s
- text_sensor.template.publish:
id: scene_button
state: "Comando enviado"
- timing:
- ON for at most 0.5s
- OFF for at most 0.5s
- ON for at most 0.5s
- OFF for at most 0.5s
- ON for at most 0.5s
- OFF for at least 1s
then:
- text_sensor.template.publish:
id: scene_button
state: "Click Triplo"
- delay: 2s
- text_sensor.template.publish:
id: scene_button
state: "Comando enviado"
display:
- platform: ssd1306_i2c
model: "SSD1306 128x32"
id: my_display
address: 0x3C
brightness: 100%
contrast: 50%
pages:
- id: page1
lambda: |-
it.print(0, 0, id(font2), "IoT no Agro");
- id: page2
lambda: |-
it.printf(0, 0, id(font1), "T: %.1f°C", id(T).state);
- id: page3
lambda: |-
it.printf(10, 0, id(font3), "%s", id(tcp_ip_address).state.c_str());
interval:
- interval: 3s
then:
- display.page.show_next: my_display
- component.update: my_display