OpenWonderLabs / SwitchBotAPI-BLE

SwitchBot BLE open API
98 stars 9 forks source link

WoSensorTHO (Model W3400010) - I get wrong measures #36

Closed lorenzopiazzi closed 4 months ago

lorenzopiazzi commented 5 months ago

Current Situation

I'm trying retrieving temperature and humidity measures from the Sonoff WoSensorTHO (Model W3400010) using the parameters posted here: https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/latest/devicetypes/meter.md#outdoor-temperaturehumidity-sensor I'm using ESPHome and a ESP32 board. Unfortunately I get wrong values compared to the ones I can read from Switchbot official app in my smartphone. I think it might be because was not able to distinguish advertisments by data type. May you help me? thanks in advance!!

Logs

From ESPHome
[22:25:27][D][sensor:094]: 'Hygrometer': Sending state 72.00000 % with 1 decimals of accuracy
[22:25:27][D][sensor:094]: 'Thermometer': Sending state 0.80000 °C with 2 decimals of accuracy
[22:25:27][D][sensor:094]: 'RSSI': Sending state -58.00000 dB with 0 decimals of accuracy
[22:25:27][D][sensor:094]: 'Battery': Sending state -83.00000 % with 0 decimals of accuracy

Real values from app: thermometer: 20.2C° and humidity 40%

Configuration

sensor:
  - platform: template
    name: "Hygrometer"
    id: hygrometer
    unit_of_measurement: '%'
    accuracy_decimals: 1
    device_class: humidity
    icon: "mdi:water-percent"
  - platform: template
    name: "Thermometer"
    id: thermometer
    unit_of_measurement: '°C'
    device_class: temperature
    accuracy_decimals: 2
    icon: "mdi:thermometer"
  - platform: template
    name: "RSSI"
    id: rssi_meter
    unit_of_measurement: 'dB'
    device_class: signal_strength
    accuracy_decimals: 0
    icon: "mdi:bluetooth"
  - platform: template
    name: "Battery"
    id: battery_meter
    unit_of_measurement: '%'
    device_class: battery
    accuracy_decimals: 0
    icon: "mdi:battery"
esp32_ble_tracker:
  on_ble_advertise:
    - mac_address: D0:5B:64:8D:9C:0A # MAC address in lowercase
      then:
        - lambda: |-
            for (auto data : x.get_service_datas()) {
              float temperature = ((data.data[10] & 0x0F) * 0.1 + (data.data[11] & 0x7F)) ;
              if ((data.data[11] & 0x80) < 0) {
                  temperature = -temperature;
                }
              float humidity= data.data[12] & 0x7F;
              int8_t battery = data.data[5];
              int8_t rssi=x.get_rssi();
              id(hygrometer).publish_state(humidity);
              id(thermometer).publish_state(temperature);
              id(rssi_meter).publish_state(rssi);
              id(battery_meter).publish_state(battery);
            }

Environment

Additional Context

No response

github-actions[bot] commented 5 months 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.

lorenzopiazzi commented 5 months ago

hey there @SwitchBot-Wonderlabs , any clue?

github-actions[bot] commented 4 months 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.

github-actions[bot] commented 4 months ago

This issue has been automatically closed because it has not had recent activity. Thank you for your contributions.