Tasmota temp/hum sensor over MQTT

Hi. I’m trying to add manually Tasmota device(wemos D1 mini + sensor SHT3C)
The reason why I’m trying to do it manually is that my Wemos D1 is powered by CR123r battery and I will use DeepSleep option to reduce power consumption.
If I’m using Tasmota integration then each time device goes to DeepSleep all readings for temp/hum disappear as Tasmota sends MQTT message - LWT = Offline - and therefore all readings are showing “Unknown” during sleep time.
There is post on this forum and workaround is to add these sensors manually. Sounds easy?
If Im using Tasmota plugin all works fine:
image

This is my config:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml


mqtt:
  sensor:
    - name: "Temperature_001"
      state_topic: "tele/tasmota_866385/SENSOR"
      unit_of_measurement: '°C'
      value_template: "{{ value_json.temperature }}"
    - name: "Humidity_001"
      state_topic: "tele/tasmota_866385/SENSOR"
      unit_of_measurement: '%'
      value_template: "{{ value_json.humidity }}"

And this is the topic sent by Tasmota:

And that’s all I get
image

Where I’m making a mistake ??

ESPHome has native support for keeping your entities’ data available when in deep sleep. Give that a shot.

1 Like

You have to be exact.
in your screenshot, I see Temperature and Humidity, but in your definition you use value_json.temperature and value_json.humidity. Since these are not present in the json, you get unknown

mqtt:
  sensor:
    - name: "Temperature_001"
      state_topic: "tele/tasmota_866385/SENSOR"
      unit_of_measurement: '°C'
      value_template: "{{ value_json.Temperature }}"
    - name: "Humidity_001"
      state_topic: "tele/tasmota_866385/SENSOR"
      unit_of_measurement: '%'
      value_template: "{{ value_json.Humidity }}"
2 Likes

To be honest I didn’t realise that you can use SHTCx sensors in ESPhome and ESPhome has Deep Sleep option. This may be even better to configure than Tasmota. I’ll give it a go.

In the mean time I’ve found where was the error in my code.

Tasmota sends MQTT message in JSON format like that:

{"sn":{"Time":"2023-08-17T22:42:53","SHTC3":{"Temperature":26.3,"Humidity":55.7,"DewPoint":16.8},"TempUnit":"C"},"ver":1}

So my confing must be:

mqtt:
  sensor:
    - name: "Temperature_001"
      state_topic: "tele/tasmota_866385/SENSOR"
      unit_of_measurement: '°C'
      value_template: "{{ value_json.SHTC3.Temperature }}"
      unique_id: 'tasmota_866385'
    - name: "Humidity_001"
      state_topic: "tele/tasmota_866385/SENSOR"
      unit_of_measurement: '%'
      value_template: "{{ value_json.SHTC3.Humidity }}"
      unique_id: 'tasmota_866385_h'

And everything works fine now !
Thanks for your help.

Ive moved to ESHome which is actually easier and more flexible than Tasmota but…
Again, I’m back to same problem, my device is showing Unavailable status while deep sleeping.
image
Readings are going fine once device is awake:
image

This is my script:

esphome:
  name: outdoor01

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "****"

ota:
  password: ""

wifi:
  ssid: "***"
  password: "***"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Outdoor01 Fallback Hotspot"
    password: "2IgcpIOICgYP"



i2c:
  - sda: GPIO4
    scl: GPIO5
    id: bus_a
  
sensor:
  - platform: shtcx
    i2c_id: bus_a
    address: 0x70
      
    temperature:
      name: "Temperature-outdoor01"
      id: "temperature_outdoor01"
    humidity:
      name: "Humidity-outdoor01"
      id: "humidity_outdoor01"
    update_interval: 60s

deep_sleep:
  run_duration: 20s
  sleep_duration: 5min


captive_portal:

Is there any chance that HA will show(keep) last reading rather than displaying “Unavailable” ?