| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- substitutions:
- devicename: ff-akwarium-plug-01
- low_devicename: ff-akwarium-plug-01
- friendly_devicename: FF Akwarium Light 01
- esphome:
- name: $devicename
- friendly_name: $friendly_devicename
- bk72xx:
- board: generic-bk7231t-qfn32-tuya
- #framework:
- # version: dev
- # Enable logging
- logger:
- web_server:
- port: 80
-
- # Enable Home Assistant API
- api:
- encryption:
- key: "ejeMnlF5M60w/yuYwAWn/kIBz701xLwVkUGf9iN8uLA="
- ota:
- password: "2c27af3ab81f992e23745c20ab5dfc02"
- wifi:
- ssid: !secret iot_ssid
- password: !secret iot_password
- domain: .int.mmax.cloud
- sensor:
- - platform: wifi_signal
- name: "WiFi Signal Sensor"
- update_interval: 60s
- - platform: uptime
- name: Uptime Sensor
- id: uptime_sensor
- update_interval: 60s
- on_raw_value:
- then:
- - text_sensor.template.publish:
- id: uptime_human
- state: !lambda |-
- int seconds = round(id(uptime_sensor).raw_state);
- int days = seconds / (24 * 3600);
- seconds = seconds % (24 * 3600);
- int hours = seconds / 3600;
- seconds = seconds % 3600;
- int minutes = seconds / 60;
- seconds = seconds % 60;
- return (
- (days ? to_string(days) + "d " : "") +
- (hours ? to_string(hours) + "h " : "") +
- (minutes ? to_string(minutes) + "m " : "") +
- (to_string(seconds) + "s")
- ).c_str();
- text_sensor:
- - platform: template
- name: Uptime Human Readable
- id: uptime_human
- icon: mdi:clock-start
- - platform: wifi_info
- ip_address:
- name: IP Address
- entity_category: diagnostic
- binary_sensor:
- - platform: status
- name: Status
- entity_category: diagnostic
- - platform: gpio
- pin:
- number: P7
- inverted: true
- mode:
- input: true
- pullup: true
- name: "Power Button"
- on_press:
- # - output.toggle: relay
- - select.next:
- id: light_mode
- cycle: true
- light:
- - platform: binary
- name: Red LED
- id: red_led
- output: led_1
- internal: True
- restore_mode: ALWAYS_OFF
- output:
- - platform: gpio
- # RED
- id: led_1
- pin:
- number: P6
- inverted: false
- # - platform: gpio
- # # BLUE
- # id: led_2
- status_led:
- pin:
- number: P26
- inverted: false
- button:
- - platform: restart
- id: restart_button
- name: Restart
- entity_category: diagnostic
- globals:
- - id: current_light
- type: int
- initial_value: "0"
- select:
- - platform: template
- name: "Light Mode"
- id: light_mode
- options:
- - "Off"
- - "Day"
- - "Daybreak"
- - "Night"
- optimistic: true
- on_value:
- then:
- - if:
- condition:
- - lambda: |-
- return(id(light_mode).state) == "Off";
- then:
- - switch.turn_off: relay
- - if:
- condition:
- - lambda: |-
- return(id(light_mode).state) == "Day";
- then:
- - switch.turn_off: relay
- - delay: 20s
- - switch.turn_on: relay
- - if:
- condition:
- - lambda: |-
- return(id(light_mode).state) == "Daybreak";
- then:
- - switch.turn_off: relay
- - delay: 20s
- - switch.turn_on: relay
- - delay: 200ms
- - switch.turn_off: relay
- - delay: 200ms
- - switch.turn_on: relay
-
- - if:
- condition:
- - lambda: |-
- return(id(light_mode).state) == "Night";
- then:
- - switch.turn_off: relay
- - delay: 20s
- - switch.turn_on: relay
- - delay: 200ms
- - switch.turn_off: relay
- - delay: 200ms
- - switch.turn_on: relay
- - switch.turn_off: relay
- - delay: 200ms
- - switch.turn_on: relay
- - lambda: |-
- id(current_light) == id(light_mode).active_index();
- switch:
- - platform: gpio
- pin: P8
- id: relay
- internal: true
- restore_mode: ALWAYS_OFF
- # Turn off red LED to show blue when turned on
- on_turn_on:
- - light.turn_on: red_led
- # - switch.turn_off: led_1
- # Turns on the red LED once the plug is turned off
- on_turn_off:
- - light.turn_off: red_led
- # - switch.turn_on: led_1
- # - platform: template
- # name: mode
- # output: relay
- # internal: True
- # effects:
- # - lambda:
- # name: Day
- # - lambda:
- # name: Daybreak
- # - lambda:
- # name: Night
-
|