forked from syssi/esphome-jbd-bms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesp32-ble-deepsleep-limit-charging-automation.yaml
118 lines (101 loc) · 2.75 KB
/
esp32-ble-deepsleep-limit-charging-automation.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
substitutions:
name: jbd-bms-ble
device_description: "Monitor and control a Xiaoxiang Battery Management System (JBD-BMS) via BLE"
external_components_source: github://syssi/esphome-jbd-bms@main
mac_address: 70:3e:97:07:c0:3e
esphome:
name: ${name}
comment: ${device_description}
min_version: 2024.6.0
project:
name: "syssi.esphome-jbd-bms"
version: 2.0.0
esp32:
board: wemos_d1_mini32
framework:
type: esp-idf
external_components:
- source: ${external_components_source}
refresh: 0s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 0s
ota:
platform: esphome
logger:
level: DEBUG
# If you use Home Assistant please remove this `mqtt` section and uncomment the `api` component!
# The native API has many advantages over MQTT: https://esphome.io/components/api.html#advantages-over-mqtt
mqtt:
broker: !secret mqtt_host
username: !secret mqtt_username
password: !secret mqtt_password
id: mqtt_client
reboot_timeout: 0s
# api:
# reboot_timeout: 0s
deep_sleep:
id: deep_sleep0
run_duration: 2min
sleep_duration: 10min
esp32_ble_tracker:
ble_client:
- id: client0
mac_address: ${mac_address}
jbd_bms_ble:
- id: bms0
ble_client_id: client0
update_interval: 2s
sensor:
- platform: jbd_bms_ble
jbd_bms_ble_id: bms0
power:
name: "${name} power"
total_voltage:
name: "${name} total voltage"
state_of_charge:
id: state_of_charge
name: "${name} state of charge"
on_value:
# Enable charging if the state of charge is below 80%
- if:
condition:
and:
- switch.is_off: charging
- sensor.in_range:
id: state_of_charge
below: 79.0
then:
- switch.turn_on: charging
# Stop charging if the state of charge is above 80%
- if:
condition:
and:
- switch.is_on: charging
- sensor.in_range:
id: state_of_charge
above: 80.0
then:
- switch.turn_off: charging
# Suspend deep sleep at the end of a charge cycle to stop on point (optional!)
- if:
condition:
and:
- switch.is_on: charging
- sensor.in_range:
id: state_of_charge
above: 75.0
then:
- deep_sleep.prevent: deep_sleep0
switch:
- platform: ble_client
ble_client_id: client0
name: "${name} enable bluetooth connection"
- platform: jbd_bms_ble
jbd_bms_ble_id: bms0
charging:
name: "${name} charging"
id: charging
discharging:
name: "${name} discharging"