Sonoff th10 with AM2301 temp\humidity sensor, not reading in HA

Hello All
Spent some time looking at this one, see several other threads that I have tried and also seemed to match DrZees had for a similar issue in one of his videos.
And this github thread, https://github.com/arendst/Sonoff-Tasmota/issues/1862

I have flashed the Sonoff with Tasmota (5.12.0) The temp and humidity show on the main page of the web browser and show in the console

16:51:44 MQT: tele/SoOTH/SENSOR = {“Time”:“2018-06-03T16:51:44”,“AM2301”:{“Temperature”:75.4,“Humidity”:51.0},“TempUnit”:“F”}

I have added the following to my configuration.yaml file (and every variation I can think of) and it dose not show up.
Here is my configuration.yaml file entry.

  - platform: mqtt
    state_topic: 'tele/SoOTH/SENSOR'
    name: "OS_Temp"
    unit_of_measurement: '°F'
    value_template: '{{ value_json.AM2301.temperature }}'

I do get an Icon with the “name” OS_Temp in the “Overview” web page and the “sensor.os_temp” shows on the states page with:
“sensor.os_temp unknown”

I do have several other mqtt topics that are working fine
Passwords seem to be fine (Compared to the other Sonoff’s)
Any Ideas?

value_template: “{{value_json[‘AM2301’].Temperature }}”

Hello
Tried your suggestion, gives me an error when I check the file

Hello
Your suggestion, also gives me an error when I check the file

This the code I use that works for mine,

- platform: mqtt
  name: "Office Temperature"
  state_topic: "tele/Office/SENSOR"
  value_template: "{{ value_json['AM2301'].Temperature }}"
  unit_of_measurement: "°C"

I think I have " " round the value template where as yours is ’ ’ not sure if that makes a difference.

1 Like

Here’s a direct copy and paste, I setup a Wemos with a BME280 and DHT22(AM3201) yesterday on a breadboard for comparison. This is from my sensor: block

  - platform: mqtt
    name: "Wemos1 Temp2"
    state_topic: "tele/wemos_tasmo1/SENSOR"
    value_template: "{{value_json['AM2301'].Temperature }}"
    qos: 0
    unit_of_measurement: "°F"  
  - platform: mqtt
    name: "Wemos1 Humidity2"
    state_topic: "tele/wemos_tasmo1/SENSOR"
    value_template: "{{value_json['AM2301'].Humidity }}"
    qos: 0
    unit_of_measurement: "%"  
    device_class: humidity
1 Like

Also another example I have with the LWT topic and reading the RSSI WiFi signal:

  - platform: mqtt
    state_topic: "tele/SNF-Sarah-Lamp/STATE"
    name: "SarahLamp RSSI"
    unit_of_measurement: "dBm"
    value_template: "{{value_json['Wifi'].RSSI }}"
    availability_topic: "tele/SNF-Sarah-Lamp/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"

Got to be something else, I tried this like a few suggested and nothing.

  • platform: mqtt
    name: “Out Side Temp”
    state_topic: “tele/SoOTH/SENSOR”
    value_template: “{{ value_json[‘AM2301’].Temperature }}”
    unit_of_measurement: ‘°F’
    It loads with no errors.

Humm
Could it be the MQTT password ? (I did try and reset it, didnt make a diff) Any one know of a addin or tool to look at the subscribe packets? I dont see any errors in the web console.

I do see this error in Hass.io

018-06-04 17:45:44 WARNING (MainThread) [homeassistant.setup] Setup of config is taking over 10 seconds.
2018-06-04 17:46:02 WARNING (SyncWorker_19) [netdisco.ssdp] Found malformed XML at http://192.168.1.16:9080: status=ok

But that IP is a Ruku

I got to go, that will be all for me tonight.

I’ve used MQTTx and then put something like tele/# should sub to all the things with tele/

One other thing… go to your Sonoff/Tasmota GUI on the device itself, click console and type in “status 0” and post the info it dumps out. Feel free to mask anything you that you feel is necessary. I want to make sure the config is setup correctly on the device.

Ok I copied the suggestion from Cee and modified it to match my topic and name
and saved it. I then watched it and it it appeared to have not made a difference.
I then searched on my phone for a MQTT app and found one called “MQTT Snoop” and installed it, i was able to put in my MQTT broker, user and password. I then could see all my traffic (Pretty cool) AND i could see the new device and info.
I then then went off to do something and when i checked back (@ 15 min) it had updated in HA… YES!!!
I think the issue (after i have fix my config file) was the broadcast delay, was it is set to update every 300 sec, so when I made the change I didn’t wait long enough.

Thanks for the help and suggestions…
Have an awesome day…
Mike…

1 Like

Awesome! You can update this with the teleperiod command on the console. Think you can go down to 10 seconds but really isn’t needed unless you have some crazy temp changes.

Hello, I know this thread has been marked as solved, so I wondering if someone can help with figure out what I missed.

I have the Sonoff th10/16 with tasmotta installed. Im trying to pull the temp data from the MQTT topic.

This is what it looks like in the console:

19:07:32 MQT: tele/3rdfloorAC/SENSOR = {"Time":"2018-07-08T19:07:32","AM2301":{"Temperature":75.2,"Humidity":49.5},"TempUnit":"F"}

this is my package code:

sensor:
  • platform: mqtt
    name: “3rd floor temp”
    state_topic: “tele/3rdfloorAC/SENSOR”
    qos: 0
    unit_of_measurement: “°F”

  • platform: mqtt
    name: “Office Temperature”
    state_topic: “tele/Office/SENSOR”
    value_template: “{{ value_json[‘AM2301’].Temperature }}”
    unit_of_measurement: “°F”

My output on the first sensor gives the fullt topic

{"Time":"2018-07-08T19:12:34","AM2301":{"Temperature":75.4,"Humidity":49.5},"TempUnit":"F"} °F

My second one which I copied exactly from here gives an Unknown. I even waited 45 min and reboot just in case it needed that time. But it stays as unknown.

Try this code,

- platform: mqtt
  name: "Office Temperature"
  state_topic: "tele/Office/SENSOR"
  value_template: "{{ value_json['AM2301'].Temperature }}"
  unit_of_measurement: "°C"

And adjust to you need’s. The code you pasted seems to have different quotes on it, “°F” These have caused me problems in the past, when I changed it to the "" ones it seemed to be fine.

The reason the first one is giving you the full topic, is because you haven’t a template to define what you want from the topic.

value_template: “{{ value_json[‘AM2301’].Temperature }}”

value_template: “{{ value_json[‘AM2301’].Humidity }}”

Use one for Temp, and one for Humidity,

- platform: mqtt
  name: "Office Temperature"
  state_topic: "tele/Office/SENSOR"
  value_template: "{{ value_json['AM2301'].Temperature }}"
  unit_of_measurement: "°C"
- platform: mqtt
  name: "Office Humidity"
  device_class: "humidity"
  state_topic: "tele/Office/SENSOR"
  value_template: "{{ value_json['AM2301'].Humidity }}"
  unit_of_measurement: "%"

Any problems, just shout.

Hi Cee

I’ve tried everything can seem to get this th10 sensor to pull the info into HA. I’ve copied your code from above and changed the topic only. But still no luck.

Any idea what i can check next?

can you post your code you are using, and the output from the console on the sonoff, should look something like this,

19:07:32 MQT: tele/3rdfloorAC/SENSOR = {"Time":"2018-07-08T19:07:32","AM2301":{"Temperature":75.2,"Humidity":49.5},"TempUnit":"F"}

Please make sure to use the code blocks, as listed at the top of each page, just copy the code you pasted, and hit the </> button above :slight_smile:

Ill do that tonight when i get home, I went as far to change my topic to the same as yours so i could just copy and past your code, yet no luck, but i will place my here later

Hi Cee, Below is my code copied out my config. I do have a !include sensor.xml if that makes any difference were the config is running from.

- platform: mqtt
  name: "Office Temperature"
  state_topic: "tele/Office/SENSOR"
  value_template: "{{ value_json['AM2301'].Temperature }}"
  unit_of_measurement: "°C"
- platform: mqtt
  name: "Office Humidity"
  device_class: "humidity"
  state_topic: "tele/Office/SENSOR"
  value_template: "{{ value_json['AM2301'].Humidity }}"
  unit_of_measurement: "%"
1 Like

could you also post this bit from the console on the sonoff, it will be available from the web interface.

I presume that is a typo, should be a .yaml file any extra config files.

Hi Cee, Yes that was n typo.
Here is the post from the devices console.
06:00:58 MQT: stat/office/STATUS10 = {“StatusSNS”:{“Time”:“2018-09-06T06:00:58”,“AM2301”:{“Temperature”:18.2,“Humidity”:41.2},“TempUnit”:“C”}}