ioBroker.esphome
ioBroker.esphome copied to clipboard
Template Button
Hi,
um zu ermöglichen, dass man ein ESPHome Script auf einem ESP antriggern kann (der vermutlich häufigste Anwendungsfall?) würde sich die Integration eines Template Buttons anbieten.
Mein Beispielscript:
esphome:
name: little_wemos
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Little Wemos Fallback Hotspot"
password: "************"
captive_portal:
# Enable logging
logger:
api:
services:
- service: control_servo
variables:
level: float
then:
- servo.write:
id: my_servo
level: !lambda 'return level / 100.0;'
ota:
output:
- platform: esp8266_pwm
id: pwm_output
pin: D3
frequency: 50 Hz
servo:
- id: my_servo
output: pwm_output
button:
- platform: template
name: "Template Button"
on_press:
- logger.log: Button Pressed
- cover.open: flying
- delay: 8s
- cover.close: flying
- delay: 9s
cover:
- platform: time_based
id: flying
open_action:
# then:
- servo.write:
id: my_servo
level: 10.0%
open_duration: 5s
close_action:
# then:
- servo.write:
id: my_servo
level: -10.0%
close_duration: 6s
stop_action:
# then:
- servo.write:
id: my_servo
level: 0%
- servo.detach: my_servo
Mein Log bei Erkennen des ESP:
esphome.0
2022-03-22 20:14:42.592 debug 192.168.178.53 client data 4 little_wemos (esphome v2022.3.0)"little_wemos
esphome.0
2022-03-22 20:14:42.575 error ESPHome client 192.168.178.53 TypeError: Cannot read property 'deserializeBinary' of undefined
esphome.0
2022-03-22 20:14:42.574 debug 192.168.178.53 client data
esphome.0
2022-03-22 20:14:13.912 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:13,912 INFO 304 GET /devices (192.168.178.146) 1.62ms
esphome.0
2022-03-22 20:14:12.535 warn Client 192.168.178.53 Timeout, connection Lost, will reconnect automatically when device is available!
esphome.0
2022-03-22 20:14:09.061 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:09,061 INFO Running command 'esphome --dashboard -q vscode --ace /opt/iobroker/iobroker-data/esphome.0'
esphome.0
2022-03-22 20:14:08.989 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,989 INFO 101 GET /ace (192.168.178.146) 1.17ms
esphome.0
2022-03-22 20:14:08.971 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,970 INFO 200 GET /static/fonts/material-icons/MaterialIcons-Regular.woff2 (192.168.178.146) 1.87ms
esphome.0
2022-03-22 20:14:08.913 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,913 INFO 304 GET /devices (192.168.178.146) 1.58ms
esphome.0
2022-03-22 20:14:08.877 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,876 INFO 200 GET /static/js/vendor/ace/mode-yaml.js (192.168.178.146) 2.07ms
esphome.0
2022-03-22 20:14:08.874 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,873 INFO 200 GET /static/js/vendor/ace/theme-dreamweaver.js (192.168.178.146) 1.69ms
esphome.0
2022-03-22 20:14:08.696 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,696 INFO 200 GET /static/js/vendor/jquery-ui/jquery-ui.min.js?hash=cab3392d (192.168.178.146) 189.47ms
esphome.0
2022-03-22 20:14:08.666 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,666 INFO 200 GET /static/js/vendor/materialize/materialize.min.js?hash=4be20daf (192.168.178.146) 158.14ms
esphome.0
2022-03-22 20:14:08.636 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,635 INFO 200 GET /static/js/esphome/index-92d154f2.js (192.168.178.146) 114.09ms
esphome.0
2022-03-22 20:14:08.633 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,633 INFO 200 GET /static/js/vendor/ace/ace.js?hash=65322f49 (192.168.178.146) 124.26ms
esphome.0
2022-03-22 20:14:08.516 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,515 INFO 200 GET /static/js/vendor/jquery-validate/jquery.validate.min.js?hash=aad785d4 (192.168.178.146) 8.16ms
esphome.0
2022-03-22 20:14:08.511 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,511 INFO 200 GET /static/js/vendor/jquery/jquery.min.js?hash=12108007 (192.168.178.146) 5.14ms
esphome.0
2022-03-22 20:14:08.462 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,461 INFO 200 GET /static/css/esphome-2.css?hash=b79b4733 (192.168.178.146) 7.20ms
esphome.0
2022-03-22 20:14:08.459 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,459 INFO 200 GET /static/css/vendor/materialize/materialize.min.css?hash=ec1df3ba (192.168.178.146) 5.40ms
esphome.0
2022-03-22 20:14:08.452 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,450 INFO 200 GET /static/fonts/material-icons/material-icons.css?hash=ead4c276 (192.168.178.146) 3.75ms
esphome.0
2022-03-22 20:14:08.449 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,449 INFO 200 GET /static/fonts/material-icons/MaterialIcons-Regular.woff2?hash=570eb838 (192.168.178.146) 2.71ms
esphome.0
2022-03-22 20:14:08.412 debug esphome.0 (13292) [ESPHome - Console] 2022-03-22 20:14:08,411 INFO 304 GET /?instance=0&newReact=true&0&react=colored (192.168.178.146) 2.16ms
esphome.0
2022-03-22 20:14:07.562 error ESPHome client 192.168.178.53 TypeError: Cannot read property 'deserializeBinary' of undefined
esphome.0
2022-03-22 20:14:07.561 debug 192.168.178.53 client data 4 little_wemos (esphome v2022.3.0)"little_wemos
esphome.0
2022-03-22 20:14:07.543 error ESPHome client 192.168.178.53 TypeError: Cannot read property 'deserializeBinary' of undefined
esphome.0
2022-03-22 20:14:07.542 debug 192.168.178.53 client data
esphome.0
2022-03-22 20:13:37.521 warn Client 192.168.178.53 Timeout, connection Lost, will reconnect automatically when device is available!
Solved it via a switch:
Solved it via a switch:
Can you tell me exactly how you made this switch? just created an object? I have a similar problem, described here #124
Now I was able to install this component through the ESPHome feb page (having previously compiled and downloaded the firmware, since iobroker is not installed through the dashboard). But the problem is that I see only basic information objects, and the firmware has more controls, see screenshots.
and here are the "managed" elements:
Can you tell me exactly how you made this switch? just created an object?
just defining a switch output should o the trick
switch:
- platform: gpio
pin: 26
name: "xxx"
I'm afraid it won't work in my case. Because I have code running on button click and I can't bind it to gpio. Maybe you can make a "switch" that will execute the code from my config?
just put ig o a fake gpis or pin ?
switch:
- platform: gpio
pin: 26
name: "Template Button"
on_press:
- logger.log: Button Pressed
- cover.open: flying
- delay: 8s
- cover.close: flying
- delay: 9s
I use lambda
button:
- platform: template
name: Пошагово
id: sbs
on_press:
lambda: |-
my_nice_cover -> NiceBusT4::send_cmd(bus_t4::SBS);
- platform: template
name: Частичное открытие 1
id: p_opn1
on_press:
lambda: |-
my_nice_cover -> NiceBusT4::send_cmd(bus_t4::P_OPN1);
cover:
- platform: bus_t4
name: "Nice RB500HS"
id: my_nice_cover
When I try to change to switch, the firmware does not compile, an error is thrown:
INFO Reading configuration /opt/iobroker/iobroker-data/esphome.0/esphome-web-17447f.yaml...
ERROR Error while reading config: Invalid YAML syntax:
Duplicate key "switch"
in "/opt/iobroker/iobroker-data/esphome.0/esphome-web-17447f.yaml", line 143, column 1:
switch:
^
NOTE: Previous declaration here:
in "/opt/iobroker/iobroker-data/esphome.0/esphome-web-17447f.yaml", line 101, column 1:
switch:
^
whole config:
substitutions:
device_name: "nice-bust4-uart"
esphome:
name: ${device_name}
platform: ESP8266
board: d1_mini
external_components:
- source:
type: git
url: https://github.com/pruwait/Nice_BusT4
debug:
logger:
level: DEBUG
baud_rate: 0
# Enable Home Assistant API
api:
reboot_timeout: 0s # иначе перезагружается при отключении от hassio
services:
- service: raw_command
variables:
raw_cmd: string
then:
lambda: |-
my_nice_cover -> NiceBusT4::send_raw_cmd(raw_cmd);
- service: send_inf_command
variables:
to_addr: string
whose: string
command: string
type_command: string
next_data: string
data_on: bool
data_command: string
then:
lambda: |-
my_nice_cover -> NiceBusT4::send_inf_cmd(to_addr, whose, command, type_command, next_data, data_on, data_command);
# std::vector < uint8_t > v_to_addr = my_nice_cover -> NiceBusT4::raw_cmd_prepare (to_addr);
# std::vector < uint8_t > v_whose = my_nice_cover -> NiceBusT4::raw_cmd_prepare (whose);
# std::vector < uint8_t > v_command = my_nice_cover -> NiceBusT4::raw_cmd_prepare (command);
# std::vector < uint8_t > v_type_command = my_nice_cover -> NiceBusT4::raw_cmd_prepare (type_command);
# std::vector < uint8_t > v_data_command = my_nice_cover -> NiceBusT4::raw_cmd_prepare (data_command);
# if (data_on) {
# my_nice_cover -> NiceBusT4::tx_buffer_.push(my_nice_cover -> NiceBusT4::gen_inf_cmd(v_to_addr[0], v_to_addr[1], v_whose[0], v_command[0], v_type_command[0], v_data_command, v_data_command.size()));
# } else {
# my_nice_cover -> NiceBusT4::tx_buffer_.push(my_nice_cover -> NiceBusT4::gen_inf_cmd(v_to_addr[0], v_to_addr[1], v_whose[0], v_command[0], v_type_command[0]));
# }
ota:
# Set statul led for Wemos D1 mini
status_led:
pin:
number: D4
inverted: true
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${device_name} Hotspot"
password: !secret ota_pass
captive_portal:
# Enable web server (can be disabled)
web_server:
port: 80
# Кнопки для отправки команд
cover:
- platform: template
name: Пошагово
id: sbs
on_press:
lambda: |-
my_nice_cover -> NiceBusT4::send_cmd(bus_t4::SBS);
# my_nice_cover -> NiceBusT4::send_raw_cmd("55 0c 00 ff 00 66 01 05 9D 01 82 01 64 E6 0c");
- platform: template
name: Частичное открытие 1
id: p_opn1
on_press:
lambda: |-
my_nice_cover -> NiceBusT4::send_cmd(bus_t4::P_OPN1);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::STOP);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::OPEN);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::CLOSE);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::P_OPN2);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::P_OPN3);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::P_OPN4);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::P_OPN5);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::P_OPN6);
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::UNLK_OPN); # Разблокировать и открыть
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::CLS_LOCK); # Закрыть и блокировать
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::UNLCK_CLS); # Разблокировать и Закрыть
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::LOCK); # Блокировать
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::UNLOCK); # Разблокировать
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::HOST_SBS); # Ведущий SBS
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::HOST_OPN); # Ведущий открыть
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::HOST_CLS); # Ведущий закрыть
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::SLAVE_SBS); # Ведомый SBS
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::SLAVE_OPN); # Ведомый открыть
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::SLAVE_CLS); # Ведомый закрыть
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::AUTO_ON); # Автооткрывание активно
# my_nice_cover -> NiceBusT4::send_cmd(bus_t4::AUTO_OFF); # Автооткрывание неактивно
cover:
- platform: bus_t4
name: "Nice RB500HS"
id: my_nice_cover
# address: 0x0003 # адрес привода
# use_address: 0x0081 # адрес шлюза
Duplicate key "switch"
somewhere you have a duplicate entry for switch