Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple instances of the integration doesn't work for EU users #6

Closed
prestomation opened this issue Jan 12, 2022 · 23 comments
Closed
Labels
bug Something isn't working

Comments

@prestomation
Copy link
Owner

Is your feature request related to a problem? Please describe.
When adding a second login from the EU, the second integration won't add as it says it is a duplicate

Describe the solution you'd like
A second instance of the integration should work

Describe alternatives you've considered
N/A

Additional context
General support for multiple instances was added to the integration in #3.
This works in the US, but the problem is the integration relies on each CPAP having a unique serial number.

This is setup in the US version, but in the EU version the serial number is not plumbed through. This is because it does not show up on the dashboard which is the only information I had an example from when adding EU support, as I do not have an EU account and cannot create one.

To address this I need a HAR file for the MyAccount Profile

  1. Login to myAir
  2. Open the developer console.
  3. Open the 'My Account' page.(https://myair.resmed.eu/MyAccount.aspx)
  4. Export a HAR file
  5. Send this HAR file to me or attach it here.
    For step 4, here are some instructions for Chrome: https://support.google.com/admanager/answer/10358597?hl=en

Be careful to NOT enter your password when you have the network tab open. This may end up including your myAir password in the har file which we want to avoid. Login first and then open the developer console, open the page, and capture the HAR file.

@HummelsTech
Copy link

HummelsTech commented Jan 12, 2022

Thanks for your quick reply. Here's my har file as requested myair.resmed.eu.har.zip
myair.resmed.eu.har_v2.zip

.

@prestomation
Copy link
Owner Author

@HummelsTech I have pushed an update. Please try upgrading through HACS to 9139e29 and let me know if it works

@HummelsTech
Copy link

HummelsTech commented Jan 13, 2022

Now I can add both CPAPs, but the readings for both are the same. The second sensor gives me the same values as the first.
At both CPAPs the sensor.cpap_sleep_data_last_collected is unavailable

@prestomation
Copy link
Owner Author

For cpap_sleep_data_last_collected, this is a bug. This only works in NA right now, but the wrong sensor was excluded. the next update will fix this.

As for both devices reporting the same data, let me dig into this.

@prestomation
Copy link
Owner Author

There is some information you can collect for me that will help.

  1. Access the HA config directory using the terminal, samba plugin, or however you edit HA files
  2. open the file .storage/core.entity_registry
  3. Find one of the CPAP sensors, any one that is currently working will do, and paste the entry into this issue
  4. Check to see if that particular sensor show up more than once(which you can identify by the same Original Name), if it does, paste the entry for all the occurrences into this issue.

@HummelsTech
Copy link

HummelsTech commented Jan 14, 2022

Sorry for the delay, but here is my output:
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_ahi_events_per_hour",
"icon": null,
"id": "ad77f7da33623788bd15ef4e7969248a",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP AHI Events Per Hour",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_raccount1@mail.com_ahi",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_usage_minutes",
"icon": null,
"id": "d37b82f1cb6e3a4d35032474e88f1fb9",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Usage Minutes",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_raccount1@mail.com_totalUsage",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_mask_on_off",
"icon": null,
"id": "6995f13b1a6fb4c02fa826923dbf8660",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Mask On/Off",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_raccount1@mail.com_maskPairCount",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": null,
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_current_data_date",
"icon": null,
"id": "f0d7fb8181f110ae32a354edc074ed19",
"name": null,
"original_device_class": "date",
"original_icon": null,
"original_name": "CPAP Current Data Date",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_raccount1@mail.com_startDate",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_mask_leak",
"icon": null,
"id": "9d7a3c92289400107679ee0d7a23a50b",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Mask Leak %",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_raccount1@mail.com_leakPercentile",
"unit_of_measurement": "%"
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_total_myair_score",
"icon": null,
"id": "c8b6c3a192822fd557a67a6e0e2f23fd",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Total myAir Score",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_raccount1@mail.com_sleepScore",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_usage_time",
"icon": null,
"id": "8c92fe799cf0e6f78ec7887816a49112",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Usage Time",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_raccount1@mail.com_usageTime",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "date"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.most_recent_sleep_date",
"icon": null,
"id": "44d9bb4e48985cc49f3429480ddcda70",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "Most Recent Sleep Date",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_raccount1@mail.com_mostRecentSleepDate",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "50122fd36a8421a625b95b9f66072df3",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_ahi_events_per_hour_2",
"icon": null,
"id": "26a6986fe16e1dee50bdd59feddf6309",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP AHI Events Per Hour",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_ahi",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "50122fd36a8421a625b95b9f66072df3",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_usage_minutes_2",
"icon": null,
"id": "a69722ecd9075a6b7d329ef6d14cf1dd",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Usage Minutes",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_totalUsage",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "50122fd36a8421a625b95b9f66072df3",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_mask_on_off_2",
"icon": null,
"id": "4955bace5237de8c8ae54d4d5ca241a5",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Mask On/Off",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_maskPairCount",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": null,
"config_entry_id": "50122fd36a8421a625b95b9f66072df3",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_current_data_date_2",
"icon": null,
"id": "ede561cb178714139148366ef65e9088",
"name": null,
"original_device_class": "date",
"original_icon": null,
"original_name": "CPAP Current Data Date",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_startDate",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "50122fd36a8421a625b95b9f66072df3",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_mask_leak_2",
"icon": null,
"id": "d19a2267c9e5a854d3d5368aefaf2964",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Mask Leak %",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_leakPercentile",
"unit_of_measurement": "%"
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "50122fd36a8421a625b95b9f66072df3",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_total_myair_score_2",
"icon": null,
"id": "d0493a538aea8a49f7c7b1ac67618638",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Total myAir Score",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_sleepScore",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "50122fd36a8421a625b95b9f66072df3",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_usage_time_2",
"icon": null,
"id": "45d665193c2fd197685af228f5191b55",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Usage Time",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_usageTime",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "date"
},
"config_entry_id": "50122fd36a8421a625b95b9f66072df3",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.most_recent_sleep_date_2",
"icon": null,
"id": "538d98865145a953c306a2955a6d2b8a",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "Most Recent Sleep Date",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_mostRecentSleepDate",
"unit_of_measurement": null
},

@HummelsTech
Copy link

demo-sleepMetrics@2x min
here's an icon suggestion for your integration.

@HummelsTech
Copy link

After install second account all values are correct, but after a restart of home assistant both sensors are unavailable.
Here is the log after reboot:

{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_ahi_events_per_hour",
"icon": null,
"id": "ad77f7da33623788bd15ef4e7969248a",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP AHI Events Per Hour",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account1@mail.com_ahi",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_usage_minutes",
"icon": null,
"id": "d37b82f1cb6e3a4d35032474e88f1fb9",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Usage Minutes",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account1@mail.com_totalUsage",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_mask_on_off",
"icon": null,
"id": "6995f13b1a6fb4c02fa826923dbf8660",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Mask On/Off",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account1@mail.com_maskPairCount",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": null,
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_current_data_date",
"icon": null,
"id": "f0d7fb8181f110ae32a354edc074ed19",
"name": null,
"original_device_class": "date",
"original_icon": null,
"original_name": "CPAP Current Data Date",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account1@mail.com_startDate",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_mask_leak",
"icon": null,
"id": "9d7a3c92289400107679ee0d7a23a50b",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Mask Leak %",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account1@mail.com_leakPercentile",
"unit_of_measurement": "%"
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_total_myair_score",
"icon": null,
"id": "c8b6c3a192822fd557a67a6e0e2f23fd",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Total myAir Score",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account1@mail.com_sleepScore",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_usage_time",
"icon": null,
"id": "8c92fe799cf0e6f78ec7887816a49112",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Usage Time",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account1@mail.com_usageTime",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "date"
},
"config_entry_id": "55cd2fc5e773a42638de93e9c480cbd6",
"device_class": null,
"device_id": "5678107b7ce85eee0604bd8b81e42729",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.most_recent_sleep_date",
"icon": null,
"id": "44d9bb4e48985cc49f3429480ddcda70",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "Most Recent Sleep Date",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account1@mail.com_mostRecentSleepDate",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "b4b30e8c1fef73e880b1beecdf3cab67",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_ahi_events_per_hour_2",
"icon": null,
"id": "3899bf26ba1f1250b794ac0c72034c1e",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP AHI Events Per Hour",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_ahi",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "b4b30e8c1fef73e880b1beecdf3cab67",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_usage_minutes_2",
"icon": null,
"id": "b933ae7af04422bd9f3d14ce52a1e262",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Usage Minutes",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_totalUsage",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "b4b30e8c1fef73e880b1beecdf3cab67",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_mask_on_off_2",
"icon": null,
"id": "71d2a6af769c643726fea90d79688b19",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Mask On/Off",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_maskPairCount",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": null,
"config_entry_id": "b4b30e8c1fef73e880b1beecdf3cab67",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_current_data_date_2",
"icon": null,
"id": "f36e972ee4b5f0b8c0bebae0922b75a7",
"name": null,
"original_device_class": "date",
"original_icon": null,
"original_name": "CPAP Current Data Date",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_startDate",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "b4b30e8c1fef73e880b1beecdf3cab67",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_mask_leak_2",
"icon": null,
"id": "046a30199af1e25acb567acc797c217c",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Mask Leak %",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_leakPercentile",
"unit_of_measurement": "%"
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "b4b30e8c1fef73e880b1beecdf3cab67",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_total_myair_score_2",
"icon": null,
"id": "05cf0110e1a0cfd3db54556b15e09330",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Total myAir Score",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_sleepScore",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "measurement"
},
"config_entry_id": "b4b30e8c1fef73e880b1beecdf3cab67",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.cpap_usage_time_2",
"icon": null,
"id": "ac4a9e867906badcefbd03f7a0d69c7e",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "CPAP Usage Time",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_usageTime",
"unit_of_measurement": null
},
{
"area_id": null,
"capabilities": {
"state_class": "date"
},
"config_entry_id": "b4b30e8c1fef73e880b1beecdf3cab67",
"device_class": null,
"device_id": "a2019f0092ab777c676876fe3ff7e932",
"disabled_by": null,
"entity_category": null,
"entity_id": "sensor.most_recent_sleep_date_2",
"icon": null,
"id": "730af8bb4d537d4e865e5d0b778c2356",
"name": null,
"original_device_class": null,
"original_icon": null,
"original_name": "Most Recent Sleep Date",
"platform": "resmed_myair",
"supported_features": 0,
"unique_id": "resmed_myair_account2@mail.com_mostRecentSleepDate",
"unit_of_measurement": null
},
{

@HummelsTech
Copy link

When I deactivate CPAP2 and reboot the values off CPAP1 are came up again.
Hope you have enough info to address the issue

prestomation added a commit that referenced this issue Jan 14, 2022
See: #6

My best guess here is that the same cookie jar is used in both instances, because it is likely shared state from a shared client provided by home assistant.
This would lead to the observed behavior, whenever one of the coordinators runs it overrides the cookies shared by both, so they effectively get the same data.

With this, each client has its own cookie jar so this sharing risk should go away.

Testing:
* Legacy tests still pass. The aiohttp mock we use doesn't seem to support cookies in such a way that we can test this further
@prestomation
Copy link
Owner Author

Thanks for the information. I have found a subtle bug that might be causing this and have pushed a fix. Please update, test and let me know.

Thank you also for the icon suggestion.

@HummelsTech
Copy link

Thanks again, but now I can't load the integration. Unknown error occurred

@prestomation
Copy link
Owner Author

Uhoh! Can you send a screenshot of what you see regarding ResMed in the logs in Settings->Logs?

@prestomation
Copy link
Owner Author

I've fixed an issue I found, please try updating again to latest.

@prestomation prestomation added the bug Something isn't working label Jan 16, 2022
@prestomation
Copy link
Owner Author

@HummelsTech I'm going to close this issue, but please re-open if you still have issues.

@HummelsTech
Copy link

Sorry again for the delay, but with last update the first bug came up again. when I config the second CPAP it gives me message: Device is already configured

@prestomation
Copy link
Owner Author

hm, so for the EU the email address is used to determine if a device is already configured. I'm assuming these devices must have different email addresses for their associated accounts, right?

Here is something to try:

  1. Turn up logging for this integration by adding these lines to your configuration.yaml, DO NOT add the default: info line though, as this will make all integrations print a lot more lines: https://github.com/prestomation/resmed_myair_sensors/blob/master/.devcontainer/configuration.yaml#L3-L6
  2. Remove your current config for resmed
  3. Reboot
  4. Add the integration twice, once for each account
  5. Send me all the log lines that mention resmed. we should see one line for each mentioning the serial number, which should contain your email address. Please sanitize the addresses, but confirm to me if they show up the same.

@HummelsTech
Copy link

Can only add one CPAP when I try to add the second I get the message

@prestomation
Copy link
Owner Author

I understand, but I need the associated log messages when this happens

@HummelsTech
Copy link

HummelsTech commented Jan 18, 2022

I try to find those, look at it tomorrow when I'm at my PC
Don't see any debug info at system logs

@HummelsTech
Copy link

Logger: homeassistant.components.sensor
Source: helpers/update_coordinator.py:161
Integration: Sensor (documentation, issues)
First occurred: 20:33:19 (1 occurrences)
Last logged: 20:33:19

Error while setting up resmed_myair platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/resmed_myair/coordinator.py", line 39, in _async_update_data
self.sleep_records = await self.myair_client.get_sleep_records()
File "/config/custom_components/resmed_myair/client/legacy_client.py", line 111, in get_sleep_records
page = await self.get_dashboard_html()
File "/config/custom_components/resmed_myair/client/legacy_client.py", line 106, in get_dashboard_html
async with self.client.get(EU_CONFIG["dashboard_url"]) as dashboard_res:
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in aenter
self._resp = await self._coro
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 559, in _request
await resp.start(conn)
File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 898, in start
message, payload = await protocol.read() # type: ignore[union-attr]
File "/usr/local/lib/python3.9/site-packages/aiohttp/streams.py", line 616, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/resmed_myair/sensor.py", line 200, in async_setup_entry
await coordinator.async_config_entry_first_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 161, in async_config_entry_first_refresh
raise ex
homeassistant.exceptions.ConfigEntryNotReady: Server disconnected

@prestomation
Copy link
Owner Author

Interesting! This looks like maybe your internet was having a hiccup, but this should have been retried and I don't think is the cause of our issues. were you able to turn on Info logging and find the lines about serial numbers?

@HummelsTech
Copy link

Strange but true. Now it works I think my account had a hick-up thanks for all your help and understanding.

@prestomation
Copy link
Owner Author

Yay! I'm going to close this but please open a new issue if you have issues or feature requests. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants