What’s wrong with my Espome yaml code that broken 03 of my Sonoff mini already flashed with esphome, i was only updating my code
when the upload finishes the three (03) Sonoff Mini r2 stopped and gives a positif ping sometimes but everything doesnt work including the phisical s1,s2 button and it doesn’t apear with its address 192.168.8.100
i have tried reflashing them using UART but they didn’t connect to the esphomeflasher tool under linux
i think because i was using the Rx pin as an ordinary pin like the following lines
logger:
level: DEBUG
baud_rate: 0
SOLVED (when flashing new nodes) without the next code lines, but 03 Sonoff mini r2 still dammaged
js_include: "./v2/www.js"
css_include: "./v2/www.css"
version: 2
my full code is the following:
substitutions:
device_name: "hooming-kpa-01"
esphome:
friendly_name: kpa-01
name: ${device_name}
# Automatically add the mac address to the name
# so you can use a single firmware for all devices
name_add_mac_suffix: true
esp8266:
board: esp8285
# Enable Home Assistant API
api:
encryption:
key: "fsvB60LOnM7UpzgMqkXNgPnrie+TecOFHVZYse9QZ/s="
ota:
password: "2acf3099eaeed28119af118576835839"
captive_portal:
wifi:
# esphome Fast connect can only be used with one network!.
# fast_connect: true
# reboot_timeout: 60s
use_address: 192.168.8.65
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
gateway: 192.168.8.1
subnet: 255.255.255.0
static_ip: 192.168.8.100
- ssid: BROADBAND
password: !secret wifi_password
manual_ip:
gateway: 192.168.1.1
subnet: 255.255.255.0
static_ip: 192.168.1.100
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${device_name}"
password: "IvIwT3MH2axb"
# Disable Logger (TO USE RX as A regular Pin)
logger:
level: DEBUG
baud_rate: 0
# Enable Web server
web_server:
port: 80
js_include: "./v2/www.js"
css_include: "./v2/www.css"
version: 2
# Global to store the on/off state of the chime
globals:
- id: turned_on_manually
type: bool
restore_value: true
initial_value: 'false'
- id: turned_off_manually
type: bool
restore_value: true
initial_value: 'false'
- id: till_turn_off_manually
type: bool
restore_value: true
initial_value: 'false'
sensor:
# Extra sensor to keep track of plug uptime
- platform: uptime
name: ${device_name} وقت التشغيل
filters:
- lambda: return x / 3600;
unit_of_measurement: "hours"
accuracy_decimals: 2
# Extra sensor for WiFi signal
- platform: wifi_signal
name: ${device_name} جودة شبكة الواي فاي
update_interval: 60s
status_led:
pin:
number: GPIO13
inverted: true
output:
- platform: gpio
id: relay_1
pin: GPIO12
light:
- platform: binary
id: kpa_light
name: kpa light
output: relay_1
on_turn_off:
then:
- switch.turn_off:
id: turned_on_manually_action
on_turn_on:
then:
- switch.turn_off:
id: turned_off_manually_action
# Example configuration entry
number:
- platform: template
name: "عداد الحركة"
id: motions_counter
optimistic: true
min_value: 0
max_value: 30
step: 1
switch:
- platform: template
name: " ON تم تشغيله يدويا"
id: turned_on_manually_action
restore_state: false
turn_on_action:
- globals.set:
id: turned_on_manually
value: 'true'
turn_off_action:
- globals.set:
id: turned_on_manually
value: 'false'
lambda: |-
return id(turned_on_manually);
- platform: template
name: ' OFF تم إطفاءه يدويا'
id: turned_off_manually_action
restore_state: false
turn_on_action:
- globals.set:
id: turned_off_manually
value: 'true'
turn_off_action:
- globals.set:
id: turned_off_manually
value: 'false'
lambda: |-
return id(turned_off_manually);
- platform: template
name: ' OFF تم إطفاءه يدويا'
id: till_turn_off_manually_action
restore_state: false
turn_on_action:
- globals.set:
id: till_turn_off_manually
value: 'true'
turn_off_action:
- globals.set:
id: till_turn_off_manually
value: 'false'
lambda: |-
return id(till_turn_off_manually);
- platform: template
name: 'api light on off'
id: api_light_on_off
restore_state: false
turn_on_action:
- light.turn_on:
id: kpa_light
- logger.log:
level: DEBUG
format: 'ON api_light_on_off'
turn_off_action:
- if:
condition:
- for:
time: 8sec
condition:
binary_sensor.is_off: kpa_motion_sensor
# - switch.is_off: iamaway
then:
- light.turn_off:
id: kpa_light
- logger.log:
level: DEBUG
format: 'OFF api_light_on_off'
# - platform: template
# name: 'i am away'
# id: iamaway
# restore_state: true
# optimistic: True
binary_sensor:
- platform: template
id: enough_motion
name: "حركة كافية"
lambda: |-
if (id(motions_counter).state > 0){
return true;}
else {
return false;
}
- platform: gpio
pin: GPIO00
id: reset
internal: true
filters:
- invert:
- delayed_off: 10ms
on_press:
- light.toggle:
id: kpa_light
- platform: gpio
pin:
number: GPIO03
# mode: INPUT_PULLUP
# inverted: True
name: "حساس الحركة "
id: kpa_motion_sensor
device_class: motion
on_press:
if:
condition:
- for:
time: 5sec
condition:
light.is_off: kpa_light
then:
- number.increment:
id: motions_counter
cycle: false
- if:
condition:
- binary_sensor.is_on: enough_motion
then:
- light.turn_on:
id: kpa_light
# on_release:
# if:
# condition:
# for:
# time: 1min
# condition:
# binary_sensor.is_off: kpa_light_wassat-rewaq-motion_sensor
# then:
# - light.turn_off:
# id: kpa_light
# time:
# - platform: sntp
# # ...
- platform: gpio
# name: ${device_name}_Lights
pin: GPIO04
id: switch_1
on_press:
then:
# - switch.turn_on:
- light.toggle:
id: kpa_light
- delay: 1s
- if:
condition:
light.is_on: kpa_light
then:
- switch.turn_on:
id: turned_on_manually_action
- switch.turn_off:
id: turned_off_manually_action
- if:
condition:
light.is_off: kpa_light
then:
- switch.turn_on:
id: turned_off_manually_action
- switch.turn_off:
id: turned_on_manually_action
on_release:
then:
# - switch.turn_off:
- light.toggle:
id: kpa_light
- delay: 1s
- if:
condition:
light.is_on: kpa_light
then:
- switch.turn_on:
id: turned_on_manually_action
- switch.turn_off:
id: turned_off_manually_action
- if:
condition:
light.is_off: kpa_light
then:
- switch.turn_on:
id: turned_off_manually_action
- switch.turn_off:
id: turned_on_manually_action
# - platform: gpio
# pin:
# number: GPIO03
# mode: INPUT_PULLUP
# inverted: True
# name: "PULLUP_Button"
# id: switch_2
# on_press:
# then:
# # - switch.turn_on:
# - light.toggle:
# id: kpa_light
# on_release:
# then:
# # - switch.turn_off:
# - light.toggle:
# id: kpa_light
# Example configuration entry
sun:
latitude: 36.5431918°
longitude: 3.4397346°
time:
- platform: homeassistant
id: homeassistant_time
# ...
on_time:
# Every 1 minute
# - minutes: '*'
# seconds: /10
# then:
# - number.decrement:
# id: motions_counter
# cycle: false
# - if:
# condition:
# - binary_sensor.is_off: enough_motion
# - switch.is_off: turned_on_manually_action
# then:
# - light.turn_off:
# id: kpa_light
# - switch.turn_off:
# id: turned_off_manually_action
- minutes: 15
then:
- if:
condition:
# - binary_sensor.is_off: enough_motion
- switch.is_on: turned_on_manually_action
- for:
time: 15min
condition:
binary_sensor.is_off: enough_motion
then:
- light.turn_off:
id: kpa_light
- switch.turn_off:
id: turned_off_manually_action
- seconds: /1
minutes: '*'
then:
- if:
condition:
- for:
time: 1.7sec
condition:
binary_sensor.is_on: kpa_motion_sensor
# - sun.is_below_horizon:
- binary_sensor.is_on: enough_motion
then:
- light.turn_on:
id: kpa_light
- switch.turn_off:
id: turned_on_manually_action