Giter Site home page Giter Site logo

wcbonner / goveebttemplogger Goto Github PK

View Code? Open in Web Editor NEW
157.0 15.0 25.0 3.47 MB

Govee H5074, H5075, H5100, H5101, H5104, H5105, H5174, H5177, H5179, H5181, H5182, and H5183 Bluetooth Low Energy Temperature and Humidity Logger

License: MIT License

C++ 87.71% Shell 0.25% HTML 1.69% C 8.77% CMake 1.58%
govee mrtg humidity-logger temperature-logger h5074 h5075 h5177 temperature linux h5183

goveebttemplogger's People

Contributors

hmblprogrammer avatar hummeltech avatar jamesderlin avatar reagan83 avatar rfjakob avatar wcbonner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goveebttemplogger's Issues

H5181 support? (like the H5182 but only one probe)

    I have a H5181 (like the H5182 but only one probe). Can I provide raw data to help decipher the information for that model?

It actually looks like it is working but just shows the second temp as 0.

2022-10-28 03:18:31     33      0       100     5183    -0.01
2022-10-28 03:18:34     33      0       100     5183    -0.01
2022-10-28 03:18:36     33      0       100     5183    -0.01
2022-10-28 03:23:38     29      0       100     5183    -0.01
2022-10-28 03:23:39     29      0       100     5183    -0.01
2022-10-28 03:23:42     29      0       100     5183    -0.01
2022-10-28 03:28:45     32      0       100     5183    -0.01
2022-10-28 03:28:48     32      0       100     5183    -0.01
2022-10-28 03:28:49     32      0       100     5183    -0.01

Originally posted by @thisgarryhas2rs in #36 (comment)

Support H5183 Meat Thermometer

I'm investigating if the meat thermometer announces temperatures or only reports via a direct connection. The announcements seem to be of two types. The H5183 was reporting 18°C when I captured these messages.

[2021-12-09T21:23:28] 42 [A4:C1:38:5D:A1:B4] (bdaddr_type) 00 (evt_type) 04 (Manu) 4C000215494E54454C4C495F524F434B535F48575075F2FF0C (Apple) (UUID) 494E54454C4C495F524F434B535F4857 (Major) 5075 (Minor) F2FF (RSSI) 0C

and

[2021-12-09T21:23:34] 46 [A4:C1:38:5D:A1:B4] (bdaddr_type) 00 (evt_type) 00 (UUID) 5183 (Flags) [LE Limited Discoverable Mode][LE General Discoverable Mode] (Manu) 5DA1B401000101E40180070813240000 (Other: 00) (Other: 00) (Other: 00) (Other: 00) (Other: 00) (Other: BE)

The first is interesting in its similarity to the H5177 thermometer message:

[2021-12-09T21:28:55] 42 [A4:C1:38:0D:3B:10] (bdaddr_type) 00 (evt_type) 04 (Manu) 4C000215494E54454C4C495F524F434B535F48575177F2FFC2 (Apple) (UUID) 494E54454C4C495F524F434B535F4857 (Major) 5177 (Minor) F2FF (RSSI) C2

Unfortunately the H5177 temperature message is significantly different.

[2021-12-09T21:28:55] 46 [A4:C1:38:0D:3B:10] (bdaddr_type) 00 (evt_type) 00 (Name) GVH5177_3B10 (UUID) 88EC (Flags) [LE Limited Discoverable Mode][LE General Discoverable Mode] (Manu) 0100010102B50930 (Temp) 17.7417°C (Humidity) 41.7% (Battery) 48%

--index {filepath} \ in service config causes service to exit directly after writing index file

using release arm binary https://github.com/wcbonner/GoveeBTTempLogger/releases/tag/v2.20231001.1.

I would expect to be able to use --index within the service to automatically add new devices to my svg-dashboard.

Instead it restarts after writing the files. It is not listening.

Log V2 with --index in service config:

Oct 16 08:11:38 energy goveebttemplogger[13149]: [2023-10-16T06:11:38] Writing: "/var/www/html/goveebttemplogger/index.html"
Oct 16 08:11:38 energy goveebttemplogger[13149]: [2023-10-16T06:11:38] Writing: A4C1380611DD
Oct 16 08:11:38 energy goveebttemplogger[13149]: [2023-10-16T06:11:38] Done
Oct 16 08:11:41 energy systemd[1]: Stopped GoveeBTTempLogger service.
Oct 16 08:11:41 energy systemd[1]: Starting GoveeBTTempLogger service...
Oct 16 08:11:41 energy systemd[1]: Started GoveeBTTempLogger service.
Oct 16 08:11:41 energy goveebttemplogger[13181]: [2023-10-16T06:11:41] Reading: "/var/log/goveebttemplogger"
Oct 16 08:11:41 energy goveebttemplogger[13181]: [2023-10-16T06:11:41] Writing: "/var/www/html/goveebttemplogger/index.html"
Oct 16 08:11:41 energy goveebttemplogger[13181]: [2023-10-16T06:11:41] Writing: A4C1380611DD
Oct 16 08:11:41 energy goveebttemplogger[13181]: [2023-10-16T06:11:41] Done
Oct 16 08:11:46 energy systemd[1]: goveebttemplogger.service: Service hold-off time over, scheduling restart.
Oct 16 08:11:46 energy systemd[1]: Stopped GoveeBTTempLogger service.
Oct 16 08:11:46 energy systemd[1]: Starting GoveeBTTempLogger service...
Oct 16 08:11:46 energy systemd[1]: Started GoveeBTTempLogger service.
Oct 16 08:11:46 energy goveebttemplogger[13243]: [2023-10-16T06:11:46] Reading: "/var/log/goveebttemplogger"
Oct 16 08:11:46 energy goveebttemplogger[13243]: [2023-10-16T06:11:46] Writing: "/var/www/html/goveebttemplogger/index.html"
Oct 16 08:11:46 energy goveebttemplogger[13243]: [2023-10-16T06:11:46] Writing: A4C1380611DD
Oct 16 08:11:46 energy goveebttemplogger[13243]: [2023-10-16T06:11:46] Done

the index file contens is correct. After removing --index from service config, everything runs properly.

Thanks for this great tool ! - I use it on raspy 3 :-)

gvh-titlemap parsing error?

I just downloaded and built the tool on ubuntu 20.10 on a Raspberry Pi 4. If I have no gvh-titlemap.txt file in my svg folder, it runs correctly. It downloads data, it writes logs, it creates SVGs, everything's great.

I made a gvh-titlemap.txt file that contains the following 2 lines. First one is from the sample file you provide, the other is my own.

A4:C1:38:0D:3B:10       H5177 (A4:C1:38:0D:3B:10)
A4:C1:38:49:F7:5A       Humidor (A4:C1:38:49:F7:5A)

There is an extra blank line at the end of the file. I invoke the command like this:
sudo /usr/local/bin/goveebttemplogger -v 2 -l /home/paco/humidor -s /home/paco/humidor

I see this error output.

[2021-02-09T13:52:39] GoveeBTTempLogger Version 2.20210202-1 Built on: Feb  8 2021 at 20:06:08
[2021-02-09T13:52:39] Reading: /home/paco/humidor/gvh-titlemap.txt
[2021-02-09T13:52:39] Reading: /home/paco/humidor/gvh-titlemap.txt
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
Aborted

I copied your example gvh-titlemap.txt unmodified into my directory. Should be harmless (it won't have a title for my device, but that shouldn't matter, right?) I get the same result.

If I remove the file, it runs fine, but if the file is present I get this error.

Excessive CPU use on Raspberry Pi 3

Howdy!

I was trying to set up GoveeBTTempLogger on the Pi3 I am currently using as an octoprint server (to monitor my filament storage humidity), and I got everything working well, except for one problem -- it uses up a steady 20% of the pi's CPU! This seems a bit excessive, just to be able to write out a few stats to a file once a minute! And on a device that needs to be fairly responsive (due to driving real hardware), this is not ideal.

A quick trace of the process suggests that it is in a fairly tight loop of trying to read from the HCI socket, getting EAGAIN (presumably a nonblocking socket), sleeping for a very short period of time, and repeating. Quick back-of-the envelope math says it's doing this ~10000 times/second.

Is there any way GoveeBTTempLogger could be updated to either use blocking reads (with timeouts for doing things like updating graphs and such, if those features are enabled), or to poll at a much slower rate than it is currently doing? I would really like to be able to use this software!

This is using the provided .deb package, build 2.20210405-2

Thanks!

2037 dates in SVG creation

I have seen a problem on a 32 bit system where the SVG files are skewed with strange data and dates from the year 2037. that date is not written in any of the logs, just the SVG files.

wim@FlightTracker:~ $ uname -a
Linux FlightTracker 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l GNU/Linux

Copying the logs to a 64 bit release on the same network and things work properly:

pi@piCam:~ $ uname -a
Linux piCam 5.15.84-v8+ #1613 SMP PREEMPT Thu Jan 5 12:03:08 GMT 2023 aarch64 GNU/Linux

Failing on ubuntu 22.04 (linux mint 21) - LE Set Scan Parameters Command Disallowed

Hello,

I am facing trouble trying to make goveebttemplogger work, may be because of latest change in bluetooth stack.
The issue happens on first call of hci_le_set_scan_parameters(device_handle, 0x01, htobs(0x0012), htobs(0x0012), 0x01, 0x00, 1000)
and it is failing with error : Error: Failed to set scan parameters: Input/output error due to the action being disallowed (see btmon trace below).

On the other side I am able to complete a manual le scan with bluetoothctl on the very same host and see my Govee devices.

So to me it looks very much like this issue where bluetoothctl works but not hcitools.

It seems people recommend to do a hci_reset before see 1 & 2.
Yet I don't understand how the code should be change to have a succesfull bluetooth initialisation - I tried my own code, but it fail the same. I am completely new to bluetooth stack, so can help much more.

Regards,

Yves

PS:

uname -a

Linux yves-huv 5.19.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 15 12:05:40 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

$ sudo GoveeBTTempLogger output

2023-02-04T15:41:36] GoveeBTTempLogger Version 2.20221220-1 Built on: Feb  3 2023 at 13:10:48
[2023-02-04T15:41:36] LocalName: yves-huv
[2023-02-04T15:41:36] No BlueTooth Address Filter: [00:00:00:00:00:00]
[                   ] Error: Failed to set scan parameters: Input/output error
GoveeBTTempLogger Version 2.20221220-1 Built on: Feb  3 2023 at 13:10:48 (exiting)

btmon output

Bluetooth monitor ver 5.64
= Note: Linux version 5.19.0-28-generic (x86_64)                                                           0.395741
= Note: Bluetooth subsystem version 2.22                                                                   0.395747
= New Index: CC:D9:AC:C3:14:A4 (Primary,USB,hci0)                                                   [hci0] 0.395749
= Open Index: CC:D9:AC:C3:14:A4                                                                     [hci0] 0.395750
= Index Info: CC:D9:AC:C3:14:A4 (Intel Corp.)                                                       [hci0] 0.395751
@ MGMT Open: bluetoothd (privileged) version 1.22                                                 {0x0001} 0.395753
@ RAW Open: goveebttemplogg (privileged) version 2.22                                             {0x0002} 4.406850
@ RAW Close: goveebttemplogg                                                                      {0x0002} 4.406864
@ RAW Open: goveebttemplogg (privileged) version 2.22                                      {0x0002} [hci0] 4.406883
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                           #1 [hci0] 4.406916
        Scanning: Disabled (0x00)
        Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                      #2 [hci0] 4.525500
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Command Disallowed (0x0c)
< HCI Command: Read Local Name (0x03|0x0014) plen 0                                              #3 [hci0] 4.525746
> HCI Event: Command Complete (0x0e) plen 252                                                    #4 [hci0] 4.530529
      Read Local Name (0x03|0x0014) ncmd 1
        Status: Success (0x00)
        Name: yves-huv
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7                                       #5 [hci0] 4.530891
        Type: Active (0x01)
        Interval: 11.250 msec (0x0012)
        Window: 11.250 msec (0x0012)
        Own address type: Random (0x01)
        Filter policy: Accept all advertisement (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                      #6 [hci0] 4.532440
      LE Set Scan Parameters (0x08|0x000b) ncmd 1
        Status: Command Disallowed (0x0c)
@ RAW Close: goveebttemplogg                                                               {0x0002} [hci0] 4.532637

Question: Celsius or Fahrenheight?

Just pulled the latest code since I saw some errors in the log after some security updates. I noticed my output has switched to Celsius. Is there an option to determine output?

2020-12-03 02:10:13 67.1729 40.5 89
2020-12-03 02:11:02 67.1729 40.5 89
2020-12-15 13:56:55 20.0346 34.6 86
2020-12-15 13:56:57 20.0345 34.5 86

Abort on Default SystemD Unit on Ubuntu 20.04 and Raspberry Pi OS (Latest)

@raspberrypi:~/GoveeBTTempLogger/GoveeBTTempLogger/usr/local/bin $ sudo ./goveebttemplogger -v 1 --log /var/log/goveebttemplogger --time 60 --svg /var/www/html/goveebttemplogger/ --battery 8 --minmax 8 --titlemap /var/www/html/goveebttemplogger/gvh-titlemap.txt
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::erase: __pos (which is 47) > this->size() (which is 32)
Aborted

It seems like the trailing / on the --svg directory is what causes the crash. I'm documenting here and will try putting my C++ hat on to submit a follow up pull request. (It's been awhile since I've written C++, so bear with me... 😁)

Bluetooth: hci0: advertising data len corrected 31 -> 29

I'd been getting a tone of these messages in Syslog ever since I switched to the "select" method of retrieving bluetooth announcements.

The behavior appeared on both PiZeroW and Pi4 units in my home environment, but did not appear at locations in friends houses I've got the same software running. I assumed that the problem was do to something strange in my apartment wireless environment. I live in a dense apartment block with plenty of neighbors.

Systemd unit arguments are not configurable

I want to use the systemd unit but I d not want to have an SVG file. It would be nice if I could configure the systemd unit easily without needing to overwrite the entire command line

Temperature for H5075 slightly wrong

The temperature for the H5075 is not correct, but the error is less than 0.1 °C. The problem is that the humidity is included in the temperature. You can see it in the example in the code: "88ec00 03519e 64 00 Temp: 21.7502°C Temp: 71.1504°F Humidity: 50.2%"

The last three digits in the temperature (Celsius) are the same digits as in the humidity. It seems to me that the description in https://github.com/Thrilleratplay/GoveeWatcher is not correct. To get correct values I changed
"Temperature[0] = float(iTemp) / 10000.0;" to "Temperature[0] = float(iTemp/1000) / 10.0;"

Problems restarting after editing configuration file

Hi,

I'm haveing problems starting the GoveeBTTempLogger after editing the configuration file. I'm running this on a Pi 4B

    description: Computer
    product: Raspberry Pi 4 Model B Rev 1.4
    serial: 10000000e23f0xxx
    width: 64 bits

Basically I get the following error when restarting:

○ goveebttemplogger.service - GoveeBTTempLogger service
     Loaded: bad-setting (Reason: Unit goveebttemplogger.service has a bad unit file setting.)
    Drop-In: /etc/systemd/system/goveebttemplogger.service.d
             └─override.conf
     Active: inactive (dead)

Feb 08 10:03:05 eigg systemd[1]: goveebttemplogger.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.

any Idea?

BR
Yonz

Below is the complete log of my build / installation and attempt to run the Program.

Goove BT Templogger - Setup

Build and Installation

Build

yonz@eigg:~ $ git clone https://github.com/wcbonner/GoveeBTTempLogger.git
Cloning into 'GoveeBTTempLogger'...
remote: Enumerating objects: 1936, done.
remote: Counting objects: 100% (654/654), done.
remote: Compressing objects: 100% (187/187), done.
remote: Total 1936 (delta 486), reused 603 (delta 448), pack-reused 1282
Receiving objects: 100% (1936/1936), 3.22 MiB | 10.31 MiB/s, done.
Resolving deltas: 100% (1039/1039), done.
yonz@eigg:~ $ cd GoveeBTTempLogger/
yonz@eigg:~/GoveeBTTempLogger $ ls
att-types.h  BTData          CMakePresets.json  goveebttemplogger.cpp      GoveeBTTempLogger.sln      goveebttemplogger-version.h.in  gvh-E35ECC215C0F-year.svg  gvh-titlemap.txt  LICENSE    postinst  prerm      uuid.c  wimiso8601.cpp
BLEScanning  CMakeLists.txt  DeviceImages       goveebttemplogger.service  GoveeBTTempLogger.vcxproj  gvh-E35ECC215C0F-day.svg        gvh-organizelogs.cpp       index.html        mrtg.conf  postrm    README.md  uuid.h  wimiso8601.h
yonz@eigg:~/GoveeBTTempLogger $ cd ..
yonz@eigg:~ $ cmake -S GoveeBTTempLogger -B GoveeBTTempLogger/build
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Components to pack: 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yonz/GoveeBTTempLogger/build
yonz@eigg:~ $ cmake --build GoveeBTTempLogger/build
[ 14%] Building CXX object CMakeFiles/goveebttemplogger.dir/goveebttemplogger.cpp.o
[ 28%] Building C object CMakeFiles/goveebttemplogger.dir/uuid.c.o
[ 42%] Building CXX object CMakeFiles/goveebttemplogger.dir/wimiso8601.cpp.o
[ 57%] Linking CXX executable goveebttemplogger
Setting Raw Priveleges on $<TARGET_FILE:goveebttemplogger>
[ 57%] Built target goveebttemplogger
[ 71%] Building CXX object CMakeFiles/gvh-organizelogs.dir/gvh-organizelogs.cpp.o
[ 85%] Building CXX object CMakeFiles/gvh-organizelogs.dir/wimiso8601.cpp.o
[100%] Linking CXX executable gvh-organizelogs
[100%] Built target gvh-organizelogs
yonz@eigg:~ $ pushd GoveeBTTempLogger/build && cpack . && popd
~/GoveeBTTempLogger/build ~
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: GoveeBTTempLogger
CPack: - Install project: GoveeBTTempLogger []
CPack: Create package
CPackDeb: - Generating dependency list
CPack: - package: /home/yonz/GoveeBTTempLogger/build/goveebttemplogger_2.20240203.1-1_arm64.deb generated.

Installation

Note: I did a sudo reboot before and after the installation

:~ $ sudo apt install ./GoveeBTTempLogger/build/goveebttemplogger_2.20240203.1-1_arm64.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'goveebttemplogger' instead of './GoveeBTTempLogger/build/goveebttemplogger_2.20240203.1-1_arm64.deb'
The following package was automatically installed and is no longer required:
  rtimucli
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  goveebttemplogger
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/267 kB of archives.
After this operation, 1,019 kB of additional disk space will be used.
Get:1 /home/yonz/GoveeBTTempLogger/build/goveebttemplogger_2.20240203.1-1_arm64.deb goveebttemplogger arm64 2.20240203.1-1 [267 kB]
Selecting previously unselected package goveebttemplogger.
(Reading database ... 249380 files and directories currently installed.)
Preparing to unpack .../goveebttemplogger_2.20240203.1-1_arm64.deb ...
Unpacking goveebttemplogger (2.20240203.1-1) ...
Setting up goveebttemplogger (2.20240203.1-1) ...
 HI I'M A POSTINST SCRIPT 1707352180
Created symlink /etc/systemd/system/multi-user.target.wants/goveebttemplogger.service → /usr/local/lib/systemd/system/goveebttemplogger.service.
N: Download is performed unsandboxed as root as file '/home/yonz/GoveeBTTempLogger/build/goveebttemplogger_2.20240203.1-1_arm64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
~ $

Edit Config File

with sudo systemctl edit goveebttemplogger.service
Just wanted to add --celsius

## Editing /etc/systemd/system/goveebttemplogger.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Unit]
Description=GoveeBTTempLogger service
After=bluetooth.target dbus-org.bluez.service network-online.target
Requires=bluetooth.target
StartLimitBurst=5
StartLimitIntervalSec=33

[Service]
Type=simple
Restart=always
RestartSec=5
ExecStartPre=/bin/mkdir -p /var/log/goveebttemplogger
ExecStartPre=/bin/mkdir -p /var/www/html/goveebttemplogger
ExecStartPre=/bin/mkdir -p /var/cache/goveebttemplogger

ExecStart=/usr/local/bin/goveebttemplogger \
    --verbose 0 \
    --log /var/log/goveebttemplogger \
    --time 60 \
    --celsius \
    --svg /var/www/html/goveebttemplogger --battery 4 --minmax 8 \
    --cache /var/cache/goveebttemplogger \
    --download
KillSignal=SIGINT

### Lines below this comment will be discarded

Restart Service

with sudo systemctl restart goveebttemplogger

○ goveebttemplogger.service - GoveeBTTempLogger service
     Loaded: bad-setting (Reason: Unit goveebttemplogger.service has a bad unit file setting.)
    Drop-In: /etc/systemd/system/goveebttemplogger.service.d
             └─override.conf
     Active: inactive (dead)

Feb 08 10:03:05 eigg systemd[1]: goveebttemplogger.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.

Single output option flag

Background: I'm trying to control my electric smoker with a smart plug depending on the temperature of the meat probe. Getting a single reading output would be handy for this.

Question: Is there a way to program an option flag to just output the current temperature? Or maybe an array of temperatures if there are multiple probes?

Thoughts: -r (--readings) Outputs a json key-value pairs for each reading

temp values are wrong for negative temperatures

temperature and humidity data is wrong for negative temperature data ( tested using cold spray to generate - C)
Any temperature < 0 gives VERY large positive temp numbers

spend some time to figure out the 2 complement but it is not that simple.
The data for the 3bytes + 1 (3 bytes for temp and humidity split at 1000) does not lead to a simple if data > xx: data -= yy

the one with 2 bytes for temp and 2 bytes for hum is a simple 2 complement for temp (hum is never negative)

No rule to make target 'deb'

I'm unable to complete the install of goveebttemplogger.service as you can see below.
On my Raspberry Pi 4 Model B Rev 1.5
I'm running:
Linux HomePi 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux

pi@HomePi:~ $ sudo apt-get install bluetooth bluez libbluetooth-dev
make deb
sudo make install-deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
bluetooth is already the newest version (5.55-3.1+rpt2).
bluez is already the newest version (5.55-3.1+rpt2).
libbluetooth-dev is already the newest version (5.55-3.1+rpt2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
make: *** No rule to make target 'deb'. Stop.
make: *** No rule to make target 'install-deb'. Stop.

Not sure where to go from here... Thanks

Add some ability to make filenames friendlier

Currently GoveeBTTempLogger generates files named after the devices' Bluetooth address. This makes inspecting the .log file for a particular device rather awkward if there are many devices with similar addresses. It would be nice if there were a mechanism to change the filenames.

Proposal:

  1. Allow gvh-titlemap.txt to live in /usr/local/etc (possibly with a different filename, e.g. goveetemplogger-devices.conf). For backward compatibility, GoveeBTTempLogger could additionally check for gvh-titlemap.txt in the SVG output directory first.
  2. Add a command-line argument (e.g. --map-filenames) to enable naming files using the mapping file. (I'd personally prefer enabling it by default, but forcing users to opt-in is okay with me for the sake of compatibility.)
  3. To avoid filename collisions, the actual filenames would be of the form TITLE (ADDRESS). For example: Outside (E35ECC215C0F).{log,svg}.

If the above sounds good and if you don't foresee any major obstacles, I'm willing to try to implement it.

Input/Output Error Starting GoveeBTTempLogger

Not sure if this is something I missed, but following the instructions with my Pi ZeroW, I'm seeing this error in the syslog:

Sep  1 10:34:07 picam systemd[1]: Starting GoveeBTTempLogger service...
Sep  1 10:34:07 picam systemd[1]: Started GoveeBTTempLogger service.
Sep  1 10:34:07 picam goveebttemplogger[2763]: GoveeBTTempLogger Version 2.20230831-1 Built on: Sep  1 2023 at 10:21:02 (starting)
Sep  1 10:34:07 picam goveebttemplogger[2763]: [                   ] Error: Failed to enable scan: Input/output error (5)
Sep  1 10:34:07 picam goveebttemplogger[2763]: GoveeBTTempLogger Version 2.20230831-1 Built on: Sep  1 2023 at 10:21:02 (exiting)
Sep  1 10:34:07 picam systemd[1]: goveebttemplogger.service: Succeeded.

hciconfig seems to work:

/var/log $ hciconfig
hci0:	Type: Primary  Bus: UART
	BD Address: B8:27:EB:97:50:9E  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING
	RX bytes:5850 acl:0 sco:0 events:180 errors:0
	TX bytes:3245 acl:0 sco:0 commands:180 errors:0

and

sudo hcitool lescan
LE Scan ...
40:8F:ED:C6:8F:21 (unknown)
6C:D2:AC:27:A8:1E (unknown)
7E:E9:C2:B5:1D:A5 (unknown)
A4:C1:38:E4:3F:C8 GVH5075_3FC8
A4:C1:38:E4:3F:C8 (unknown)
67:59:9D:3B:C6:DE (unknown)
67:59:9D:3B:C6:DE (unknown)
71:9C:12:F9:16:AB (unknown)
5E:92:F2:D6:2B:C6 (unknown)
2F:CC:2E:CC:29:37 (unknown)
6F:29:8A:E4:DF:9C (unknown)
6F:29:8A:E4:DF:9C (unknown)

Not sure what the IO error is, though I noticed that hcitool lescan fails with Operation Not Permitted, if that's relevant...

Any suggestions?

Remove postbuild step from CMakeLists with build flag

Hi there, thank you for developing this awesome application!

I wrote a guix package for the latest release:

(define-public goveebttemplogger
  (package
    (name "goveebttemplogger")
    (version "2.20231001.1")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "https://github.com/wcbonner/GoveeBTTempLogger/archive/refs/tags/v"
             version ".tar.gz"))
       (sha256
        (base32 "00hsyxz6v0ksq4x6199hv0da5rg4z6s9g7vnkw3r1yfv9cc8j7xx"))
       (patches (search-patches "goveebttemplogger-postbuild-sudo-fix.patch"))))
    (build-system cmake-build-system)
    (inputs (list bluez))
    (home-page "https://github.com/wcbonner/GoveeBTTempLogger")
    (synopsis "Temperature and Humidity Logger for Goove devices")
    (description
     "Govee H5074, H5075, H5100, H5174, H5177, H5179, 
H5181, H5182, and H5183 Bluetooth Low Energy Temperature and Humidity Logger")
    (license license:expat)))

I had to make a couple of changes for this to work:

  • remove POST_BUILD, not sure what's best practive here, but since this may be build on a computer that will not run it, this may be undesired (sudo setcap 'cap_net_raw,cap_net_admin+eip'...). In my case it failed because the build does not allow side-effects.
  • install to ${CMAKE_INSTALL_PREFIX}/..

Here's the diff with which I can build successfully:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c2b3f35..4902d97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,11 +37,11 @@ target_include_directories(goveebttemplogger PUBLIC
                            ${EXTRA_INCLUDES}
                            )
 
-add_custom_command(TARGET goveebttemplogger POST_BUILD
-    COMMAND sudo setcap 'cap_net_raw,cap_net_admin+eip' $<TARGET_FILE:goveebttemplogger>
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-    COMMENT "Setting Raw Priveleges on $<TARGET_FILE:goveebttemplogger>"
-)
+# add_custom_command(TARGET goveebttemplogger POST_BUILD
+#     COMMAND sudo setcap 'cap_net_raw,cap_net_admin+eip' $<TARGET_FILE:goveebttemplogger>
+#     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+#     COMMENT "Setting Raw Priveleges on $<TARGET_FILE:goveebttemplogger>"
+# )
 
 add_executable(gvh-organizelogs gvh-organizelogs.cpp goveebttemplogger-version.h)
 target_link_libraries(gvh-organizelogs -lbluetooth -lstdc++fs)
@@ -62,12 +62,12 @@ add_test(NAME gvh-organizelogs COMMAND gvh-organizelogs --help)
 
 install(TARGETS goveebttemplogger gvh-organizelogs
     DESTINATION bin
-    RUNTIME DESTINATION "/usr/local/bin/"
-    LIBRARY DESTINATION "/usr/local/lib/"
+    RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
+    LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
 )
 
 install(FILES goveebttemplogger.service
-    DESTINATION "/usr/local/lib/systemd/system"
+    DESTINATION "${CMAKE_INSTALL_PREFIX}/systemd/system"
     COMPONENT "goveebttemplogger"
 )

I'm not too familiar with cmake. I guess this should be adjustable with build flags?

Feature Request: Push Values on to a MQTT Queue

Hi,

I'm working on a remote data logger, that logs data from my Govee sensors. I would like have the RPI put the values read at a certain interval on to a MQTT queue.

I'm not a CPP developer, so I can't implement it myself and submit a pull request for a patch.

I did look into it, though, and using the Eclipse Paho Library and a few new parameters this should be a straight forward thing to do...

Parameters

[MQTT]
MQTT_URI=myserver.athome.com  
MQTT_PORT=1883 
MQTT_Username=myMQTTuser
MQTT_Password=myMQTTpassword
MQTT_TOPIC_PREFIX=goveebttemplogger
MQTT_INTERVAL=300

The routine should then every MQTT_INTERVAL seconds send the latest reading from each device as a JSON payload to the MQTT Topic: MQTT_TOPIC_PREFIX/<<Mac Address of Device>> (or use the filename prefix used for the log files, for consistency)

JSON Payload

{
  "temperature": 23.20,
  "humidity": 43.70,
  "battery": 100
}

On the other end we can then use e.g. Home Assistant's MQTT Sensor to process the data

Example Home Assistant configuration.yaml entry

mqtt:
  sensor:
    - name: "Temperature"
      state_topic: "goveebttemplogger/gvh-A4C13876CCXX"
      suggested_display_precision: 1
      unit_of_measurement: "°C"
      value_template: "{{ value_json.temperature }}
    - name: "Humidity"
      state_topic: "goveebttemplogger/gvh-A4C13876CCXX"
      unit_of_measurement: "%"
      value_template: "{{ value_json.humidity }}"
    - name: "Battery"
      state_topic: "goveebttemplogger/gvh-A4C13876CCXX"
      unit_of_measurement: "%"
      value_template: "{{ value_json.battery }}"

(Note: This config is just a basic template, needs to be tuned to the respective HA installation)

Just a thought.....

Best regards,
Yonz

H5179?

Does this work with H5179? I'm not getting any BLE readings, so was just wondering.

Daylight savings time - not changing timestamp

I'm in the UK and the clocks went forward at the weekend.
The output from the GoveeBTTempLogger doesn't reflect the system time and is now an hour behind.
Is there a way to get the program to change the logged time according to the actual system time?

Only thing I've tried so far is to restart the service, and the output remains 1 hour behind.

Or is the time set on the device?

PI3 Ubuntu Install Failed

Trying to install but running into dependancy and cannot locate this specifc armhf for libluetooth3

ubuntu@ubuntu:~/GoveeBTTempLogger$ sudo apt-get install bluetooth bluez libbluetooth-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
bluez is already the newest version (5.53-0ubuntu3).
libbluetooth-dev is already the newest version (5.53-0ubuntu3).
bluetooth is already the newest version (5.53-0ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
ubuntu@ubuntu:~/GoveeBTTempLogger$ make deb
chmod a+x GoveeBTTempLogger/DEBIAN/postinst GoveeBTTempLogger/DEBIAN/postrm GoveeBTTempLogger/DEBIAN/prerm
dpkg-deb --build GoveeBTTempLogger
dpkg-deb: building package 'goveebttemplogger' in 'GoveeBTTempLogger.deb'.
ubuntu@ubuntu:~/GoveeBTTempLogger$ sudo apt install ./GoveeBTTempLogger.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'goveebttemplogger:armhf' instead of './GoveeBTTempLogger.deb'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 goveebttemplogger:armhf : Depends: libbluetooth3:armhf but it is not installable
E: Unable to correct problems, you have held broken packages.
ubuntu@ubuntu:~/GoveeBTTempLogger$

TIME setting not being honored

I'm using a Govee H5074. I just installed v2.20220111-1, and I left the service with defaults, so TIME should have defaulted to 60 seconds. I also tried setting the TIME environmental variable to 60 and restarted the service. However, both ways don't seem to "stick":

2022-03-16 02:13:01 26.02 27.4 100
2022-03-16 02:13:15 26.05 27.4 100
2022-03-16 02:13:17 26.05 27.4 100
2022-03-16 02:13:23 26.02 27.42 100
2022-03-16 02:13:25 26.02 27.42 100
2022-03-16 02:13:39 26.04 27.41 100
2022-03-16 02:13:41 26.04 27.41 100
2022-03-16 02:13:55 26.04 27.43 100
2022-03-16 02:13:57 26.04 27.43 100

Any ideas? Thanks!

Define ganularity of logging

Hi.

It is great that you "save" the file only every X-Seconds to moderately "use" the SD-Card.
Nevertheless it would be great to have an option to summarize the values to a given timeframe and only log that specific value.
I am doing this currently with an SQLite Database, but collecting a lot of data to then eg. get it down to a minute base, would be more efficient to only log what I need.
e.g. 1 Minute, Average of the temperature (mayb one digit rounded), average of humidity (rounded on one digit), Battery (Min-Value)
here is my SQL Import I use for filtering it to minute base:

select strftime('%Y-%m-%d %H:%M:00',timestamp) as timestamp,'$LOCATION' as location,'$ID' as id,round(AVG(temp),2) as temp,round(AVG(humidity),2) as humidity,MIN(battery) as battery from import group by strftime('%Y-%m-%d %H:%M:00',timestamp)

Support Govee H5177 devices

Example output needs decoding:

[2020-11-09T00:27:35] 46 [A4:C1:38:0D:3B:10] (Name) GVH5177_3B10 (UUID) 88EC (Flags) 05 (Manu) 01000101029D1A64
[2020-11-09T00:27:35] 42 [A4:C1:38:0D:3B:10] (Manu) 4C000215494E54454C4C495F524F434B535F48575177F2FFC2 (Apple) (UUID) 494E54454C4C495F524F434B535F4857 (Major) 5177 (Minor) F2FF (RSSI) C2

Question: goveebttemplogger.service doesn't seem to accept '-c' and '--celsius'

Hey there!

I ran into the following issue today while setting everything up on my Raspberry Zero. The .svg files that are created automatically in /var/www/html don't seem to follow the '-c' argument if allpied in goveebttemplogger.service.

I tried the following:

  1. "sudo systemctl edit goveebttemplogger.service" with both '--celsius' and '-c', I also tried the EXTRAARGS:
Environment="SVGARGS=--svg /var/www/html/goveebttemplogger/ --celsius --battery 8 --minmax 8 --titlemap /var/www/html/goveebttemplogger/gvh-titlemap.txt"
ExecStart=/usr/local/bin/goveebttemplogger  -v ${VERBOSITY} --log ${LOGDIR} --time ${TIME} $SVGARGS $EXTRAARGS
  1. sudo systemctl restart goveebttemplogger

But the .svg files in /var/www/html/goveebttemplogger/ are still showing Fahrenheit instead of Celsius. Am I doing something wrong or can't I edit that part of the service? I can get Celsius .svg when manually starting /usr/local/bin/goveebttemplogger after all and the logs are in Celsius as well.

Thanks in advance for your help!

Simple output?

Would it be possible to build in the ability to simply output the temp/humidity once in JSON, CSV format and then exit? I would love to run this via a cron as part of another temperature monitoring script I have. Thanks

Log time format

Hello, first of all, I want to really thank you for this great piece of software. I needed to upgrade my grow room's environment monitoring, and I picked up 2 H5075's and 3 H5100's. So far, I only got a chance to test out one of the H5075's, but great job!

I spent all day trying to figure out why your software didn't work. bluetoothctl would see advertisements from the device, but not the logger. It turns out the signal was just too weak with that ble controller, but with another one they stream in pretty quickly.

Anyway, I just wanted to ask if it is currently possible, or in the works, to have the log written to use the client's local time. Currently I can see times relative to the local time offset. My client is in EDT (GMT -4), but logs are being written with times 4 hours in the future. Additionally, there is no indicator in the timestamp format as to which offset it is using. It's been a couple years since I messed with time conventions, but I think it might make sense to annotate this in the log format if it does not make sense to translate them before writing.

Thanks a lot!

Very new user looking to try the code out

Hello I am trying to use the templogger, and I am new to all of this.
I am trying to run this on my Raspberry pi 3B+

Started by verifying my Kernel version: 6.1.21-v7+
Then I made sure my Raspberry pi was updated and upgraded: Sudo apt update and sudo apt upgrade

Then installed libbluetooth-dev: sudo apt install bluetooth pi-bluetooth bluez blueman

Then I tried: git clone https://github.com/wcbonner/GoveeBTTempLogger.git

and: sudo apt-get install bluetooth bluez libbluetooth-dev dpkg-dev
make deb
sudo make install-deb

At this point I reread the readme and tried to verify the files were created. I was unable to find them in /var/log or /var/www/html

Thank you for putting this all together and if anyone could help me get this running I would appreciate it.

Usage questions: Custom paths and support for H5100

I'm trying to collect data from 3x H5100 but I have trouble with two points:

  1. There doesn't seem to be any log / cache / svg output
goveebttemplogger \
	--verbose 1 \
	--log /root/goveebttemplogger/log \
	--time 60 \
	--svg /root/goveebttemplogger/html --battery 8 --minmax 8 \
	--cache /root/goveebttemplogger/cache \
	--download

I created and checked above dirs, but there's nothing there (/log, /html, cache), even after hours of running, and stdout like this:

[2023-11-24T22:55:12] 300 seconds or more have passed. Writing SVG Files
[2023-11-24T22:55:12] 60 seconds or more have passed. Writing LOG Files

I assume there's nothing, because nothing was found?


  1. I don't actually seem to pickup anything
[2023-11-25T15:31:30] GoveeBTTempLogger Version 2.20231001.1 Built on: Jan  1 1970 at 00:00:01
[2023-11-25T15:31:30] LocalName: BlueZ
[2023-11-25T15:31:30] No BlueTooth Address Filter
[2023-11-25T15:31:30] Scanning Stopped.
[2023-11-25T15:31:30] Scanning Started. ScanInterval(40 msec) ScanWindow(30 msec) ScanType(1)
[2023-11-25T15:31:31] 300 seconds or more have passed. Writing SVG Files
[2023-11-25T15:31:31] No recent Bluetooth LE Advertisments! (> 3 Minutes)
[2023-11-25T15:31:31] Scanning Stopped.
...
# just repeats from here on

I can discover the devices fine, both from the computer as well as my mobile (which I currently use to collect data). I paired one to see if it makes any difference, but it does not.

As far as I understand, these devices are supposed to broadcast the stats occasionally, but I couldn't pickup any relevant BLE data in nRF Connect on Android (unless I connect to it, and explore the services directly). Maybe there's a config I missed?

Screenshot_20231125-154029

I also tried --only CC:35:34:... without any luck.

Support for H5101

https://a.co/d/cAmWKGc

I saw that there's a new H5101 device that uses the CR2450 battery with an lcd display on Amazon.

I'm guessing that its Bluetooth encoding is compatible with the other 510x devices. I don't feel like buying more thermometers right now. If someone running this software can confirm the results, I'll update the software to report the devices properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.