ESPHome: Treatlife Single Pole Smart Switch SS02S

I finally took the time to convert these to run the ESPHome firmware to break them away from Treatlife/Tuya and keep them local. My version had the TYWE3S board installed so I was able to use the Tuya-Convert to flash the devices to Tasmota first and then upload the ESPHome firmware once the profile was built.

Below is the code that I run on my Treatlife Single Pole Smart Switch (SS02S) devices.

I have a bunch of code in there that may not apply to your network or you may not want all of the stats that I have enabled. You can remove or comment out those lines.
In the secrets config of ESPHome I have the following variables set:
ap_password – this is the password used to connect to the device directly if the WiFi network is unavailable
esphome_ota – this is the key used by esphome to push updates to the devices, this keeps the key consistent for all devices
wifi_ssid – this is the SSID of the wifi network you want your devices to connect to, this allows you to make one change to affect all devices
wifi_password – this is the password for the wifi network you want your devices to connect to, this allows you to make one change to affect all devices

substitutions:
  device_name: exterior-front-door-lights
  device_friendly_name: Exterior Front Door Lights
  device_id: exterior_front_door_lights
  device_description: "Treatlife Single Pole Smart Switch SS02S"
  icon: "mdi:light-switch"
  update_interval_wifi: 60s
esphome:
  name: ${device_name}
  friendly_name: ${device_friendly_name}
  comment: ${device_description}
esp8266:
  board: esp01_1m
# Automatically logs all log messages, By default, all logs with a severity DEBUG or higher will be shown
# Increasing the log level severity (to e.g INFO or WARNING) can help with the performance of the application and memory size.
logger:
  level: INFO
# Create a simple web server on the node that can be accessed through any browser and a simple REST API
web_server:
# Make the node announce itself on the local network using the multicast DNS (MDNS)
mdns:
# ESPHome native API is used to communicate with clients directly, required for Home Assistant functionality
api:
  encryption:
    key: "(INSERTKEY)"
# Permit OTA (Over The Air) updates
ota:
  - platform: esphome
    password: !secret esphome_ota
# Setup the wifi connection, and configure a possible local access point
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # domain: (LOCALDOMAIN)
  power_save_mode: NONE
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${device_name}
    password: !secret ap_password
# After 1 minute of unsuccessful WiFi connection attempts, the ESP will start a WiFi hotspot (with the credentials from ap configuration above)
captive_portal:
# Provide buttons to restart device in normal and Safe modes.
button:
  - platform: restart
    name: "Restart"
    id: restart_normal
  - platform: safe_mode
    name: "Restart (Safe Mode)"
    id: restart_safe
debug:
  update_interval: 30s
# Report various information about the device and the WiFi connection
text_sensor:
  - platform: debug
    reset_reason: 
      name: Reset Reason
  - platform: version
    name: Version
  - platform: wifi_info
    ip_address:
      name: ${device_friendly_name} IP Address
      icon: "mdi:ip-outline"
      update_interval: ${update_interval_wifi}
    ssid:
      name: Connected SSID
      icon: "mdi:wifi-settings"
      update_interval: ${update_interval_wifi}
    bssid:
      name: Connected BSSID
      icon: "mdi:wifi-settings"
      update_interval: ${update_interval_wifi}
    mac_address:
      name: ${device_friendly_name} WiFi MAC Address
      icon: "mdi:network-outline"
sensor:
  - platform: uptime
    name: ${device_friendly_name} Uptime
    unit_of_measurement: minutes
    filters:
      - lambda: return x / 60.0; 
output:
  - platform: gpio
    pin: GPIO12
    id: switch_output
  - platform: gpio
    pin: GPIO4
    id: white_led_output
light:
  - platform: binary
    name: ${device_friendly_name}
    id: ${device_id}_output
    output: switch_output
    on_turn_on:
      - light.turn_on: white_led
    on_turn_off:
      - light.turn_off: white_led
  - platform: binary
    id: white_led
    output: white_led_output
    restore_mode: RESTORE_AND_OFF
binary_sensor:
  - platform: gpio
    pin: GPIO13
    id: ${device_id}_button
    name: ${device_friendly_name} Button
    on_press:
      - light.toggle: ${device_id}_output
status_led:
  # Red LED
  pin: 
    number: GPIO5
    inverted: yes

2 thoughts on “ESPHome: Treatlife Single Pole Smart Switch SS02S”

  1. Hi there. This is great. Just confirming that this is the single pole version (SS02S). You reference SS02 above so could this be for both SS02 and SS02S? Also I have the very basics working with DS02F if you’d like any info on that.

    1. You are correct, this is the for the single pole. I forgot to put the final S in the model. I’ll update, but I also have the 3-way switch and I’ll get that config posted shortly.

      The config for the DS02F would be great, I have the version that requires a little more work to flash so I haven’t gotten to that yet. You can email it to me [email protected]

      Thanks

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top