Advertisement
CD_Fighter

ESPHome Wemos D1 Mini esp8266

Apr 1st, 2024 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.70 KB | Source Code | 0 0
  1. substitutions:
  2.   name: "jk-bms"
  3.   device_description: "Monitor a JK-BMS via UART-TTL"
  4.   external_components_source: github://syssi/esphome-jk-bms@main
  5.   tx_pin: GPIO1
  6.   rx_pin: GPIO3
  7.  
  8. esphome:
  9.   name: ${name}
  10.   comment: ${device_description}
  11.   project:
  12.     name: "syssi.esphome-jk-bms"
  13.     version: 2.0.0
  14.  
  15. esp8266:
  16.   board: d1_mini
  17.  
  18. # Enable Home Assistant API
  19. api:
  20.   encryption:
  21.     key: "xxx"
  22.  
  23. ota:
  24.   password: "xxx"
  25.  
  26. wifi:
  27.   reboot_timeout: 5min
  28.   power_save_mode: NONE
  29.   fast_connect: True
  30.   networks:
  31.   - ssid: !secret wifi_ssid
  32.     password: !secret wifi_password
  33. #  - ssid: !secret wifi2_ssid
  34. #    password: !secret wifi2_password
  35.  
  36. # Enable fallback hotspot (captive portal) in case wifi connection fails
  37. #  ap:
  38. #    ssid: "Jk-Bms Fallback Hotspot"
  39. #    password: "xxx"
  40.  
  41. external_components:
  42.   - source: ${external_components_source}
  43.     refresh: 0s
  44.  
  45. logger:
  46.   baud_rate: 0
  47.   level: DEBUG
  48.  
  49. uart:
  50.   - id: uart_0
  51.     baud_rate: 115200
  52.     rx_buffer_size: 384
  53.     tx_pin: ${tx_pin}
  54.     rx_pin: ${rx_pin}
  55.  
  56. jk_modbus:
  57.   - id: modbus0
  58.     uart_id: uart_0
  59.     rx_timeout: 50ms
  60.  
  61. jk_bms:
  62.   - id: bms0
  63.     jk_modbus_id: modbus0
  64.     update_interval: 5s
  65.  
  66. binary_sensor:
  67.   - platform: jk_bms
  68.     balancing:
  69.       name: "${name} balancing"
  70.     balancing_switch:
  71.       name: "${name} balancing switch"
  72.     charging:
  73.       name: "${name} charging"
  74.     discharging:
  75.       name: "${name} discharging"
  76.     dedicated_charger_switch:
  77.       name: "${name} dedicated charger switch"
  78.     online_status:
  79.       name: "${name} online status"
  80.  
  81. sensor:
  82.   - platform: jk_bms
  83.     min_cell_voltage:
  84.       name: "${name} min cell voltage"
  85.     max_cell_voltage:
  86.       name: "${name} max cell voltage"
  87.     min_voltage_cell:
  88.       name: "${name} min voltage cell"
  89.     max_voltage_cell:
  90.       name: "${name} max voltage cell"
  91.     delta_cell_voltage:
  92.       id: delta_cell_v
  93.       name: "${name} delta cell voltage"
  94.     average_cell_voltage:
  95.       name: "${name} average cell voltage"
  96.     cell_voltage_1:
  97.       id: cell_1_v
  98.       name: "${name} cell voltage 1"
  99.     cell_voltage_2:
  100.       id: cell_2_v
  101.       name: "${name} cell voltage 2"
  102.     cell_voltage_3:
  103.       id: cell_3_v
  104.       name: "${name} cell voltage 3"
  105.     cell_voltage_4:
  106.       id: cell_4_v
  107.       name: "${name} cell voltage 4"
  108.     cell_voltage_5:
  109.       id: cell_5_v
  110.       name: "${name} cell voltage 5"
  111.     cell_voltage_6:
  112.       id: cell_6_v
  113.       name: "${name} cell voltage 6"
  114.     cell_voltage_7:
  115.       id: cell_7_v
  116.       name: "${name} cell voltage 7"
  117.     cell_voltage_8:
  118.       id: cell_8_v
  119.       name: "${name} cell voltage 8"
  120.     cell_voltage_9:
  121.       name: "${name} cell voltage 9"
  122.     cell_voltage_10:
  123.       name: "${name} cell voltage 10"
  124.     power_tube_temperature:
  125.       name: "${name} power tube temperature"
  126.     temperature_sensor_1:
  127.       name: "${name} temperature sensor 1"
  128.     temperature_sensor_2:
  129.       name: "${name} temperature sensor 2"
  130.     total_voltage:
  131.       name: "${name} total voltage"
  132.     current:
  133.       name: "${name} current"
  134.     power:
  135.       id: battery_power
  136.       name: "${name} power"
  137.     capacity_remaining:
  138.       id: remain_battery
  139.       name: "${name} capacity remaining"
  140.     actual_battery_capacity:
  141.       name: "${name} actual battery capacity"
  142.     total_battery_capacity_setting:
  143.       name: "${name} total battery capacity setting"
  144.     total_charging_cycle_capacity:
  145.       name: "${name} total charging cycle capacity"
  146.     charging_cycles:
  147.       name: "${name} charging cycles"
  148.     capacity_remaining_derived:
  149.       name: "${name} capacity remaining derived"
  150.     total_runtime:
  151.       name: "${name} total runtime"
  152.  
  153.   - platform: homeassistant
  154.     id: active_power
  155.     entity_id: sensor.shellypro3em_xxx_total_active_power
  156.     internal: true
  157.  
  158.   - platform: homeassistant
  159.     id: batt_volt
  160.     entity_id: sensor.hm_400_ch1_u_dc
  161.     internal: true
  162.  
  163.   - platform: dallas
  164.     address: 0x203c01b5569fcb28
  165.     name: "Battery Box"
  166.  
  167. switch:
  168.   - platform: jk_bms
  169.     charging:
  170.       name: "${name} charging"
  171.     discharging:
  172.       name: "${name} discharging"
  173.  
  174. text_sensor:
  175.   - platform: jk_bms
  176.     errors:
  177.       name: "${name} errors"
  178.     operation_mode:
  179.       name: "${name} operation mode"
  180.     total_runtime_formatted:
  181.       name: "${name} total runtime formatted"
  182.  
  183. #captive_portal:
  184.  
  185. dallas:
  186.   - pin: 14
  187.  
  188. time:
  189.   - platform: homeassistant
  190.     id: esptime
  191.  
  192. font:
  193.   - file: 'slkscr.ttf'
  194.     id: font1
  195.     size: 8
  196.  
  197.   - file: 'arial.ttf'
  198.     id: font2
  199.     size: 36
  200.  
  201.   - file: 'arial.ttf'
  202.     id: font3
  203.     size: 16
  204. i2c:
  205.   sda: D2
  206.   scl: D1
  207.   scan: True
  208.   id: bus_a
  209.   frequency: 400kHz
  210.  
  211. display:
  212.   - platform: ssd1306_i2c
  213.     model: "SSD1306 128x64"
  214.     reset_pin: D0
  215.     address: 0x3C
  216.     lambda: |-
  217.       it.strftime(45, 0, id(font1), TextAlign::TOP_LEFT, "JK-BMS %H:%M %S", id(esptime).now());
  218.       if (id(cell_1_v).has_state()) {
  219.         it.printf(1, 0, id(font1), TextAlign::TOP_LEFT , "1: %.3fV", id(cell_1_v).state);
  220.       }
  221.       if (id(cell_2_v).has_state()) {
  222.         it.printf(0, 8, id(font1), TextAlign::TOP_LEFT , "2: %.3fV", id(cell_2_v).state);
  223.       }
  224.       if (id(cell_3_v).has_state()) {
  225.         it.printf(0, 16, id(font1), TextAlign::TOP_LEFT , "3: %.3fV", id(cell_3_v).state);
  226.       }
  227.       if (id(cell_4_v).has_state()) {
  228.         it.printf(0, 24, id(font1), TextAlign::TOP_LEFT , "4: %.3fV", id(cell_4_v).state);
  229.       }
  230.       if (id(cell_5_v).has_state()) {
  231.         it.printf(0, 32, id(font1), TextAlign::TOP_LEFT , "5: %.3fV", id(cell_5_v).state);
  232.       }
  233.       if (id(cell_6_v).has_state()) {
  234.         it.printf(0, 40, id(font1), TextAlign::TOP_LEFT , "6: %.3fV", id(cell_6_v).state);
  235.       }
  236.       if (id(cell_7_v).has_state()) {
  237.         it.printf(0, 48, id(font1), TextAlign::TOP_LEFT , "7: %.3fV", id(cell_7_v).state);
  238.       }
  239.       if (id(cell_8_v).has_state()) {
  240.         it.printf(0, 56, id(font1), TextAlign::TOP_LEFT , "8: %.3fV", id(cell_8_v).state);
  241.       }
  242.       if (id(delta_cell_v).has_state()) {
  243.         it.printf(48, 8, id(font1), TextAlign::TOP_LEFT , "D: %.3fV", id(delta_cell_v).state);
  244.       }
  245.       if (id(battery_power).has_state()) {
  246.         it.printf(48, 31, id(font3), TextAlign::BASELINE_LEFT , "P: %.1fW", id(battery_power).state);
  247.       }
  248.       if (id(remain_battery).has_state()) {
  249.         it.printf(48, 47, id(font3), TextAlign::BASELINE_LEFT , "C: %.1f%%", id(remain_battery).state);
  250.       }
  251.       if (id(active_power).has_state()) {
  252.         it.printf(48, 63, id(font3), TextAlign::BASELINE_LEFT , "N: %.1fW", id(active_power).state);
  253.       }
  254.       if (id(batt_volt).has_state()) {
  255.         it.printf(91, 8, id(font1), TextAlign::TOP_LEFT , "B: %.1f", id(batt_volt).state);
  256.       }
  257.      
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement