libdyson-wg / ha-dyson

Home Assistant custom integration for Wi-Fi connected Dyson devices
MIT License
243 stars 26 forks source link

Discussion section for questions #3

Closed Anto79-ops closed 1 year ago

Anto79-ops commented 1 year ago

Hi,

thanks for opening up an new Dyson repository. Any way to add a discussion section to this repository?

I'd like to ask a question if Dyson local does "I/O in the event loop"

For context, here is a comment

I'm trying to find some demons in my HA instance and wanted to ask that question and if Dyson local does this, it would be good to fix that.

Anto79-ops commented 1 year ago

also, question 2

Would it be possible to migrate to this new repository from the Shenxn one? Or do I have to remove the Shenxn one, and install this one?

I'm a little reluctant to remove the Shenxn one because I've heard of people having issues installing it again, but if one can confirm this is not the case anymore, that would be great!

dotvezz commented 1 year ago

Any way to add a discussion section to this repository?

I think you just did it!

I'd like to ask a question if Dyson local does "I/O in the event loop"

I genuinely don't know right now - I'll dig and find out.

Would it be possible to migrate to this new repository from the Shenxn one? Or do I have to remove the Shenxn one, and install this one?

Yes! Here's the migration steps that have worked for me. I should add them to the readme.

Experimental no-reconfiguration swap

I haven't tested this method very much, but in my experiments it seems possible to switch over with zero impact to your current integration configuration, entities/devices, or dashboards. I don't know what side-effects it may have though (leftover old config data might start causing issues or something - no guarantees).

  1. Remove the ha-dyson and ha-dyson-cloud custom repositories from HACS
    • Without removing the integrations themselves.
  2. Add the new ha-dyson and ha-dyson-cloud custom repositories
    • The ha-dyson-cloud repository is only necessary if you already use it, or are intending to use its features. It is not required, but currently, it makes setting up new devices like HP07 (527K) much simpler.
  3. Update the ha-dyson and ha-dyson-cloud repositories using the HACS updater

Proven some-reconfiguration swap

This is proven to work without any side effects. If you used the default IDs for the entities and devices, then you'll just need to re-configure the devices but your dashboards will not need updating.

  1. Remove the Dyson Local and Dyson Cloud integrations from your /config/integrations page.
  2. Remove the Dyson Local and Dyson Cloud integrations from your /hacs/integrations page.
  3. Remove the dyson-ha and dyson-ha-cloud custom repositories from HACS
  4. Add the new dyson-ha and dyson-ha-cloud custom repositories
    • The libdyson-ha-cloud repository is only necessary if you already use it, or are intending to use its features. It is not required, but currently, it makes setting up new devices like HP07 (527K) much simpler.
  5. Update the dyson-ha and dyson-ha-cloud repositories
Anto79-ops commented 1 year ago

Yes, thank you very much! Dottore 😉

GitPetri commented 1 year ago

Tested the no-reconfiguration swap method, worked at least for me.

Anto79-ops commented 1 year ago

awesome. I just migrated using the "Proven some-reconfiguration swap". all my machines are working as they did.

You'll have to update/fix the HACS title page though, for some good PR :)

image

khzd commented 1 year ago

Hello thanks to re activate this integration,:) I was able to integrate my Dyson Pure Hot Cool today after years, everything is OK, integrated in local ( NB the second region requested by get_devices.py is the code of the Contry ie DE, FR... ) If you need any help for testing... Congratz the dream team:)

Anto79-ops commented 1 year ago

Hello with the new version that just released 0.17.2, will i now be able to add my Dyson pure hot cool formaldehyde machine? I have it already added but it is added as only a pure hot cool so I don't have any formaldehyde functionality because when I click the formaldehyde machine it never wants to connect on setup. Thanks again for reviving this repo

dotvezz commented 1 year ago

Great question! 0.17.2 fixes cloud login issues. I'm working on an experimental refactor to fix formaldehyde and hope to release it soon as 0.18.0.

dotvezz commented 1 year ago

I've released v0.18.0 of the dyson-local integration which now supports Formaldehyde devices!

One note, I've been testing with a simulated device as my 527K happens to be the no-Formaldehyde version. Please feel free to install and test. There should be no breaking changes to dyson-local, but please let me know if you experience any problems.

cc: @Anto79-ops

Anto79-ops commented 1 year ago

Just updated and it works!

Screenshot_20230430-195845.png

I didn't have to delete and add the device, it just showed up after restart!

Just curious do I have to delete and reinstall the device?

dotvezz commented 1 year ago

Ah, I should have mentioned: You do not need to delete and re-add! It detects whether or not it should provide that sensor when Home Assistant is loading the integration (like after a Home Assistant restart, etc) so you're good!

I wonder if it should have a unit like it has for NOX in your screenshot. Does the Dyson App display a particular unit with the Formaldehyde measurement?

Anto79-ops commented 1 year ago

Perfect it's all good I didn't delete anything.

Yes, it should have units like this. Screenshot_20230430-200439.png

But the value it is reporting is actually a little bit different than what the machine is reporting, for example

Screenshot_20230430-200734.png

Screenshot_20230430-200806.png

Also maybe the class should be total increasing or measurement? When I click on it it doesn't show history plot, just colour coded numbers.

Screenshot_20230430-200947.png

But the number is updating and changing so there might be some conversion calculation that might need to be done.

dotvezz commented 1 year ago

Cool, that'll be an easy enough change! Thanks for the screenshots.

Edit: Oh interesting, yeah there may need to be some math for the sensor data. I'll dig into it a bit!

dotvezz commented 1 year ago

Okay Dyson was already kinda pissing me off with Formaldehyde devices sharing product codes with normal devices. But now the inconsistent units are even more annoying.

Why are they presenting the NOX measurement in µg/m3 but HCHO measurement in mg/m3?? 5 µg/m3 is the same as 0.005 mg/m3.

For my part, I think I'm just going to stick with µg/m3 in the integration. I'll release a new change that improves the display and should add the correct units, should just take a moment. Let me know if anything's weird when it lands for you.

Anto79-ops commented 1 year ago

Cool, that'll be an easy enough change! Thanks for the screenshots.

Edit: Oh interesting, yeah there may need to be some math for the sensor data. I'll dig into it a bit!

For sure. While you're at it,

I believe the NO2 and VOC units should be ppb. The Dyson app does some conversion to their 0 to 10 or 12 scale, but the machine outputs raw values I think. PM, temp, and humidity are correct of course.

If you need help with the formaldehyde math, i might be able to extract that to a stats sensor or if you can fix the class so that it plots a history graph, I can try to compare with the Dyson app plots over 1 week or 2.

And thanks for adding this!

dotvezz commented 1 year ago

Yeah, I'd really appreciate your help with the Formaldehyde math. I'll double-check the NO2 and VOC calculations using my devices.

For the time being, I'll wait on the release that "fixes" the unit display - if I'm gonna correct something, I want to actually be correct.

If nothing else, now people can actually use their devices - we'll work on making the sensor data accurate next. Thanks for your help!

dotvezz commented 1 year ago

Okay, I couldn't sleep and went down a rabbit hole. Like you said, The raw sensor data seems to be what's coming over mqtt, and it is definitely not the same as what's coming from Dyson's app. On the one hand, I'll always prefer raw data! On the other hand, I wish that we had a definitive answer as to what units that data will be in! Temp is reported in °K, which feels like it would be a pretty standard unit to report. I've got a friend who works with industrial gear, maybe he'll be able to shine a light as to whether there's just an obvious standardization of units that we can assume the raw data is using.

Also, with this math I'm having to revisit a bunch of Chemistry I haven't thought about since university; getting molecular weight of things, finding the mass of 1m3 of air at a given temperature and pressure. Fun stuff. Between that and looking at the Dyson app:

  1. For NO2 and VOC, annoyingly Dyson is doing some proprietary math to turn the sensors' raw data into their 0-9+ scale.
    • I'm betting it's ppb (as opposed to ppm) for NO2 like you said - if it was ppm, wikipedia says I would be in "immediate danger" with my reading of 16 a few hours ago.
  2. pm2.5 and pm10 are probably going through some proprietary math as well.
    • It's at least using an arbitrary (and proprietary) assumption about the composition of the particulate material being measured, and just using some constant value in the math. Without knowing information the composition, I'm pretty sure you can't actually get a molecular weight to convert to g/m3.
    • We can probably at least reverse-engineer the constant in this case. IF we do that, we can cross reference it against relevant ppm/ppb recommendations to whether it corresponds with those.
    • In practice, maybe it's just normal to assume some standardized constant for this? :shrug:
      1. Formaldehyde is also almost definitely ppb rather than ppm: 1ppm would be above OSHA's exposure limits.

It seems a safe bet that all the raw sensor data is in ppb. I don't know where Dyson is pulling atmospheric pressure from in order to convert it to µg/m3 - it's a relatively cheap sensor to include with temperature, so it might be onboard? But it's definitely not sent over mqtt. Maybe in practice it's just common to assume 1atm or something like that though?

So I want to do this:

  1. Confirm whether it's all ppb for the air quality sensors.
  2. Update the HASS integration side to report the correct raw units, rather than doing the same kind of calculations that Dyson does.
Anto79-ops commented 1 year ago

oh this so interesting! Yes, this so strange and I can see why there is frustration. I do agree that the integration should provide raw data and not do some conversion. Knowing that the units are, however, would make automations more intuitive for example, having a ventilator turn on if some of these values are not good.

For the formaldehyde, I've been reading quite a bit about conversion factors from ppb/ppm to µg/m3 or mg/m3 based molecular weight. What is interesting for formaldehyde, I've read that a conversion factor of about 1.25 or 1.3 is needed:

mg/m3 = (ppm) × (molecular weight of the compound)/(24.45).

30.03 g/mol formaldehyde

using published formulas above give a different number compared to what the machine is reporting compared to the app. I have no idea what Dyson in using the app because it does not seem to be that...its more like around 2 with some rounding error, for example, here's the comparison of what the integration reports and what the Dyson app reports

HA Dyson 5 0.011 2 0.006/0.005 1 0.004/0.002 0 0.002/0.001

These values roughly translate to a factor of 2? cannot find any literature on this though if we assume its native ppb.

I can't make any sense of the numbers the dyson app reports vs what the machine reports. Maybe some tear videos showing at the sensors are could tell more.

dotvezz commented 1 year ago

Yeah, this has been an interesting exercise but I don't feel any closer to the base units for NO2 or VOC at all. I was doing that exact math for NO2 then realized that Dyson is giving us some unknown scale instead of µg/m3. I've been using this calculator to get an idea for what the raw numbers might correlate to but fell asleep before I wound up coming up with anything useful. I'll continue the search later today - this is gonna drive me crazy if I can't figure it out.

For PM2.5 and PM10 I figure there may be some reasonable conversion factor. I haven't been able to find a lot of solid material online, but ChatGPT suggests a conversion factor of 3.53 for PM10 so that's something :upside_down_face: - although I haven't been able to test that (or anything) against the numbers we're getting yet.

I'll also look into contacting Dyson directly to see if they're willing to share any info.

dotvezz commented 1 year ago

Got a bit more information to post here. I actually hopped onto a live chat on Dyson's website and asked directly. I'm not 100% confident in the information but hopefully it's better than nothing. The chat transcript is in this gist if you're curious.

He seems pretty confident that NO2, VOC, and HCHO are all being measured and reported in ppb[1]. But like you've found for HCHO, there's not really a sane conversion factor I can work out that translates the measurements we're seeing into the numbers that the app is presenting.

For NO2, I'm having a hard time wrapping my head around the claim that it's actually in ppm even from the horse's mouth:

  1. The idea that 0.028 ppm is supposedly an AQI of 1 in the app feels like the AQI is too low, since 0.028 ppm is about half of the limit for Nitrogen Dioxide (annual mean) as defined by 40 CFR § 50.11(c). But it's possible that their conversion factor accounts for this being periodical exposure - as long as it's infrequent, even going way over 0.053ppm doesn't bring your annual mean near it.
  2. Speaking of 40 CFR, looking at the chat, his explanation is suspiciously similar to a line from that exact reference. It looks like he might have just been copypasting and putting numbers where convenient. Note how 0.053ppm and 0.028ppm are both equal to 100 µg/m3 in the two quotes (and almost identical verbiage):
    • From chat (line 106):

      . . . 0.028 parts per million (ppm) (100 micrograms per cubic meter), annual arithmetic mean concentration.

    • From 40 CFR § 50.11(c):

      . . . 0.053 parts per million (100 micrograms per cubic meter), annual arithmetic mean concentration.

For PM2.5 and PM10, I realized that the numbers I'm getting from MQTT actually match what the Dyson app is showing me. The app displays a µg/m3 label with the graph. So I think it's actually reporting in µg/m3 over mqtt? The inconsistency is kinda strange but I guess I can't complain about something being reasonably certain in these circumstances.

1: he said that 0028 is 0.028ppm, which is 28ppb, so I'm interpreting that as measurement in ppb.

Anto79-ops commented 1 year ago

just when I thought I had this figured out....lol

I can't make any sense from the units now. I will defer to your wisdom and knowledge on this :) But, what you say above, makes sense. It could very well all be ppb plus minus a multiple factor of 1000.

that was an interesting conversation with the Dyson Chat. You explanation of what a unit is, its great! Professor!

dotvezz commented 1 year ago

To be honest, I think I'm just going to try to work out the conversion factors and match what the Dyson app is presenting. Unless I find a way to talk to an actual Dyson engineer, I've given up on understanding what the heck the base units are supposed to be.

dotvezz commented 1 year ago

I'll continue the conversation about units in #4 in an attempt to keep things on topic :sweat_smile:.

Anto79-ops commented 1 year ago

I'm tried to dig into this by finding out what devices are actually in the unit but so far no luck

Peronia commented 1 year ago

Hi, I have a new Dyson Purifier Cool Autoreact TP7A, this one: https://www.dyson.de/raumklima/luftreiniger/purifier-cool-autoreact-tp7a/weiss-nickel I added it to myDyson account and the cloud integration still says no devices found. So this device isn't supported?

mundschenk-at commented 1 year ago

Hi, I have a new Dyson Purifier Cool Autoreact TP7A, this one: https://www.dyson.de/raumklima/luftreiniger/purifier-cool-autoreact-tp7a/weiss-nickel I added it to myDyson account and the cloud integration still says no devices found. So this device isn't supported?

Since the "autoreact" devices don't have app support, do they even have WiFi? I don't think these can be integrated (other than by cloning the remote control maybe) into a smart home system.

Peronia commented 1 year ago

Hi, I have a new Dyson Purifier Cool Autoreact TP7A, this one: https://www.dyson.de/raumklima/luftreiniger/purifier-cool-autoreact-tp7a/weiss-nickel I added it to myDyson account and the cloud integration still says no devices found. So this device isn't supported?

Since the "autoreact" devices don't have app support, do they even have WiFi? I don't think these can be integrated (other than by cloning the remote control maybe) into a smart home system.

No, they doesn't have wifi. But i don't know if they have MQTT.

mundschenk-at commented 1 year ago

No, they doesn't have wifi. But i don't know if they have MQTT.

Without an underlying network connection, how should MQTT messages be sent?

Peronia commented 1 year ago

I have many devices without wifi but with some other support, so how should I answer this?

mundschenk-at commented 1 year ago

"Some other support" for what?

MQTT needs a transport layer connection. That could be ethernet, WiFi, or even ZigBee, true. But those devices are Dyson's low cost line that doesn't include WiFi hardware - why on earth would you think they've added another networking subsystem that's not in the more expensive product line?

Peronia commented 1 year ago

Things change, so why not Dyson's devices? Anyway, is known what protocoll the remote control uses?

GitPetri commented 1 year ago

Things change, so why not Dyson's devices? Anyway, is known what protocoll the remote control uses?

Dyson remotes use infrared. Controlling a non-networked device with Home Assistant can be done but requires additional hardware. For example I have a couple of IR-remote devices (not Dyson thou) that are conrolled via Broadlink RM4 pro blaster and the HA Broadlink integration

Peronia commented 1 year ago

Thanks @GitPetri, I have my Dysons (three) in seperate rooms, so I need 3 devices.. I'm not sure if i will set it up, we have mainly good air conditions here. But the Dyson model which wifi costs 200€ more per unit, I am not willing to pay that.

dotvezz commented 1 year ago

Hey @Peronia! As far as I've I've been able to determine, the cheaper models without wifi don't have any connectivity at all.

This means that I cannot support them in this integration. The integration itself depends on reverse-engineering the mobile apps to learn about the undocumented MQTT broker that the wifi-enabled devices have. So if the app doesn't support it, then sadly neither can I.

You're right that the wifi tax for these devices is kinda crazy.

catgirlkara commented 1 year ago

If I were to manually enter device details in configuration.yaml what would that look like? The "manual" configuration isn't working for me. image

dotvezz commented 1 year ago

If I were to manually enter device details in configuration.yaml what would that look like?

@catgirlkara great question. This may be frustrating, but I don't have a clear answer for you using configuration.yaml. Home Assistant has adopted a stance against supporting YAML configuration in integrations. If we're not able to solve your problem in another way, let's circle back to the yaml though.

I see you selected Purifier Hot+Cool. It's possible you're running into a quirk of Dyson devices starting with the that particular model. There's one more bit of information we'll need: the "device type." By any chance, did you use the get_devices.py script to get your credentials? If so, what was the "device type" result for your device? If it says "527E", the only fully supported way to set up your device is by linking your MyDyson account to the integration. After initial discovery and setup of your device, there's zero dependency on the MyDyson account so you can safely remove the MyDyson entry if you want to.

Click here if you want more details as to why it works out this way Each Dyson device has a product type that we need to know in order to connect to it. Before 2021, it was easy because each model had a specific code: the Pure Hot+Cool HP04 was 527, the Pure Cool TP04 was 438. But starting in 2021, the HP07 (Purifier Hot+Cool) and HP09 (Purifier Hot+Cool Formaldehyde) were released, and they both share the product codes 527K and 527E. Most or all of the devices released starting in 2021 have this issue, and we haven't found a reliable way to get the correct value other than using the Dyson App API. Because the original code for this integration was written to depend on the "old" 1:1 relationships between model numbers and device types, despite the model showing up in that select menu, it only works if your device code is 527K. That's why the only fully supported way to add the Purifier Hot+Cool HP07 is by connecting a MyDyson account, which automatically fetches the device metadata from the API.
dotvezz commented 1 year ago

Closing this thread to clean up the issues page. Feel free to post any new discussions in the Github Discussions section!