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

Added skipidentical support for ATC mode #74

Merged
merged 4 commits into from
Mar 12, 2021
Merged

Conversation

mvdklip
Copy link
Contributor

@mvdklip mvdklip commented Mar 4, 2021

Instead of single variables for the previous measurement and identical counter I changed the script to use dictionaries so that it can keep track of previous measurements and identical counters per sensor. I also fixed the instantiation of the previous measurement by making sure that the sensorname is being copied; otherwise the comparison between the current and previous measurement fails!

@JsBergbau
Copy link
Owner

Hi mvdklip,

thanks for your contribution.
I've seen that you've changed the identical measurement criteria so that voltage and battery may differ. Since this changes the previous behaviour it could brake or at least confuse users who update.
So when you change this back to previous behaviour I'd be glad to integrate your code.

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 10, 2021

Hi JsBergbau,

Thanks for noticing. Yes I did change the criteria because voltage constantly changes. For me including the voltage in the criteria effectively destroys the whole identical mechanism. Could you please test and see if you get more stable voltage readings? Does the identical mechanism work for you when including the voltage?

Example readings:

@400000006048c3e02e6eaa54 BLE packet: A4:C1:38:29:8D:59 00 1110161a18a4c138298d59009e31410ae8eb -85
@400000006048c3e02e71a024 Temperature: 15.8
@400000006048c3e02e71abdc Humidity: 49
@400000006048c3e02e72e074 Battery voltage: 2.792 V
@400000006048c3e02e74ad64 RSSI: -85 dBm
@400000006048c3e02e76f754 Battery: 65 %
@400000006048c3e02e7c1bbc
@400000006048c3ea3481101c BLE packet: A4:C1:38:29:8D:59 00 1110161a18a4c138298d59009e31410ae9ec -74
@400000006048c3ea348457f4 Temperature: 15.8
@400000006048c3ea34845fc4 Humidity: 49
@400000006048c3ea34857cec Battery voltage: 2.793 V
@400000006048c3ea3487a3b4 RSSI: -74 dBm
@400000006048c3ea348968d4 Battery: 65 %
@400000006048c3ea348e3f1c
@400000006048c3f438325464 BLE packet: A4:C1:38:29:8D:59 00 1110161a18a4c138298d59009e31410ae6ed -88
@400000006048c3f438357914 Temperature: 15.8
@400000006048c3f43837615c Humidity: 49
@400000006048c3f438387a9c Battery voltage: 2.79 V
@400000006048c3f438392a64 RSSI: -88 dBm
@400000006048c3f4383ae3cc Battery: 65 %
@400000006048c3f43840814c
@400000006048c3fe3b699a34 BLE packet: A4:C1:38:29:8D:59 00 1110161a18a4c138298d59009e31410ae6ee -74
@400000006048c3fe3b6c93ec Temperature: 15.8
@400000006048c3fe3b6c9bbc Humidity: 49
@400000006048c3fe3b6db8e4 Battery voltage: 2.79 V
@400000006048c3fe3b6f7a1c RSSI: -74 dBm
@400000006048c3fe3b71a0e4 Battery: 65 %
@400000006048c3fe3b7732ac
@400000006048c40e060d00ec BLE packet: A4:C1:38:29:8D:59 00 1110161a18a4c138298d59009e31410ae8ef -73
@400000006048c40e060f048c Temperature: 15.8
@400000006048c40e060f5e64 Humidity: 49
@400000006048c40e061077a4 Battery voltage: 2.792 V
@400000006048c40e0610d17c RSSI: -73 dBm
@400000006048c40e0611eabc Battery: 65 %
@400000006048c40e06160d54
@400000006048c4130767fd0c BLE packet: A4:C1:38:29:8D:59 00 1110161a18a4c138298d59009e31410ae6f0 -87
@400000006048c413076c797c Temperature: 15.8
@400000006048c413076c814c Humidity: 49
@400000006048c413076de4c4 Battery voltage: 2.79 V
@400000006048c413076f195c RSSI: -87 dBm
@400000006048c4130770bb54 Battery: 65 %
@400000006048c41307767fe4

You see how RSSI and voltage constantly change?

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 10, 2021

What if I would just put battery level back and leave the voltage out?

@JsBergbau
Copy link
Owner

Yes I've also noticed that with ATC Firmware voltage level changes quite often, definitvely much more than with original firmware. Since each voltage measurement uses a small amount of battery charge measuring voltage level too often is not a so good idea. I've planned to compile my own ATC firmware version with default measurement interval of 10 seconds, no switching between battery and humidity and a much longer battery measurement period, perhaps one hour or so. Haven't thought about much so far.
I think I can find time for that within the next month. Are you also interested in this custom ATC firmware?

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 10, 2021

I am personally using pvvx ATC firmware:
https://github.com/pvvx/ATC_MiThermometer

Disabling the (display) switching between battery and humidity is ease with that firmware. You can can just disable the 'Show batt.' option in the flasher.

Maybe you're better off contacting pvvx and asking whether the voltage reading interval can be reduced?

@JsBergbau
Copy link
Owner

You can also easily disable that in the original ATC/Telink flasher. However if battery is quite empty thermostat resets and the defaults are back. One of my thermostat shows 43 % battery level. However when connecting to change the interval and disabling battery indicator it reboots because maintaining the bluetooth connection seems to need to much energy.

What advantages has the pvvx firmware compared to original ATC firmware for you?

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 10, 2021

Main reason to use pvvx version for me is the ability to set a pincode so that i can prevent random strangers from connecting to my bluetooth devices. Also the fact that it's actively developed. Even atc himself recommends pvvx firmware instead. It should also offer better battery life than original atc firmware.

@JsBergbau
Copy link
Owner

Ok. I was confused with pvvx's version because his flasher https://pvvx.github.io/ATC_MiThermometer/TelinkMiFlasher.html doesn't show any options like changing interval compared to the original Telink flasher https://atc1441.github.io/TelinkFlasher.html

I'll give it definitively a try.

Since pvvx claims his version needs less power than original ATC version changing battery measurement intervall is a good idea.
I've opened an issue here pvvx/ATC_MiThermometer#72

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 10, 2021

Great! You think this PR can be merged now that I restored battery level as part of the identical check?

@JsBergbau
Copy link
Owner

Battery is measured every 10 seconds. Measuring needs 4 mA for 200 µs, this is on average 0,00008 mA. A CR2032 with 220 mAh would last for almost 314 years measuring battery. So changing this interval doesn't really change anything.
However I see that this frequent battery measurement can be problematic for skipidentical.

So how about conditional code: If in ATC mode --skipidentical doesn't consider voltage (and battery level?) but in connection mode it works like before.
Since --skipidentical didn't work so far with ATC mode we're now free to change it. So you may choose whether a different batterylevel is considered as change or not, like in your first pull request.

@mvdklip
Copy link
Contributor Author

mvdklip commented Mar 11, 2021

Added code for including the battery voltage when not in ATC mode.

@JsBergbau JsBergbau merged commit 0d3bbbd into JsBergbau:master Mar 12, 2021
@JsBergbau
Copy link
Owner

Thank you very much for your contribution and making this script even better.

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

Successfully merging this pull request may close these issues.

2 participants