Sonoff switch stopped working

Tags: #<Tag:0x00007f73ac995cd8>

Hi,

I have a Sonoff basic switch that was working fine with a lamp in drawing room but it suddenly stopped working, I did not tweak anything at all.

Here is the error in logs:

Error during setup of component sonoff
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 362, in connect
    self.sock = ssl_wrap_socket(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 384, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1108)

The configurations are as follows:

switch drawing_room:
  - platform: mqtt
    name: "Sonoff-01"
    command_topic: "cmnd/sonoff1/power"
    state_topic: "stat/sonoff1/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: true

sonoff:
  username: <redacted>
  password: !secret sonoff_password
  scan_interval: 60 #(optional, lower values than 60 won't work anymore!)
  grace_period: 600 #(optional)
  api_region: 'us' #(optional)
  entity_prefix: False #(optional)
  debug: False #(optional)

Last week Sonoff switch started giving some warning about switch being deprecated and to move to SwitchEntity (sorry…did not pay attention so cannot recall with precision).

Any pointers on how to get this switch to start working again?
Thanks!

PS: I am able to operate the Sonoff switch using the eWeLink mobile app without any trouble.

I’m really confused by this.

You clearly have a TLS error; what does that have to do with your Sonoff device?
Your Sonoff is configured to communicate over MQTT not HTTPS.
I assume that’s some cloud config service tied to Sonoff (not sure as I flashed all of my Sonoff with Tasmota)

Also, I can’t find a sonoff component in the docs. Where did you get that template for sonoff from?

@fanuch thanks and you are correct. I just sat on it for a day and restarted HA and Sonoff seems to be working again although I do not have a clue what went wrong (or why) the first time!

I got the Sonoff template on one of the threads in community discussion and it seemed to work for me.

Glad it’s working!

So I got the warning message again and here are the details:

Log Details (WARNING)
Logger: homeassistant.components.switch
Source: components/switch/__init__.py:123
Integration: Switch (documentation, issues)
First occurred: 8:03:14 PM (2 occurrences)
Last logged: 8:03:14 PM

SwitchDevice is deprecated, modify SonoffSwitch to extend SwitchEntity
SwitchDevice is deprecated, modify SonoffDebugSwitch to extend SwitchEntity

Any clue what I need to do or change?