hi all
i have linked my doorbell to a esp-01s and relay so i can use it in home assistant, everything about the switch works fine.
what i’m trying to do is create a button that will act like the real thing… ie when i press it, it will ‘ding’ when i release it, it will ‘dong’
here is what i have on the esp-01s
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
# Sensors with general information.
sensor:
# Uptime sensor.
- platform: uptime
name: "Doorbell Uptime"
id: doorbell_uptime
update_interval: 15s
# WiFi Signal sensor.
- platform: wifi_signal
name: Doorbell WiFi Signal
update_interval: 60s
# Text sensors with general information.
text_sensor:
# Expose ESPHome version as sensor.
- platform: version
name: Doorbell ESPHome Version
# Expose WiFi information as sensors.
- platform: wifi_info
ip_address:
name: Doorbell IP
ssid:
name: Doorbell SSID
bssid:
name: Doorbell BSSID
- platform: template
name: "Doorbell Uptime (formatted)"
lambda: |-
uint32_t dur = id(doorbell_uptime).state;
int dys = 0;
int hrs = 0;
int mnts = 0;
if (dur > 86399) {
dys = trunc(dur / 86400);
dur = dur - (dys * 86400);
}
if (dur > 3599) {
hrs = trunc(dur / 3600);
dur = dur - (hrs * 3600);
}
if (dur > 59) {
mnts = trunc(dur / 60);
dur = dur - (mnts * 60);
}
char buffer[17];
sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
return {buffer};
icon: mdi:clock-start
update_interval: 15s
# Global to store the on/off state of the chime
globals:
- id: chime
type: bool
restore_value: true
initial_value: 'true'
# Exposed switches.
switch:
# Switch to restart the doorbell.
- platform: restart
name: Doorbell Restart
# Switch to turn on/off the chime.
- platform: gpio
id: relay
inverted: true
name: Doorbell Chime
pin: GPIO0
# Switch to turn on/off chime when
# doorbell button is pushed.
#
# It creates a "virtual" switch based
# on a global variable.
- platform: template
name: Doorbell Chime Active
id: chime_active
restore_state: false
turn_on_action:
- globals.set:
id: chime
value: 'true'
turn_off_action:
- globals.set:
id: chime
value: 'false'
lambda: |-
return id(chime);
# Binary sensor representing the
# Doorbell button push.
binary_sensor:
- platform: gpio
id: button
name: Doorbell Button
pin:
# Connected to GPIO on the ESP-01S.
number: GPIO2
mode: INPUT_PULLUP
inverted: true
filters:
# Small filter, to debounce the button press.
- delayed_on: 25ms
- delayed_off: 25ms
on_press:
# Only turn on the chime when it is active.
then:
if:
condition:
- switch.is_on: chime_active
then:
- switch.turn_on: relay
- delay: 100ms
- switch.turn_off: relay
on_release:
# On release, turn of the chime.
- switch.turn_on: relay
- delay: 100ms
- switch.turn_off: relay
this is what i have tried in lovelace
type: entity-button
tap_action:
- action: toggle
- delay: 100ms
- action: toggle
hold_action:
action: more-info
show_icon: true
show_name: true
entity: switch.doorbell_chime
with the following errors
“Expected a value of type {action,navigation_path,service,service_data} | undefined
for tap_action
but received [{"action":"toggle"},{"delay":"100ms"},{"action":"toggle"}]
.”
so i tried the following
type: entity-button
tap_action:
action:
- switch.turn_on: switch.doorbell_chime
- delay: 100ms
- switch.turn_off: switch.doorbell_chime
hold_action:
action: more-info
show_icon: true
show_name: true
entity: switch.doorbell_chime
but again received the following…
" Expected a value of type {action,navigation_path,service,service_data} | undefined
for tap_action.action
but received [{"switch.turn_on":"switch.doorbell_chime"},{"delay":"100ms"},{"switch.turn_off":"switch.doorbell_chime"}]
. "
can anybody offer some help?
thank you in advance