cmaion / polar

A set of command line tools written in Ruby to interact with Polar watches and decode raw data files
89 stars 22 forks source link

sleepanalysis2text bug while parsing sleep data #22

Closed max-thoma closed 4 years ago

max-thoma commented 4 years ago

Hi cmaion!

I have been using your software successfully to extract all my data from a Polar 430m. (Thank you very much by the way!)

However, while I was trying to parse my sleep data with polar_sleepanalysis2txt I received the following error message:

Traceback (most recent call last):
        5: from ./polar_sleepanalysis2txt:47:in `<main>'
        4: from ./polar_sleepanalysis2txt:47:in `open'
        3: from ./polar_sleepanalysis2txt:48:in `block in <main>'
        2: from ./polar_sleepanalysis2txt:37:in `output_txt'
        1: from ./polar_sleepanalysis2txt:37:in `each'
./polar_sleepanalysis2txt:38:in `block in output_txt': undefined method `value_to_names_map' for PolarData::PbSleepWakeState:Module (NoMethodError)

I have tried to troubleshoot the error and found out that these three lines in polar_sleepanalysis2txt seem to cause "errors":

28: buffer << "Alarm time : #{pb_localdatetime_to_string sleep.alarm_time}\n"

31: buffer << "Sleep user rating : #{PolarData::PbSleepUserRating.value_to_names_map[sleep.user_sleep_rating].join(', ')}\n"

38: buffer << "#{"%9is" % phase.seconds_from_sleep_start}: #{PolarData::PbSleepWakeState.value_to_names_map[phase.sleepwake_state].join(', ')}\n"

If I comment these three lines out, the program runs with no errors but important parts of the sleep data is, of course missing in the report.

I would be very grateful, if you could have a look at this issue and I would be more than happy to provide you with more information if needed.

Cheers,

Max

max-thoma commented 4 years ago

Here you can find the sleep data, that I am trying to parse. (I figured that this could be helpful)

removed sleep data, because the issue was fixed

Cheers Max

cmaion commented 4 years ago

Hi Max,

Should be fixed now.

Cheers

max-thoma commented 4 years ago

This is awesome, thank you very much for fixing the issue!