captive_portal: web_server: port: 80 version: 3 output: - platform: esp8266_pwm pin: GPIO12 # D6 on NodeMCU id: buzzer_pwm rtttl: output: buzzer_pwm id: doorbell_chime time: - platform: sntp id: ntp_time servers: - "ntp.pagasa.dost.gov.ph" - "pool.ntp.org" timezone: "PHT-8" update_interval: 7d font: # NOTE: Original URLs are currently inaccessible — replaced with built-in font - file: "https://www.systembay.com/api/jwan5X8.bdf" id: clock_font spi: clk_pin: GPIO14 # D5 mosi_pin: GPIO13 # D7 sensor: - platform: homeassistant name: "Battery SOC from HA" id: ha_batt_soc entity_id: sensor.modbus_battery_soc internal: true - platform: homeassistant name: "Grid Power from HA" id: ha_gridpwr entity_id: sensor.modbus_grid_power # ✅ UPDATE WITH YOUR HA ENTITY internal: true - platform: homeassistant name: "Battery Power from HA" id: ha_battpwr entity_id: sensor.modbus_battery_power internal: true binary_sensor: - platform: homeassistant name: "Doorbell Alarm" id: ha_doorbell entity_id: binary_sensor.iotsvvdoorbell_doorbell_button internal: true # Triggers instantly when the imported binary sensor changes to true/on on_press: then: - rtttl.play: "dingdong2:d=4,b=120:e6,2c6,p,e6,2c6,e6,2c6,p,e6,2c6" globals: - id: show_time_screen type: bool restore_value: no initial_value: 'true' - id: soc_string type: std::string restore_value: no initial_value: 'std::string("OFFLINE")' - id: show_doorbell_alert type: bool restore_value: no initial_value: 'false' - id: current_gridpwr type: int restore_value: no initial_value: '0' - id: current_battpwr type: int restore_value: no initial_value: '0' - id: current_battsoc type: int restore_value: no initial_value: '0' interval: - interval: 2s then: - lambda: |- id(show_time_screen) = !id(show_time_screen); // Pull latest values from Home Assistant if (id(ha_batt_soc).has_state()) id(current_battsoc) = round(id(ha_batt_soc).state); if (id(ha_gridpwr).has_state()) id(current_gridpwr) = round(id(ha_gridpwr).state); if (id(ha_battpwr).has_state()) id(current_battpwr) = round(id(ha_battpwr).state); // Original display formatting logic preserved exactly std::string display_text = std::to_string(id(current_battsoc)) + "%"; if (id(current_gridpwr) > 0) { display_text += " V"; } if (id(current_battsoc) == 100) { display_text = " " + display_text; } else if (id(current_battpwr) >= 0 && id(current_battpwr) <= 500) { display_text = " -" + display_text; } else if (id(current_battpwr) > 500 && id(current_battpwr) <= 1000) { display_text = " --" + display_text; } else if (id(current_battpwr) > 1000) { display_text = "---" + display_text; } else if (id(current_battpwr) >= -500 && id(current_battpwr) < 0) { display_text = " +" + display_text; } else if (id(current_battpwr) >= -1000 && id(current_battpwr) < -500) { display_text = " ++" + display_text; } else if (id(current_battpwr) < -1000) { display_text = "+++" + display_text; } id(soc_string) = display_text; display: - platform: max7219digit id: max7219_display cs_pin: GPIO15 # D8 num_chips: 4 intensity: 1 lambda: |- if (id(show_doorbell_alert)) { it.print(1, 1, id(clock_font), "DOOR"); return; } if (id(ntp_time).now().is_valid()) { if (id(show_time_screen)) { it.strftime(9, 1, id(clock_font), "%l:%M", id(ntp_time).now()); return; } } if (!id(show_time_screen)) { it.print(1, 1, id(clock_font), id(soc_string).c_str()); return; } it.print(1, 1, id(clock_font), "GET TIME");