Humanity/ShiftPlanning API

Hiya

They look totally normal. Expired token maybe??


Super cool of you to help!

It was my first guest… if you restart the HA it will force to renew the token. May you test this please? I put code in there to renew the token using a API call to should do that. Perhaps I should change to just re-authenticate again.

sadly, a restart of HA hasn’t changed anything. Still just get “nobody” and the same error in the logs. Interesting, though, as I guess ultimately this is useful debugging info?

may you show your shift? There’s another thing to check: who is on duty? I didnt payed too much attention to unicode/UTF-8 strings, so if the one on duty has accented letters in the name could be a problem.

Guess it could be the ‘holiday’ state? But even yesterday the ‘today’ sensor was showing ‘nobody’ so I suspect it’s not that.

Hi,

May you run this code and send the error that it should produce? Edit the file to change your humanity credentials and run it as “python humanitydebug.py”. Perhaps you will have to run “pip install requests” before as the requests library is needed.

yes… “holiday” may be the problem. I will need to add code to deal with this kind of thing.

sdsadsa

thanks for this!

I did a quick fix and commited to my github. May you update/try the new code?

Thanks for this!

Now it says:

2019-06-21 19:09:31 ERROR (SyncWorker_10) [custom_components.humanity.sensor] Error when calling humanity to update data
2019-06-21 19:09:33 ERROR (SyncWorker_2) [custom_components.humanity.sensor] Error when calling humanity to update data

My instinct is that it’s a token issue rather than a holiday issue, but that the holiday issue would probably have caused problems at a later date anyway!

Hi,

Please download and run again the humanitydebug.py code. I dont think the problem is the token as there’s another message for when the token/login is wrong.

hmmm, miraculously, the Humanity implementation has started working again?!

I use a “get_shifts” API call to retrieve the shifts from the next 3 days. I pass this response to a function to split it on today/tomorrow shifts. Something was wrong while trying to parse/split that response. Looking at your shift picture again get me wondering about that “Empty Shifts” line. I will update the code and put more checks on it, but I’m really curious about what humanity was returning that broke that split function :-(.

Hi pal,
Well, I won’t disappear! When if/it “breaks” again I will happily post again so we can try to crack it?
EDIT: or I can add an “empty shift” for Tuesday, say?
Thanks!!

Have sent a paste to the JSON output of a failed call to you as a PM. Names are anonymised, but even so!