Sonoff TH16, how to use it?

The state of sensor.sonoff_temperature says “unknown”
The sonoff switch id is : switch.sonoff_1000beb186

Just check if this is the config.

sensor:
  - platform: template
    sensors:
      sonoff_temperature:
        friendly_name: "Temperature"
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('switch.sonoff_1000beb186', 'temperature') }}"
      sonoff_humidity:
        friendly_name: "Humidity"
        unit_of_measurement: '%'
        value_template: "{{ state_attr('switch.sonoff_1000beb186', 'humidity') }}"
2 Likes

i copied your code and put it in the config, then restarted the server.

now it is showing up perfectly!

Thank you so much for your time and effort

1 Like

sheminasalam :clap: :+1: :clap: :+1: thanks ,the code works perfectly

1 Like

Hello to all, and first of all, I want to say Thank you to all people that are helping us (newbies) here.
I have installed same sonoff TH16 sensor, with the help of this forum users I managed to display data from it, but is there a way to force refresh it? Sometimes it gives me data from few mins ago, sometimes it returns data from hours ago, and … I don’t know how to force refresh on a fixed interval of time, or on demand. Thank you in advance.

Hello Laurentiu,

i opened another topic facing the exact same question:

Long story sort, you cant do it without flashing other software on it.

If you use the AlexxIT / SonoffLAN integration you can configure the refresh interval by setting i.e.

scan_interval: '00:05:00' # (optional) default 5 minutes

within the sonoff-block inside configuration.yaml.

Can you please give me an example of configuration for this scan_interval ?
And where exactly to add it? I’m new to HA and don’t know yet what files are for configuration.
This is my configuration, but … it does not update :
sonoff:
username: xxxxx
password: xxxxx
reload: always
scan_interval: ‘00:01:00’
devices:
10010b8405:
name: Sonoff TH
force_update: True

sensor:

  • platform: template
    sensors:
    sonoff_temperature:
    friendly_name: “Temperature”
    unit_of_measurement: ‘°C’
    value_template: “{{ state_attr(‘switch.sonoff_10010b8405’, ‘temperature’) }}”
    sonoff_humidity:
    friendly_name: “Humidity”
    unit_of_measurement: ‘%’
    value_template: “{{ state_attr(‘switch.sonoff_10010b8405’, ‘humidity’) }}”

As I mentioned it before the scan_interval-directive only applies if you use the AlexxIT / SonoffLAN custom integration (which I recommend since you will be able to circumvent the eWeLink/Sonoff-Cloud but run your TH’s etc. locally).

If you use that custom integration the sonoff-block inside configuration.yaml looks like i.e.:

  sonoff:
    username: !secret sonoff_usr
    password: !secret sonoff_pwd
    force_update: [temperature, power]
    scan_interval: '00:05:00'  # (optional) default 5 minutes
    sensors: [temperature, humidity, power]
    mode: local
    reload: always  # update device list every time HA starts

Thank you, but I don’t have all necessary hardware for flashing it.

Tamsy, maybe I’m to stupid to understand. Now I have the following configuration in configuration.yaml

sonoff:
username: xxx
password: xxx
force_update: [temperature, humidity, power]
scan_interval: ‘00:01:00’
sensors: [temperature, humidity, power, current, voltage]
mode: cloud
reload: always

I tried to set interval to 1 min just to see if it is updating, I tried with mode : local and cloud, but still not updating, when I check updating time, always shows more than 1 min.
What I’m doing wrong? I’m using AlexxIT/ SonoffLAN

So, without flashing, but using AlexxIT/ SonoffLAN we cant force scan_interval every X minutes, is that right?

That is correct:
scan_interval: '00:05:00' # (optional) default 5 minutes

Thanks for the reply @Tamsy!

We put scan_interval: '00:05:00' # (optional) default 5 minutes at configuration.yaml file below ewelink account credentials, right> If yes, i have already tested with out any results…

I don’t use the ewelink integration here, purely AlexxIT/ SonoffLAN installed through HACS.

Inside configuration.yaml, sonoff-part (for TH10 & TH16):

  sonoff:
    username: !secret sonoff_usr
    password: !secret sonoff_pwd
    mode: local
    reload: always # update device list every time HA starts
    force_update: [temperature, power]
    scan_interval: '00:00:30' # (optional) default 5 minutes
    sensors: [temperature, humidity, power, current, voltage]

OK, Nice, thanks for the reply.

Here is the issue: When i add the mode: local i dont see temperatures. If i comment it, temps appeared.

Why is that?

Can you check my config and tell me whats wrong?

Might at “sensors” i must put my sensor names?

sonoff:
  username: [email protected]
  password: ****
  mode: local
  reload: always # update device list every time HA starts
  force_update: [temperature, power]
  scan_interval: '00:00:30' # (optional) default 5 minutes
  sensors: [temperature, humidity, power, current, voltage]

  # Example configuration.yaml entry
sensor:
  - platform: template
    sensors:

      water_temperature:
        friendly_name: 'Water Heater'
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('switch.sonoff_1001200fb3', 'temperature') }}"

      kitchen_radiator:
        friendly_name: 'Kitchen Temperature'
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('switch.sonoff_100114ad27', 'temperature') }}"

      kitchen_humidity:
        friendly_name: 'Kitchen Humidity'
        unit_of_measurement: '%'
        value_template: "{{ state_attr('switch.sonoff_100114ad27', 'humidity') }}"

      dining_room_radiator:
        friendly_name: 'Dining Room Temperature'
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('switch.sonoff_100114ad74', 'temperature') }}"

      dining_room_humidity:
        friendly_name: 'Dining Room Humidity'
        unit_of_measurement: '%'
        value_template: "{{ state_attr('switch.sonoff_100114ad74', 'humidity') }}"

      living_room_radiator:
        friendly_name: 'Living Room Temperature'
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('switch.sonoff_100114adcf', 'temperature') }}"

      living_room_humidity:
        friendly_name: 'Living Room Humidity'
        unit_of_measurement: '%'
        value_template: "{{ state_attr('switch.sonoff_100114adcf', 'humidity') }}"

      basement_temperature:
        friendly_name: 'Basement Temperature'
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('switch.sonoff_1000fde8f8', 'temperature') }}"

      basement_humidity:
        friendly_name: 'Basement Humidity'
        unit_of_measurement: '%'
        value_template: "{{ state_attr('switch.sonoff_1000fde8f8', 'humidity') }}"

Have you restarted HA after you made changes to configuration.yaml?

Also go to

Home Assistant --> Developer Tools and look for switch.sonoff_100114ad74. What is listed below “Attributes” for your switch?

Yes, i restart HA everytime after changes to the config file.

manufacturer: SONOFF
model: TH16
sw_version: PSA-BHA-GL v3.5.0
local: online
rssi: -71
unit_of_measurement: °C
friendly_name: Dining Room Radiator Temperature
device_class: temperature

After change mode: from cloud to local temperatures does not appear:

Screenshot 2021-11-12 at 13.19.10

Screenshot 2021-11-12 at 13.19.05

Your configuration looks OK to me. Under Attributes I am missing temperature, humidity etc. though.

Are you running AlexxIT/ SonoffLAN and the eWelink Integration in parallel? If so remove the eWelink Integration.

I only use AlexxIT/ SonoffLAN - not eWelink integration.

What i should check for temperature, humidity etc under Attributes?

Try the following in your configuration.yaml:

sonoff:
  username: [email protected]
  password: ****
  mode: local
  reload: always # update device list every time HA starts
  force_update: [currentTemperature, currentHumidity, voltage_00]
  scan_interval: '00:00:30' # (optional) default 5 minutes
  sensors: [currentTemperature, currentHumidity, voltage_00, rssi]
  devices:
    100114ad74:
       device_class: switch
       name: Sonoff TH16 
       devicekey: your-devicekey
       sensors: [currentTemperature, currentHumidity, rssi]