Hello all!
I would like to change status 'Unknown" of battery entity (Filament Stan baterii) to 0 since it makes problem with other automations. I tried filters and lambdas but I can’t get it to work. My code:
esphome:
name: bramka-bluetooth-pietro
platform: ESP32
board: esp32dev
wifi:
ssid: "xxx"
password: "xxx"
# Enable logging
logger:
# Enable Home Assistant API
api:
# password: "xxx"
ota:
password: "xxx"
esp32_ble_tracker:
# scan_parameters:
# duration: 10s
# on_ble_service_data_advertise:
# - mac_address:
# service_uuid: FE95
# then:
# - lambda: |-
# id(kettle_temp).publish_state(float(x[16]));
# if(x[15] == 01) {
# id(kettle_mode).publish_state(true);
# } else {
# id(kettle_mode).publish_state(false);
# }
binary_sensor:
- platform: ble_presence
mac_address:
name: "Marcin"
- platform: ble_presence
mac_address:
name: "Gosia"
# - platform: template
# id: kettle_mode
# name: "Tryb Czajnik"
sensor:
- platform: xiaomi_hhccjcy01
mac_address:
temperature:
name: "Temperatura"
moisture:
name: "Wilgotność"
illuminance:
name: "Nasłonecznienie"
conductivity:
name: "Żyzność gleby"
# battery_level:
# name: "Stan baterii"
- platform: xiaomi_lywsdcgq
mac_address:
temperature:
name: "Temperatura Terrarium"
humidity:
name: "Wilgotność Terrarium"
battery_level:
name: "Stan baterii Terrarium"
- platform: xiaomi_lywsd02
mac_address: '
temperature:
name: "Temperatura Zegar"
humidity:
name: "Wilgotność Zegar"
- platform: xiaomi_lywsd03mmc
mac_address:
bindkey:
temperature:
name: "Filament Temperatura"
humidity:
name: "Filament Wilgotność"
battery_level:
id: battery_level
name: "Filament Stan baterii"
# filters:
# - lambda: |-
# if ((id(battery_level).state == 'Unknown')) {
# id(battery_level).publish_state(0);
# return {};}
- platform: xiaomi_mhoc401
mac_address:
bindkey:
temperature:
name: "Strych Temperatura"
humidity:
name: "Strych Wilgotność"
battery_level:
name: "Strych Stan baterii"
# - platform: template
# id: kettle_temp
# name: "Temperatura Czajnik"
# unit_of_measurement: '°C'
# accuracy_decimals: 0
# icon: "mdi:thermometer"
Thank you in advance for any info and help!