Sonoff TH16, how to use it?

Hello,

i am using Home Assistant 2021.1.5 on a raspberyy pi 4 4gb.
My knowledge is practically 0 in this area. I did manage to connect my Ewelink (Sonoff account) to home assistant, with the Hacs integration + sonoff lan.
All the devices show up correctly, but the TH16 device is not recognised as a sensor but as a switch.

it shows a bunch of information on the right side of entity list:

manufacturer: SONOFF
model: TH16
sw_version: PSA-BHA-GL v3.4.1
local: online
cloud: online
rssi: -56
humidity: 42
temperature: 21.6
friendly_name: Thermometer
supported_features: 0

I’ve looked at templates for generic sensors but i really dont know what im doing.
Is there a way to extract the humidty and temperature from this device and show it in a Card?

thank you for your time

Hi there…welcome. there are two methods to achieve what you have asked for. The simplest method would be to create two template sensors from this and use then in the dashboard. In this method you can create template sensors by adding the following to config.

sensor:
  - platform: template
    sensors:
      sonoff_temperature:
        friendly_name: "Temperature"
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('<entity_id>', 'temperature') }}"
      sonoff_humidity:
        friendly_name: "Humidity"
        unit_of_measurement: '%'
        value_template: "{{ state_attr('<entity_id>', 'humidity') }}"

You can edit the name and other details of this configuration but dont forget to add the entity_id of this switch in the place I have mentioned <entity_id>. The entity id would be something like switch.<something>

After this you will have to restart your HA server and then you would see two new sensors with temperature and humidy. you can use this in dashboard.

Hi Sheminasalam,

Thank you so much for your help, i have added this code to the configuation file and replaced the <entity_id> with the sonof id. After the reboot it does show me the 2 icons for temperature and humidity, but it says unknown on the right side.

It says “t This entity (“sensor.sonoff_temperature”) does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail.”

what is the state of sensor.sonoff_temperature? Also please share the entity_id of the sonoff switch.

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') }}"
1 Like

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