substitutions: name: "livingroom-bulb-1" friendly_name: "Living Room Bulb 1" room: "Living Room" device_description: "athom 7w rgbcw light bulb" project_name: "Athom Technology.Athom RGBCW Bulb" dns_domain: ".cloonar.smart" timezone: "" sntp_update_interval: 6h sntp_server_1: "0.pool.ntp.org" sntp_server_2: "1.pool.ntp.org" sntp_server_3: "2.pool.ntp.org" log_level: "WARN" esphome: name: "${name}" friendly_name: "${friendly_name}" comment: "${device_description}" area: "${room}" name_add_mac_suffix: false min_version: 2024.6.0 project: name: "${project_name}" version: "${project_version}" on_boot: then: - light.turn_on: id: rgbww_light - delay: 100ms - light.turn_on: id: rgbww_light brightness: 20% - delay: 100ms - light.turn_on: id: rgbww_light red: 100% green: 50% blue: 0% white: 100% interval: - interval: 15s then: - if: condition: api.connected: # check if api connected else: - light.turn_on: id: rgbww_light brightness: 100% esp8266: board: esp8285 restore_from_flash: true preferences: flash_write_interval: 1min api: ota: - platform: esphome logger: mdns: disabled: false wifi: ssid: !secret wifi_ssid password: !secret wifi_password fast_connect: True domain: .cloonar.smart captive_portal: dashboard_import: package_import_url: github://athom-tech/athom-configs/athom-rgbww-light.yaml binary_sensor: - platform: status name: "Status" entity_category: diagnostic sensor: - platform: uptime name: "Uptime Sensor" id: uptime_sensor entity_category: diagnostic internal: true - platform: wifi_signal name: "WiFi Signal dB" id: wifi_signal_db update_interval: 60s entity_category: "diagnostic" - platform: copy source_id: wifi_signal_db name: "WiFi Signal Percent" filters: - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); unit_of_measurement: "Signal %" entity_category: "diagnostic" device_class: "" button: - platform: restart name: "Restart" entity_category: config - platform: factory_reset name: "Factory Reset" id: Reset entity_category: config - platform: safe_mode name: "Safe Mode" internal: false entity_category: config output: - platform: esp8266_pwm id: red_output pin: GPIO4 min_power: 0.000499 max_power: 1 - platform: esp8266_pwm id: green_output pin: GPIO12 min_power: 0.000499 max_power: 1 - platform: esp8266_pwm id: blue_output pin: GPIO14 min_power: 0.000499 max_power: 1 - platform: esp8266_pwm id: warm_white_output pin: GPIO13 min_power: 0.000499 max_power: 0.9 - platform: esp8266_pwm id: white_output pin: GPIO5 min_power: 0.000499 max_power: 0.9 light: - platform: rgbww id: rgbww_light name: "RGBCW_Bulb" red: red_output green: green_output blue: blue_output warm_white: warm_white_output cold_white: white_output cold_white_color_temperature: 6000 K warm_white_color_temperature: 3000 K color_interlock: true text_sensor: - platform: wifi_info ip_address: name: "IP Address" entity_category: diagnostic ssid: name: "Connected SSID" entity_category: diagnostic mac_address: name: "Mac Address" entity_category: diagnostic # Creates a sensor showing when the device was last restarted - platform: template name: 'Last Restart' id: device_last_restart icon: mdi:clock entity_category: diagnostic # device_class: timestamp # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds - platform: template name: "Uptime" entity_category: diagnostic lambda: |- int seconds = (id(uptime_sensor).state); int days = seconds / (24 * 3600); seconds = seconds % (24 * 3600); int hours = seconds / 3600; seconds = seconds % 3600; int minutes = seconds / 60; seconds = seconds % 60; if ( days > 3650 ) { return { "Starting up" }; } else if ( days ) { return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() }; } else if ( hours ) { return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() }; } else if ( minutes ) { return { (String(minutes) +"m "+ String(seconds) +"s").c_str() }; } else { return { (String(seconds) +"s").c_str() }; } icon: mdi:clock-start time: - platform: sntp id: sntp_time # Define the timezone of the device timezone: "${timezone}" # Change sync interval from default 5min to 6 hours (or as set in substitutions) update_interval: ${sntp_update_interval} # Set specific sntp servers to use servers: - "${sntp_server_1}" - "${sntp_server_2}" - "${sntp_server_3}" # Publish the time the device was last restarted on_time_sync: then: # Update last restart time, but only once. - if: condition: lambda: 'return id(device_last_restart).state == "";' then: - text_sensor.template.publish: id: device_last_restart state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'