差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

后一修订版
前一修订版
developmentboard:esphome_smart_light_bulb [2024/10/19 03:55] – 创建 admindevelopmentboard:esphome_smart_light_bulb [2024/12/18 14:41] (当前版本) admin
行 1: 行 1:
 ESPHome Smart Light Bulb ESPHome Smart Light Bulb
  
-Yaml File:+Introduction – Detected by Home Assistant 
 + 
 +– Controlled by MQTT, Web UI, HTTP, etc 
 + 
 +– Using times, scripts, rules 
 + 
 +– Open source 
 + 
 +– Use ESP8285-2M as MCU 
 + 
 +Specification – RGB+C+W, 9W 
 + 
 +– 850LM 
 + 
 +– AC:100-265V, 50/60Hz 
 + 
 +– 2700-6500K 
 + 
 +– E26/E27 
 + 
 +– 60 x 60 x 125 mm 
 + 
 +– 40000 hours 
 + 
 +**GPIOs** 
 + 
 +GPIO4 – PWM1 – Cool WhiteGPIO5 – PWM4 – Blue ColorGPIO12 – PWM2 – Red Color GPIO13 – PWM5 – Warm WhiteGPIO14 – PWM3 – Green Color 
 + 
 +**Yaml File:**
  
 substitutions: substitutions:
 +
 name: "aiyato-rgbcw" name: "aiyato-rgbcw"
 +
 friendly_name: "AiYaTo RGBCW" friendly_name: "AiYaTo RGBCW"
 +
 project_name: "doit.aiyato-rgbcw" project_name: "doit.aiyato-rgbcw"
 +
 project_version: "1.0.0" project_version: "1.0.0"
 +
 light_restore_mode: RESTORE_DEFAULT_ON light_restore_mode: RESTORE_DEFAULT_ON
 +
 color_interlock: 'true' color_interlock: 'true'
  
 esphome: esphome:
 +
 name: "${name}" name: "${name}"
 +
 name_add_mac_suffix: true name_add_mac_suffix: true
 +
 project: project:
 +
 name: "${project_name}" name: "${project_name}"
 +
 version: "${project_version}" version: "${project_version}"
  
 preferences: preferences:
 +
 flash_write_interval: 1min flash_write_interval: 1min
  
 esp8266: esp8266:
 +
 board: esp8285 board: esp8285
 +
 restore_from_flash: true restore_from_flash: true
  
 globals: globals:
 +
 - id: my_global_mode - id: my_global_mode
 +
 type: bool type: bool
 +
 restore_value: no restore_value: no
 +
 initial_value: 'true' initial_value: 'true'
  
行 36: 行 82:
  
 ota: ota:
 +
 safe_mode: false safe_mode: false
  
 wifi: wifi:
 +
 ap: {} ap: {}
  
 interval: interval:
 +
 - interval: 1s - interval: 1s
 +
 then: then:
 +
 - lambda: |- - lambda: |-
 +
 static uint32_t cnt = 0; static uint32_t cnt = 0;
 +
 static int flag = 0; static int flag = 0;
-static ESPPreferenceObject pref = global_preferences->make_preference<uint32_t>(23332500UL, true); + 
-if((flag == 1) && (network::is_connected()))+static ESPPreferenceObject pref = global_preferencesmake_preference(23332500UL, true); 
 + 
 +if((flag == 1) && (network::is_connected( _FCKG_BLANK_TD_)) ) 
 { {
 +
 flag = 0; flag = 0;
 +
 ESP.restart(); ESP.restart();
 +
 } }
 +
 if(cnt == 0){ if(cnt == 0){
 +
 cnt++; cnt++;
 +
 uint32_t val = 0; uint32_t val = 0;
 +
 pref.load(&val); pref.load(&val);
 +
 val+=1; val+=1;
 +
 pref.save(&val); pref.save(&val);
-global_preferences->sync();+ 
 +global_preferencessync(); 
 if(val >= 3){ if(val >= 3){
-my_global_mode->value() = false;+ 
 +my_global_modevalue() = false; 
 } }
 +
 }else if(cnt < 5){ }else if(cnt < 5){
 +
 cnt++; cnt++;
 +
 if(cnt == 5){ if(cnt == 5){
 +
 uint32_t val = 0; uint32_t val = 0;
 +
 pref.save(&val); pref.save(&val);
-global_preferences->sync();+ 
 +global_preferencessync(); 
 } }
 +
 } }
-if(!my_global_mode->value()){+ 
 +if(!my_global_modevalue()){ 
 if(cnt == 1){ if(cnt == 1){
 +
 char a[] = "000000"; char a[] = "000000";
 +
 char b[] = "000000"; char b[] = "000000";
-wifi_wificomponent->clear_sta(); + 
-wifi_wificomponent->save_wifi_sta(a, b);+wifi_wificomponentclear_sta(); 
 + 
 +wifi_wificomponentsave_wifi_sta(a, b); 
 wifi::WiFiAP wifi_wifiap = wifi::WiFiAP(); wifi::WiFiAP wifi_wifiap = wifi::WiFiAP();
-wifi_wificomponent->set_ap(wifi_wifiap); + 
-wifi_wificomponent->set_ap_timeout(5000);+wifi_wificomponentset_ap(wifi_wifiap); 
 + 
 +wifi_wificomponentset_ap_timeout(5000); 
 flag = 1; flag = 1;
-rgbww_rgbwwlightoutput->set_color_interlock(false);+ 
 +rgbww_rgbwwlightoutputset_color_interlock(false); 
 } }
 +
 static int state = 0; static int state = 0;
 +
 auto call = id(my_light).turn_on(); auto call = id(my_light).turn_on();
 +
 call.set_transition_length(1000); call.set_transition_length(1000);
 +
 call.set_brightness(1.0); call.set_brightness(1.0);
 +
 if (state == 0) { if (state == 0) {
 +
 call.set_rgb(1.0, 0.0, 0.0); call.set_rgb(1.0, 0.0, 0.0);
 +
 call.set_cold_white(0.0); call.set_cold_white(0.0);
 +
 call.set_warm_white(0.0); call.set_warm_white(0.0);
 +
 } else if (state == 3) { } else if (state == 3) {
 +
 call.set_rgb(0.0, 1.0, 0.0); call.set_rgb(0.0, 1.0, 0.0);
 +
 } else if (state == 5) { } else if (state == 5) {
 +
 call.set_rgb(0.0, 0.0, 1.0); call.set_rgb(0.0, 0.0, 1.0);
 +
 } else if (state == 7) { } else if (state == 7) {
 +
 call.set_color_brightness(0.0); call.set_color_brightness(0.0);
 +
 call.set_cold_white(1.0); call.set_cold_white(1.0);
 +
 call.set_warm_white(0.0); call.set_warm_white(0.0);
 +
 } else if (state == 9) { } else if (state == 9) {
 +
 call.set_cold_white(0.0); call.set_cold_white(0.0);
 +
 call.set_warm_white(1.0); call.set_warm_white(1.0);
 +
 } else if (state == 11) { } else if (state == 11) {
 +
 call.set_color_brightness(1.0); call.set_color_brightness(1.0);
 +
 call.set_rgb(0.0, 1.0, 0.0); call.set_rgb(0.0, 1.0, 0.0);
 +
 call.set_cold_white(0.0); call.set_cold_white(0.0);
 +
 call.set_warm_white(0.0); call.set_warm_white(0.0);
 +
 } }
 +
 call.perform(); call.perform();
 +
 state += 1; state += 1;
 +
 if (state == 12) if (state == 12)
 +
 { {
-my_global_mode->value() = true;+ 
 +my_global_modevalue() = true; 
 } }
 +
 } }
  
 web_server: web_server:
 +
 port: 80 port: 80
  
行 122: 行 244:
  
 binary_sensor: binary_sensor:
 +
 - platform: status - platform: status
 +
 name: "${friendly_name} Status" name: "${friendly_name} Status"
  
 sensor: sensor:
 +
 - platform: uptime - platform: uptime
 +
 update_interval: 60s update_interval: 60s
 +
 name: "${friendly_name} Uptime" name: "${friendly_name} Uptime"
  
 button: button:
 +
 - platform: restart - platform: restart
 +
 name: "${friendly_name} Restart" name: "${friendly_name} Restart"
  
 output: output:
 +
 - platform: esp8266_pwm - platform: esp8266_pwm
 +
 id: red_output id: red_output
 +
 pin: GPIO12 pin: GPIO12
 +
 - platform: esp8266_pwm - platform: esp8266_pwm
 +
 id: green_output id: green_output
 +
 pin: GPIO14 pin: GPIO14
 +
 - platform: esp8266_pwm - platform: esp8266_pwm
 +
 id: blue_output id: blue_output
 +
 pin: GPIO5 pin: GPIO5
 +
 - platform: esp8266_pwm - platform: esp8266_pwm
 +
 id: cold_white_output id: cold_white_output
 +
 pin: GPIO4 pin: GPIO4
 +
 - platform: esp8266_pwm - platform: esp8266_pwm
 +
 id: warm_white_output id: warm_white_output
 +
 pin: GPIO13 pin: GPIO13
  
 light: light:
 +
 - platform: rgbww - platform: rgbww
 +
 name: "${friendly_name}" name: "${friendly_name}"
 +
 restore_mode: "${light_restore_mode}" restore_mode: "${light_restore_mode}"
 +
 red: red_output red: red_output
 +
 green: green_output green: green_output
 +
 blue: blue_output blue: blue_output
 +
 cold_white: cold_white_output cold_white: cold_white_output
 +
 warm_white: warm_white_output warm_white: warm_white_output
 +
 cold_white_color_temperature: 6000 K cold_white_color_temperature: 6000 K
 +
 warm_white_color_temperature: 3000 K warm_white_color_temperature: 3000 K
 +
 color_interlock: "${color_interlock}" color_interlock: "${color_interlock}"
 +
 id: my_light id: my_light
  
 text_sensor: text_sensor:
 +
 - platform: wifi_info - platform: wifi_info
 +
 ip_address: ip_address:
 +
 name: "${friendly_name} IP Address" name: "${friendly_name} IP Address"
 +
 disabled_by_default: true disabled_by_default: true
 +
 +{{:developmentboard:yaml.zip|yaml.zip}}
 +
 +----
 +
  
  • developmentboard/esphome_smart_light_bulb.1729310112.txt.gz
  • 最后更改: 2024/10/19 03:55
  • admin