YorkshireIoT / ha-google-fit

Home Assistant Google Fit Custom Component

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unknown sleep stage type

fwmarcel opened this issue · comments

System Health details

System Information

version core-2023.10.5
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.11.5
os_name Linux
os_version 6.1.21-v8
arch aarch64
timezone Europe/Berlin
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4986
Installed Version 1.33.0
Stage running
Available Repositories 1333
Downloaded Repositories 56
HACS Data ok
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 11.1
update_channel stable
supervisor_version supervisor-2023.10.1
agent_version 1.6.0
docker_version 24.0.6
disk_total 28.3 GB
disk_used 18.3 GB
healthy true
supported true
board rpi4-64
supervisor_api ok
version_api ok
installed_addons deCONZ (6.22.0), MariaDB (2.6.1), Samba share (10.0.2), ESPHome (2023.10.5), InfluxDB (4.8.0), Advanced SSH & Web Terminal (15.1.0), phpMyAdmin (0.8.9), Home Assistant Google Drive Backup (0.111.1), Mosquitto broker (6.3.1), Cloudflared (4.2.9), DSS VoIP Notifier (4.0.0), AirCast (3.6.1), Silicon Labs Multiprotocol (2.3.2), Wmbusmeters (W-MBus to MQTT) (1.14.0), openWakeWord (1.8.2), Piper (1.4.0), Whisper (1.0.0), Matter Server (4.10.0), File editor (5.6.0)
Dashboards
dashboards 3
resources 33
views 31
mode storage
Recorder
oldest_recorder_run 1. Oktober 2023 um 21:12
current_recorder_run 1. November 2023 um 17:59
estimated_db_size 2452.05 MiB
database_engine mysql
database_version 10.6.12
Spotify
api_endpoint_reachable ok

Checklist

  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues..

Describe the issue

Unfortunately, all values show unknown.
Unfortunately, not much can be found in the log.
My sleep data is synced with Google Fit via Samsung Health.

image

Reproduction steps

The error occurs immediately after the setup. I have followed the instructions for this.

Debug logs

2023-11-01 18:11:39.912 ERROR (MainThread) [custom_components.google_fit] Error fetching google_fit data: Error communicating with API: Unknown sleep stage type. Got enum: 0
2023-11-01 18:11:39.913 DEBUG (MainThread) [custom_components.google_fit] Finished fetching google_fit data in 2.626 seconds (success: False)

Diagnostics dump

No response

Same error here!!

That might be an oversight on my part. The Google docs say:

"intVal": 0 // Unspecified or unknown if user is sleeping.

which I guess might still be a valid value in some cases. Can I ask where your sleep data is coming from?

Hello @YorkshireIoT
My sleep data comes from a Samsung Galaxy Watch and is therefore imported from Samsung Health into Google Fit. It is possible that google defines the data as unspecified.
It hope it helps.
If you have further questions, let me know.

Hi @fwmarcel and @daniperaleda,

I've no way to replicate and test this myself but I've got some code on a custom branch that will log a warning instead of throwing an error if the sleep type is 0. It'd be great if you could test this out.

To do this you need to download these two files:

and replace them with the existing files in your config/custom_components/google_fit folder in Home Assistant. You will then need to restart HA for the changes to take effect.

I'm interested to see if all your sleep data is using the unspecified/unknown type or if it's just one portion of sleep. Thanks 😄

Hello @YorkshireIoT,
First of all, thank you for your effort. I have applied the changes to my system.
Your built-in log message occurs several times in any case.
It also looks like the data is not displayed as unknown.

Here is the log output:

2023-11-12 21:07:23.848 DEBUG (MainThread) [custom_components.google_fit] Setting up Google Fit Coordinator. Use zero=False and updating every 5 minutes
2023-11-12 21:07:37.898 DEBUG (MainThread) [custom_components.google_fit] Setting up Google Fit Coordinator. Use zero=False and updating every 1 minutes
2023-11-12 21:08:37.475 DEBUG (MainThread) [custom_components.google_fit] Fetching data for account *********
2023-11-12 21:08:40.090 DEBUG (MainThread) [custom_components.google_fit] No float data points found for derived:com.google.body.temperature:com.google.android.gms:merged
2023-11-12 21:08:40.465 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.466 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.466 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.466 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.466 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.466 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.466 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.466 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.466 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.467 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.468 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.469 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.470 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.470 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.470 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.470 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.470 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.470 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.470 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:40.470 WARNING (MainThread) [custom_components.google_fit] Google Fit reported an unspecified or unknown value for sleep stage. Please report this as a bug to the original data provider. This will not be reported in Home Assistant.
2023-11-12 21:08:41.878 DEBUG (MainThread) [custom_components.google_fit] No float data points found for derived:com.google.blood_glucose:com.google.android.gms:merged
2023-11-12 21:08:42.052 DEBUG (MainThread) [custom_components.google_fit] No float data points found for derived:com.google.hydration:com.google.android.gms:merged
2023-11-12 21:08:42.246 DEBUG (MainThread) [custom_components.google_fit] Finished fetching google_fit data in 4.770 seconds (success: True)
2023-11-12 21:09:16.563 DEBUG (MainThread) [custom_components.google_fit] Setting up Google Fit Coordinator. Use zero=False and updating every 5 minutes

If I can help in any way, please let me know.

I've also looked a little more into the sleep data from Samsung Health and Google Fit. Apparently there seem to be a few discrepancies there too.
While the time in bed is transferred correctly. The actual sleep duration with light deep and REM sleep does not seem to be displayed correctly in the Google Fit app.
The sleep time in the app is strangely at 0 min.

The error in the integration is then only a subsequent error. Probably with the change you made, it can now handle the error better.

Hm, those logs would suggest there's lots of those data point problems where the type is unspecified. I don't really want to spam the log with that many messages.

I'm actually using Samsung Health as well but I use a nice Android app called Sleep Sync. You do have to pay for it (although you get a trial) but I've found you get a lot more data pulled across to your Google account.

Is your sleep time (just overall sleep, not deep, REM, light etc.) accurate in HA now?

@YorkshireIoT Yes, my sleep time (total) is now accurate in HA.
I use Health Connect myself so that Samsung Health and Google Fit work together.

However, from time to time I still have the problem that all entities have the status "unknown".
I'm just not sure if this is another problem.

Unfortunately, I am currently not able to stop my VSC in the custom component code during debugging.

Thanks for trying that @fwmarcel, I'll get that fix merged into the code base ASAP.

However, from time to time I still have the problem that all entities have the status "unknown".
I'm just not sure if this is another problem.

This is linked to issue #88 which I really need to get round to fixing at some point.

Unfortunately, I am currently not able to stop my VSC in the custom component code during debugging.

If you do want to play around with debugging, the best way is via the dev container and to enable debugging you have to edit the configuration.yaml lines, restart HA with ./scripts/develop and then you can use the built-in launch.json to debug the code

@YorkshireIoT Thank you for the changes and the pending ones.

If you do want to play around with debugging, the best way is via the dev container and to enable debugging you have to edit the configuration.yaml lines, restart HA with ./scripts/develop and then you can use the built-in launch.json to debug the code

Yes exactly what you are describing I have already tried. Strangely enough, VSC does not stop at the breakpoints. That's why I asked.