esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

DHT sensor error when NAME in non-English characters #2028

Open IvanGavrilenko opened 3 years ago

IvanGavrilenko commented 3 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

core-2021.4.6 AND ESPHOME web server

ESP (ESP32/ESP8266, Board/Sonoff):

ESP8266 Wemos D1 mini ESPHome version (latest production, beta, dev branch)

C:\Users\ivan>esphome version Version: 1.16.2 Affected component:

https://esphome.io/components/sensor/dht.html

Description of problem: When attached DHT-11 sensor and if name section in sensor block consists of only English cahracters - then web server and HomeAssistant receives both values - temperature and humidity. But if the name section consists of only Russian characters then both web server and HomeAssistant show the single sensor (and web server shows name from temperature and value - from humidity - it looks like the temperature sensor obtains the value from the temperature and shows the temperature value and then after a part of second the humidity value is written to the same sensor and overwrites it's value).

Problem-relevant YAML-configuration entries:

PASTE YAML FILE HERE
#WORKING CONFIG
sensor:
  - platform: dht
    pin: D3
    temperature:
      name: Temperature #pay attantion to this name
      filters:
        - filter_out: nan
    humidity:
      name: Humidity #pay attantion to this name
      filters:
        - filter_out: nan
    update_interval: 20s

#CONFIG PRODUCING ERROR
sensor:
  - platform: dht
    pin: D3
    temperature:
      name: Температура #The error goes here 
      filters:
        - filter_out: nan
    humidity:
      name: Влажность #The error goes here 
      filters:
        - filter_out: nan
    update_interval: 20s

Logs (if applicable):

PASTE DEBUG LOG HERE
dht Web Server
States
Name    State   Actions
Температура 26 %    
Влажность       
See ESPHome Web API for REST API documentation.

OTA Update
Файл не выбран
Debug Log
[VV][scheduler:152]: Running interval 'update' with interval=20000 last_execution=36085 (now=56085)
[VV][scheduler:152]: Running interval 'update' with interval=20000 last_execution=36085 (now=56085)
[VV][dht:176]: Data: Hum=0b0001100100000000, Temp=0b0010000000001000, Checksum=0b01000001
[VV][dht:176]: Data: Hum=0b0001100100000000, Temp=0b0010000000001000, Checksum=0b01000001
[D][dht:048]: Got Temperature=32.8°C Humidity=25.0%
[V][sensor:013]: 'Температура': Received new state 32.799999
[VV][sensor.filter:013]: Filter(0x3fff27bc)::input(32.799999)
[VV][sensor.filter:013]: Filter(0x3fff27bc)::input(32.799999)
[VV][sensor.filter:020]: Filter(0x3fff27bc)::output(32.799999) -> SENSOR
[VV][sensor.filter:020]: Filter(0x3fff27bc)::output(32.799999) -> SENSOR
[D][sensor:092]: 'Температура': Sending state 32.80000 °C with 1 decimals of accuracy
[V][sensor:013]: 'Влажность': Received new state 25.000000
[VV][sensor.filter:013]: Filter(0x3fff291c)::input(25.000000)
[VV][sensor.filter:013]: Filter(0x3fff291c)::input(25.000000)
[VV][sensor.filter:020]: Filter(0x3fff291c)::output(25.000000) -> SENSOR
[VV][sensor.filter:020]: Filter(0x3fff291c)::output(25.000000) -> SENSOR
[D][sensor:092]: 'Влажность': Sending state 25.00000 % with 0 decimals of accuracy
[VV][scheduler:152]: Running interval '' with interval=10000 last_execution=46688 (now=56688)
[VV][scheduler:152]: Running interval '' with interval=10000 last_execution=46688 (now=56688)
[VV][scheduler:152]: Running interval '' with interval=10000 last_execution=56688 (now=66691)
[VV][scheduler:152]: Running interval '' with interval=10000 last_execution=56688 (now=66691)
[VV][scheduler:152]: Running interval 'update' with interval=20000 last_execution=56085 (now=76085)
[VV][scheduler:152]: Running interval 'update' with interval=20000 last_execution=56085 (now=76085)
[VV][dht:176]: Data: Hum=0b0001101000000000, Temp=0b0010000000001000, Checksum=0b01000010
[VV][dht:176]: Data: Hum=0b0001101000000000, Temp=0b0010000000001000, Checksum=0b01000010
[D][dht:048]: Got Temperature=32.8°C Humidity=26.0%
[V][sensor:013]: 'Температура': Received new state 32.799999
[VV][sensor.filter:013]: Filter(0x3fff27bc)::input(32.799999)
[VV][sensor.filter:013]: Filter(0x3fff27bc)::input(32.799999)
[VV][sensor.filter:020]: Filter(0x3fff27bc)::output(32.799999) -> SENSOR
[VV][sensor.filter:020]: Filter(0x3fff27bc)::output(32.799999) -> SENSOR
[D][sensor:092]: 'Температура': Sending state 32.80000 °C with 1 decimals of accuracy
[V][sensor:013]: 'Влажность': Received new state 26.000000
[VV][sensor.filter:013]: Filter(0x3fff291c)::input(26.000000)
[VV][sensor.filter:013]: Filter(0x3fff291c)::input(26.000000)
[VV][sensor.filter:020]: Filter(0x3fff291c)::output(26.000000) -> SENSOR
[VV][sensor.filter:020]: Filter(0x3fff291c)::output(26.000000) -> SENSOR
[D][sensor:092]: 'Влажность': Sending state 26.00000 % with 0 decimals of accuracy
[VV][scheduler:152]: Running interval '' with interval=10000 last_execution=66688 (now=76688)
[VV][scheduler:152]: Running interval '' with interval=10000 last_execution=66688 (now=76688)

Additional information and things you've tried: The screenshots of working config: Working HomeAssistant working web server

The screenshots of errous config: not working web server not working HomeAssistant

Complete YAMLs: YAML not working.txt YAML working.txt

Parts of VERY_VERBOSE logs containig sensor values obtainig: not working log.txt working log.txt

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

IvanGavrilenko commented 3 years ago

Any comments to the issue?

oxan commented 3 years ago

The problem here is that entities are internally identified by their "object id", which is the name with all non-Latin-alphanumericals stripped. Thus, the two sensors with only Russian characters in their name get the same object id.

IvanGavrilenko commented 3 years ago

The problem here is that entities are internally identified by their "object id", which is the name with all non-Latin-alphanumericals stripped. Thus, the two sensors with only Russian characters in their name get the same object id.

So may be not stripping non-english characters but adding transliteration to object id would be a good idea (as hame assistant does)?

oxan commented 3 years ago

So may be not stripping non-english characters but adding transliteration to object id would be a good idea (as hame assistant does)?

The problem with Unicode transliteration and things like that is that they require huge datatables, for which an ESP doesn't have enough space.

An additional complication is that the object id is also used to identify entities to Home Assistant, and changing them would mean that new entities are created for everyone.

IvanGavrilenko commented 3 years ago

Well may be I do not know the full procedure of firmware compilation, but may be just add to the computer ESPhome a sort of pre-compilation - before compiling *.yaml transliterate fields that form "object id" all strings "name: " and so on?