I’ve a problem with my SNBZB-02 sensörs. I’m using Sonoff Wifi bridge ( flash it with a tasmota)
a) Temperature values are sometimes updated for longer periods such as 1 hour. Is there a way to fix this with ZHA? Is this a problem or is it normal?
I think I have a device of the same model, goes by a couple names, TH01 by eWeLink Sonoff SNZB-02, attached to ZHA via a Tasmota Sonoff WiFi bridge, I am on HA 2021.12.10 with the Tasmota firmware shown below.
It reports on average about 4 times an hour, but does this interval consistently for me. I have found this to be too infrequent, as with most zigbee environmental sensors, so I have moved to BLE for these tasks, but that is a different topic. It does report more often, when there are changes, as shown by humidity chart and data from same period as temperature.
I have not seen any issues with it reporting in over a year of operation. It does have a quirk with ZHA, in that almost from day one, ZHA does not show any connections from it. If you look at the ZHA map, it just floats out there by itself, however, as I say it happily reports its temp, humidity and battery at regular intervals, see table of reports and charts below.
The whole world of Aqara and Sonoff battery powered devices in Zigbee seem pretty much all over the spectrum of success with most models of zigbee coordinators. This is unfortunate.
Program Version 9.2.0.1(zbbridge)
Build Date & Time 2020-12-23T17:57:10
Core/SDK Version 2_7_4_9/2.2.2-dev(38a443e)
with ncp-uart-sw-6.7.6_115200.ota
select
date_trunc('hour', last_updated),
count(1)
from states_archive where (
last_updated > now() - interval '1 day'
AND
entity_id = 'sensor.ewelink_th01_test_temperature')
group by 1;
select
date_trunc('hour', last_updated),
count(1)
from states_archive where (
last_updated > now() - interval '1 day'
AND
entity_id = 'sensor.ewelink_th01_test_humidity')
group by 1;
select
date_trunc('hour', last_updated),
count(1)
from states_archive where (
last_updated > now() - interval '1 day'
AND
entity_id = 'sensor.ewelink_th01_test_power')
group by 1;
Yes you’re right. It’s TH01. My HA version is 2022.03.5 and i’m using Tasmota firmware ( with ncp-uart-sw_6.7.8_115200 ) unfortunately in my case it is often impossible to get 4 updates every hour. Sometimes I get an update just every hour. Are you using BLE with HA? if yes how to add in HA? Meanwhile, humidity information is updated faster most of the time. I Sharing my update table. By the way red line is for my test ( I put it in the freezer for test and I saw that it was constantly updated in very short seconds, loooks like it only send updates over time when values are actually changing)
Yes, I have about 20 cheap BLE temperature/humidity sensors inside house, outside house and in fridge and freezers. I use a custom setup, using a Raspberry Pi to listen for the BLE sensor reports, then the Pi puts these in MQTT for digestion by HA. See link below for more info on my setup and sensor tests. Quite a number of people are successful with BLE addins directly attached to HA. If you search the discussion here, you will find a lot of info. Also people use espHome with one or more esp32 devices to do remote collection similar to what I do. Again search forum for lots of info.
Which every of the above three paths, I am pretty confident you will find better readings than ANY zigbee solution that is running without issues.
Back to your TH01 sensor. Again search the forums for the following. Some zigbee devices have the ability to be sent configuration commands. To the forum search, I believe some folks found that the TH01 has the ability to be configured for different sending periods of it’s reading. I think some folks might of found some improvement doing this but I am not sure, and never tried it. But you might give this a search and try, before you go down the rabbit hole of a BLE solution .
I concur, when the TH01 senses a rapid change in readings it sends more often, when things are steady state it does not send. I am pretty sure this behavior is out of the zigbee philosophy that longer battery life is a higher priority than number of readings. Back to BLE sensors, I have BLE sensors with CR2032 batteries and others with 2 AAA batteries, they have been sending 400 readings per hour for 2 years withOUT a battery change, so I’m not sure the zigbee battery life philosophy is really necessary in this scenario.
To your question on how to extract the raw readings from Home Assistant. HA stores all devices states in a SQLite database that HA calls the Recorder. You can query any of these values using the SQL language and a program (good free ones available) that can connect to the database.
First a WARNING. The default database engine that HA uses is SQLite. This is a very lightweight database engine and it is not very robust when more than one program accesses it’s data at a time.
So, as you are learning about the SQL language and your queries. I recommend that you shut down HA for a moment and copy the SQLite database to your local workstation. There you can play around with queries and not worry about messing up your HA system. File name is:
home-assistant_v2.db
Read more about HA Recorder at link below.
HA has the ability to store it’s Recorder database using more robust database engines. I use one called Postgresql. These ‘bigger’ database engines have no problem supporting multiple accesses to their data and as a result, you can get real time data from HA.
The SQL language queries I showed in my prior post, are a little more complex, this to get a count by hour of the number of sensor readings. But don’t be put off by the odd SQL language, there are lots of good resources on the web to get you going. And for the most part, the queries you need from HA are pretty basic. Once you get the tabular data out of HA via SQL, most of the work is on your spreadsheet or whatever tool you use to do your analysis. Below is a more simple example to just read the raw sensor readings out for the last 2 days from a BLE device in a freezer.
The SQL Query program I use is called TablePlus, link below. It has a free edition available on many different operating systems. I have had very good success with it. That said, there are a number of free SQL tools out on the interweb.
Good hunting!
--- simpler query to get all columns of data from the Home Assistant state table
SELECT
*
FROM
states
WHERE (entity_id = 'sensor.freezer_govee_temperature'
AND last_updated > now() - interval '2 days')
ORDER BY
last_updated DESC;
-- results saved to a .csv file for import into Excel
state_id,domain,entity_id,state,attributes,event_id,last_changed,last_updated,created,old_state_id
492592256,sensor,sensor.freezer_govee_temperature,7.8,"{""timestamp"":""20220319165047"",""mac-address"":""3F:46:0D:90:C0:FC"",""rssi"":-92,""temperature"":7.8,""units"":""F"",""temperature-celsius"":-13.4,""humidity"":70.4,""battery-pct"":100,""sensor-name"":"""",""location"":""H5052 Freezer"",""sensor-type"":""2"",""unit_of_measurement"":""\u00b0F"",""device_class"":""temperature"",""friendly_name"":""Freezer Govee Temperature""}",494743231,2022-03-19 09:50:47.106169-07,2022-03-19 09:50:47.106169-07,2022-03-19 09:50:47.106169-07,492592248
492592248,sensor,sensor.freezer_govee_temperature,7.7,"{""timestamp"":""20220319165047"",""mac-address"":""3F:46:0D:90:C0:FC"",""rssi"":-92,""temperature"":7.8,""units"":""F"",""temperature-celsius"":-13.4,""humidity"":70.4,""battery-pct"":100,""sensor-name"":"""",""location"":""H5052 Freezer"",""sensor-type"":""2"",""unit_of_measurement"":""\u00b0F"",""device_class"":""temperature"",""friendly_name"":""Freezer Govee Temperature""}",494743229,2022-03-19 09:49:31.108682-07,2022-03-19 09:50:47.105511-07,2022-03-19 09:50:47.105511-07,492592064
492592064,sensor,sensor.freezer_govee_temperature,7.7,"{""timestamp"":""20220319165032"",""mac-address"":""3F:46:0D:90:C0:FC"",""rssi"":-93,""temperature"":7.7,""units"":""F"",""temperature-celsius"":-13.5,""humidity"":70.3,""battery-pct"":100,""sensor-name"":"""",""location"":""H5052 Freezer"",""sensor-type"":""2"",""unit_of_measurement"":""\u00b0F"",""device_class"":""temperature"",""friendly_name"":""Freezer Govee Temperature""}",494743045,2022-03-19 09:49:31.108682-07,2022-03-19 09:50:32.106462-07,2022-03-19 09:50:32.106462-07,492592042
.
.
.
.
Thank you so much for detail informations. I’l check shared topics. By the way, I’m using HA on esxi as VM. Also i’m using mariadb for database. I think TablePlus also supporting mariadb, i’ll check it.