jlamendo / ha-sensor.owlet

Owlet Smart Sock v2/v3 Sensor Integration for HomeAssistant using the modern Owlet API.
MIT License
83 stars 22 forks source link

Does this still work? #11

Closed mjb83 closed 2 years ago

mjb83 commented 2 years ago

I've been trying to get this working for a few days now. No success. Many errors in the logs (note SERIAL ID is intentional to hide my serial #). Just trying to show output on a sensor integration with no success.

2021-11-23 01:14:34 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'sensor' is undefined when rendering '{{sensor.owlet_smartsock[SERIALID].attributes.heart_rate}}'

2021-11-23 01:14:34 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{sensor.owlet_smartsock[SERIALID].attributes.heart_rate}}")

and many like this:

homeassistant.exceptions.TemplateError: UndefinedError: 'sensor' is undefined 2021-11-23 01:14:34 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'sensor' is undefined when rendering '{{sensor.owlet_smartsock[SERIALID].attributes.heart_rate}}' 2021-11-23 01:14:34 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: 'sensor' is undefined') while processing template 'Template("{{sensor.owlet_smartsock[SERIALID].attributes.heart_rate}}")' for attribute '_attr_native_value' in entity 'sensor.owlet_heart_rate' 2021-11-23 01:14:34 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{states.sensor.owlet_smartsock[SERIALID].attributes.oxygen_saturation}}")

homeassistant.exceptions.TemplateError: TemplateError: str: Invalid entity ID 'sensor.owlet_smartsock' 2021-11-23 01:14:34 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('TemplateError: str: Invalid entity ID 'sensor.owlet_smartsock'') while processing template 'Template("{{states.sensor.owlet_smartsock[SERIALID].attributes.oxygen_saturation}}")' for attribute '_attr_native_value' in entity 'sensor.owlet_spo2' 2021-11-23 01:14:34 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{states.sensor.owlet_smartsock[SERIALID].attributes.movement}}")

This is the setup in configuration.yaml:

sensor:

I have been trying but I'm a little behind on the scripting. Not sure if I have a silly mistake here.

florianwedler commented 2 years ago

Used to work up to a week ago. Then owlet servers were down, also no data in the owlet app. Once recovered it quit working on my side. Will need to investigate, unfortunately I am a newbe. ;-)

mjb83 commented 2 years ago

Ahh. super bummer! I was really looking forward to getting some custom dashboards going. Ya I have some experience coding but pulling data from Owlets API I have no idea where to start.

Even things that aren't HA specific seem to have not been updated for at least 3 years. I think Owlet is actively restricting access to their API because they want users to use their app. Very disappointing...

florianwedler commented 2 years ago

It quit working on the 21st of Nov. I have two sock of different generation. Both quit working. I also did some HA updates during last week, due to their outage I thought it was an issue on their side. Log says invalid entity id in template. Not sure how i can troubleshoot and check data traffic or what may be the new entity id.

mjb83 commented 2 years ago

Ya apparently Owlet has a cease and desist from the FDA right now... nothing concerning about how the socks work - its just owlet has been marketing them as medical devices, and that requires FDA approval. Owlet never got this approval.

Could be related but the timelines don't exactly match up.

https://www.romper.com/life/fda-warning-owlet-smart-sock-baby-monitor

mjb83 commented 2 years ago

and yes, I'm getting sensor undefined all the time as my error.

florianwedler commented 2 years ago

In order to get it initially working,... like instructions said. HACS, Custom Repository, config.yaml with sensor section and for me europe as region and then platform template. Just like discribed, was working perfectly for months. With additional temperature reading via mqtt the dashboard/ monitoring of the kids looked like in ER/ICU, if not better. ;-)

jlamendo commented 2 years ago

Sorry, I don't monitor my personal Github as often as I should :) Is this still not working for folks? It's working for me, but I may have made some local changes at some point.

FWIW, in regards to the app store blocking etc etc, I find that this integration is now the only thing that makes my Owlet worthwhile. I have my own sets of alerts that can trigger on far more advanced things like 30m rolling averages and trendlines. So I'd like to do what I can to get this working for you all again if you're still having issues.

florianwedler commented 2 years ago

At least not working for me. 😢

mjb83 commented 2 years ago

Hi @jlamendo still not working for me either. My configuration hasn't changed from what I posted on 23-NOV. Does my config look any different to what you are currently running?

jlamendo commented 2 years ago

Nope, it looks exactly the same as mine! I will say - sometimes it stops working, and I have to restart my HA instance to get it working again. Can you take a look at your HA logs and let me know if there are any messages related to the integration? You can find the relevant logs in your HA instance under Configuration -> Settings -> Logs Tab. You might need to hit the "Load Full HomeAssistant Log" button to see it if it's been a while since you've booted up your instance.

mjb83 commented 2 years ago

I've got quite a few of them... My device ID is changed to xxx

Template variable error: 'sensor' is undefined when rendering '{{sensor.owlet_smartsock[xxx].attributes.heart_rate}}' 1:43:53 AM – (ERROR) helpers/template.py - message first occurred at January 11, 2022, 3:19:19 PM and shows up 6511 times

Owlet Network error while retrieving data for Sock xxx: 503 Server Error: Service Unavailable for url: https://ads-field-1a2039d9.aylanetworks.com/apiv1/dsns/xxx/properties.json January 16, 2022, 9:53:29 AM – (ERROR) owlet (custom integration) - message first occurred at January 12, 2022, 9:01:18 PM and shows up 3 times

Owlet Network error while activating Sock xxx: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) January 15, 2022, 11:00:58 AM – (ERROR) owlet (custom integration) - message first occurred at January 11, 2022, 3:42:03 PM and shows up 5 times

Updating owlet sensor took longer than the scheduled update interval 0:00:10 January 14, 2022, 11:00:45 AM – (WARNING) Sensor - message first occurred at January 14, 2022, 10:55:45 AM and shows up 31 times

Update of sensor.owlet_smart_sock_xxx is taking over 10 seconds January 14, 2022, 10:55:45 AM – (WARNING) helpers/entity.py

TemplateError('TemplateError: str: Invalid entity ID 'sensor.owlet_smartsock'') while processing template 'Template("{{states.sensor.owlet_smartsock[xxx].attributes.HIGH_HR_ALRT}}")' for attribute '_attr_native_value' in entity 'sensor.owlet_tachycardia_alert' January 11, 2022, 3:19:19 PM – (ERROR) Template - message first occurred at January 11, 2022, 3:19:19 PM and shows up 12 times

Error while processing template: Template("{{states.sensor.owlet_smartsock[xxx].attributes.HIGH_HR_ALRT}}") January 11, 2022, 3:19:19 PM – (ERROR) helpers/template.py - message first occurred at January 11, 2022, 3:19:19 PM and shows up 12 times

mjb83 commented 2 years ago

Is there anything in the manifest.json or sensor.py configs that had to be customized? I only added the custom sensor entries to configuration.yaml

mjb83 commented 2 years ago

Still no luck here @jlamendo Do any of my logs make sense to you?

mjb83 commented 2 years ago

Looks like the /config/custom_components/owlet/init.py file has nothing in it? Should it?

Was looking at this setup https://github.com/CAB426/HomeAssistant-Owlet and it looks like init file should have much more? Did you move everything over to sensor.py?

jlamendo commented 2 years ago

Nothing in either of those files needs to be customized, and your sensor entries look fine. The issue is in this log line - "Owlet Network error while retrieving data for Sock xxx: 503 Server Error: Service Unavailable for url:" - the rest of it is just cascading effects from that failure.

Essentially, Owlet's servers are responding to your requests with a 503 error indicating that the service is unavailable. Why it's specifically responding as unavailable to you, but not for anyone else, that's the real question. Unfortunately, that's one of many potential downsides when dealing with undocumented and unsupported private API's like this.

A blank init file is fairly standard in python - if the module doesn't require setup before loading, and the module doesn't contain submodules that you want to expose as top-level functionality, there's not much reason to include anything in there. The file is just there to let python know that it should treat the files in the directory as a module. See http://docs.python.org/tutorial/modules.html#packages

jlamendo commented 2 years ago

One thing you might want to try is to disconnect your Owlet from your wifi and reconnect it. Sometimes mine gets stuck in a weird state where I have to do that. If that doesn't resolve the problem, if you aren't located in the US you might want to try connecting to a US-based VPN. It would likely need to have both the Owlet and your HA instance both connected to the internet via VPN in order to work, so you'd most likely need a router capable of tunneling your entire network's connection via VPN.

mjb83 commented 2 years ago

One thing you might want to try is to disconnect your Owlet from your wifi and reconnect it. Sometimes mine gets stuck in a weird state where I have to do that. If that doesn't resolve the problem, if you aren't located in the US you might want to try connecting to a US-based VPN. It would likely need to have both the Owlet and your HA instance both connected to the internet via VPN in order to work, so you'd most likely need a router capable of tunneling your entire network's connection via VPN.

Well, I think this did it. Got my router behind my VPN connecting into Chicago... I'm not seeing any errors and I'm actually seeing entity value data after adding the base station to a lovelace entity tile.

Do you know if its possible to show the data as individual entity tiles in home assistant or is this setup specifically designed for prometheus / grafana?

mjb83 commented 2 years ago

I should clarify.. I have the following setup: type: vertical-stack cards:

I can see the owlet smart sock is connected, and if I hover over the tile I can see the attributes that are associated with it. I just can't add each individual attribute to its own entity tile on lovelace to give me a dashboard.

jlamendo commented 2 years ago

That's more of an HA thing than anything specific to this integration, but you definitely can expose an entity attribute in a tile.

type: attribute
entity: sensor.owlet_smart_sock_xxxxyyyy
attribute: heart_rate
jlamendo commented 2 years ago

In any case, I'm glad that fixed it for you! I suspect that there's some value of the string which is currently configured as "world" that would allow you to connect without VPN, but I don't know what it might be or have any way of finding out. And hey, if it's not broken don't fix it.

It is pretty hilarious though that the Owlet developers felt it fitting to call the US "World" - classic American Exceptionalism! Sorry our hubris caused you problems 😬

mjb83 commented 2 years ago

That's more of an HA thing than anything specific to this integration, but you definitely can expose an entity attribute in a tile.

type: attribute
entity: sensor.owlet_smart_sock_xxxxyyyy
attribute: heart_rate

Doesn't look like attribute is picking up?

Unknown type encountered: attribute

mjb83 commented 2 years ago

Figured it out! For everyone else following along:

jlamendo commented 2 years ago

Going to close this issue out for now, as it sounds like your problem is resolved.

mjb83 commented 2 years ago

Thanks Jonathan!

Now on to figuring out Prometheus lol..

On Sat, Feb 12, 2022 at 12:14 PM Jonathan Lamendola < @.***> wrote:

Going to close this issue out for now, as it sounds like your problem is resolved.

— Reply to this email directly, view it on GitHub https://github.com/jlamendo/ha-sensor.owlet/issues/11#issuecomment-1037320759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLQ5BZTBKLGHLIWMG5TLV3U22IPRANCNFSM5ISXB25A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>