Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return battery voltage, too #3

Open
opape opened this issue Aug 23, 2021 · 1 comment
Open

Return battery voltage, too #3

opape opened this issue Aug 23, 2021 · 1 comment

Comments

@opape
Copy link

opape commented Aug 23, 2021

Please extend the structure SensorDataBattery with the voltage of the battery. The value is already present in the code, but it is not returned in SensorDataBattery.

    def _process_sensor_data(self, data):
        temperature, humidity, voltage = struct.unpack_from('<hBh', data)
        temperature /= 100
        voltage /= 1000

        # Estimate the battery percentage remaining
        battery = min(int(round((voltage - 2.1),2) * 100), 100) # 3.1 or above --> 100% 2.1 --> 0 %
        self._data = SensorDataBattery(temperature=temperature, humidity=humidity, battery=battery)

Thanks

@afer92
Copy link

afer92 commented Feb 20, 2022

View lywsd03mmc fork. With AtcMiThermometerClient you can retrieve thermometers data without connecting. Limitations : can't get firmware and hardware revisions, can't get history.

from lywsd03mmc import AtcMiThermometerClient
client = AtcMiThermometerClient()

client.get_datas()

for thermometer in client.thermometers:
    print('----\n', thermometer) # print all data `

Result:

Discovered device a4:c1:38:xx:xx:xx
Discovered device a4:c1:38:yy:yy:yy
Device disconnected
Proceed...
Discovered device a4:c1:38:xx:xx:xx
Discovered device a4:c1:38:yy:yy:yy
Received new data from a4:c1:38:xx:xx:xx
----
 mac:   A4:C1:38:xx:xx:xx - ATC_xxxxxx
temp:   22.8 °C
hum:    37 %
batt:   86 %
volts:  2.98 V
rssi:   -54 dB
skip:   False
----
 mac:   A4:C1:38:yy:yy:yy - ATC_yyyyyy
temp:   21.7 °C
hum:    42 %
batt:   88 %
volts:  2.996 V
rssi:   -71 dB
skip:   False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants