substitutions: devicename: ff-akwarium-plug-01 low_devicename: ff-akwarium-plug-01 friendly_devicename: FF Akwarium Plug 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 mode: input: true pullup: true inverted: true name: "Power Button" on_press: - switch.toggle: relay switch: - platform: gpio # RED id: led_1 pin: number: P6 inverted: false - platform: gpio # BLUE id: led_2 pin: number: P26 inverted: false - platform: gpio name: Switch pin: P8 id: relay # Turn off red LED to show blue when turned on on_turn_on: - switch.turn_on: led_2 - switch.turn_off: led_1 # Turns on the red LED once the plug is turned off on_turn_off: - switch.turn_off: led_2 - switch.turn_on: led_1 button: - platform: restart id: restart_button name: Restart entity_category: diagnostic