sanghviharshit / ha-mila Goto Github PK
View Code? Open in Web Editor NEW🏡 💨 Home Assistant custom component for Mila Air Purifier (Unofficial)
Home Page: http://rwrd.io/mtcrbhl
License: MIT License
🏡 💨 Home Assistant custom component for Mila Air Purifier (Unofficial)
Home Page: http://rwrd.io/mtcrbhl
License: MIT License
Every few days my Mila auth token expires and I need to follow the 'reconfigure' flow, supplying my password.
Instead of this, assuming refresh tokens are not supported, I would prefer to entrust my password to the plugin, and for it to reauthenticate automatically.
Hello - Thank you for this great integration with my Mila! I hope I can get it working.
When I add the Mila Integration and am prompted to log in I am getting "Invalid Login". I know I am using the correct credentials because I can log in to the Mila app successfully. Any thoughts?
I am getting this error under logs:
This error originated from a custom integration.
Logger: custom_components.mila.config_flow
Source: custom_components/mila/config_flow.py:73
Integration: Mila (documentation, issues)
First occurred: 3:50:22 PM (3 occurrences)
Last logged: 3:53:23 PM
Status: 500, Error Message: Error with get https://api.milacares.com/mms/appliances/meta
Status: 500, Error Message: Error with get https://id.milacares.com/auth/realms/prod/protocol/openid-connect/auth
I found the warning below in my logfiles:
2023-01-16 09:17:00.587 WARNING (MainThread) [homeassistant.helpers.frame] Detected integration that accesses the `is_metric` property of the unit system. This is deprecated and will stop working in Home Assistant 2023.1. Please adjust to use instance check instead.. Please report issue to the custom integration author for mila using this method at custom_components/mila/entities/location/distance_sensor.py, line 44: return self.device.hass.config.units.is_metric
Home Assistant 2023.1.4
Thanks :) !
Using the HASS HomeKit Bridge and enabling all the sensors, everything else shows up fine (the fans, temp, humidity, CO, CO2, VOC, PM2.5 and PM10) but the PM1 and (indoor) "Room" AQI doesn't show up in HomeKit? Why might this be?
If this is obvious... apologies in advance. I'm new to Home Assistant and have not yet dived in deep enough to figure this out on my own — and wondering if there is something up that the integration author might want to be aware of. Or is this expected behaviour?
Entered my username and password and entity was not added. Here are the log entries:
2023-09-03 16:24:30.664 WARNING (MainThread) [homeassistant.config_entries] Config entry 'm******@***.com' for mila integration not ready yet: Error communicating with API: Transport reported query error; Retrying in background
2023-09-03 16:24:36.159 DEBUG (MainThread) [custom_components.mila.update_coordinator] Setting up coordinator
2023-09-03 16:24:36.159 DEBUG (MainThread) [custom_components.mila.update_coordinator] Getting first refresh
2023-09-03 16:24:36.385 DEBUG (MainThread) [custom_components.mila.update_coordinator] Finished fetching mila data in 0.225 seconds (success: False)
I also reinatalled the HACS module and set up the integration. No luck. Thank for any assistance.
First of all, I want to say thank you for your hard work on this integration. Mila was one of the biggest missing pieces for me in Home Assistant.
The integration was working flawlessly for me since you released it, until yesterday, when both of my Milas became unavailable. I reloaded the integration hoping it would fix the issue, but it didn't. Tonight, I updated to Home Assistant Core 2022.6, uninstalled the integration and reinstalled it, but am unable to login with the correct credentials.
Any insight? Thanks again.
The information about the integration is out of date, because there is actually a native integration of Mila for Alexa and Google Home. See here: https://milacares.com/support.html#amazon-alexa
The Mila support staff also mentioned they implemented a HomeKit integration and will announce it this year.
BTW there a typo in line 31 of the readme: air auality
Hello!
I'm not sure if this is an issue with this integration or with my Mila account. I have 4 Mila devices, and this integration detects 4 devices, but 2 of them control the exact same Mila and none of them control my 4th unit.
Wondering if you might have any troubleshooting tips, or if this is something I will need to work with Mila to correct in my account in some way? Thanks!
This was working great until a month or so ago. The Integration for Mila no longer appears in the +Integrations, though it does still come up and install in the HACS.
Hello,
Great work on this! I really was hoping Mila API would be out by now. But you solved this wounderfuly!
Just wondering if i missed something. Buy HA is showing Mila Temps in C vs the App shoing in F. My other Temp Sensors are reporting correctly in F. Is there a setting I missed or what?
It seems that the indoor sensor (sensor.location_air_quality) is fixed for the statistics card changes that were made a while back, but the outdoor/purple air sensor.location_aqi still needs fixed.
see: https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics
2022-06-01 20:30:37 INFO (MainThread) [custom_components.mila.milacloud] get https://api.milacares.com/mms/appliances/meta
2022-06-01 20:30:39 INFO (MainThread) [custom_components.mila.milacloud] 502, message='Bad Gateway', url=URL('https://api.milacares.com/mms/appliances/meta')
Hello,
I am currently on 2024.6.0b7 release and there like they added blocking call detection in 2024.6.0. not sure how to reolve this but reporting so it not a surprise.
Detected blocking call to open inside the event loop by custom integration 'mila' at custom_components/mila/update_coordinator.py, line 37: self._api = MilaApi(MilaConfigEntryAuth(hass, config_entry, MilaOauthImplementation(hass, config_entry))) (offender: /usr/local/lib/python3.12/site-packages/milasdk/api.py, line 38: with open(Path(__file__).parent / './gql/mila_schema.gql') as f:), please create a bug report at https://github.com/sanghviharshit/ha-mila/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 188, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 447, in _async_setup_component await asyncio.gather( File "/usr/src/homeassistant/homeassistant/setup.py", line 449, in <genexpr> create_eager_task( File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 742, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/mila/__init__.py", line 19, in async_setup_entry coordinator = MilaUpdateCoordinator(hass, entry) File "/config/custom_components/mila/update_coordinator.py", line 37, in __init__ self._api = MilaApi(MilaConfigEntryAuth(hass, config_entry, MilaOauthImplementation(hass, config_entry)))
it seems after the recent update the configuration via UI is not working anymore.
I have tried removing mila from custom components, restarting ha, installing again, and restarting ha before adding again from integrations.
Always getting the same message:
This integration does not support configuration via the UI. If you followed this link from the Home Assistant website, make sure you run the latest version of Home Assistant.
I haven’t checked the other sensors but CO2 across my three Mila’s hasn’t budged from 411 since I installed the integration.
Anyone else experiencing this?
I’ve tried restarting the integration as well as uninstalling and reinstalling.
Getting this error on my Mila stuff in Home assistant. Seemed to happen after updating to 8ed6332
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 353, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/mila/init.py", line 19, in async_setup_entry
coordinator = MilaUpdateCoordinator(hass, entry)
File "/config/custom_components/mila/update_coordinator.py", line 37, in init
self._api = MilaApi(MilaConfigEntryAuth(hass, config_entry, MilaOauthImplementation(hass, config_entry)))
File "/config/custom_components/mila/auth.py", line 43, in init
self._auth = milasdk.MilaOauth2(token=cast(dict, config_entry.data["token"]))
KeyError: 'token'
Any idea what’s causing this please?
`This error originated from a custom integration.
Logger: homeassistant
Source: custom_components/mila/devices/device.py:85
Integration: Mila Cares (documentation, issues)
First occurred: 20:58:58 (25 occurrences)
Last logged: 21:49:59
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 348, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 533, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 571, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 539, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 388, in state
value = self.native_value
File "/config/custom_components/mila/entities/location/aqi_sensor.py", line 21, in native_value
pm25: float = self.device.get_value("outdoorStation.sensor.latest.value")
File "/config/custom_components/mila/devices/device.py", line 85, in get_value
return self._device_data[data_path]
File "/usr/local/lib/python3.10/site-packages/benedict/dicts/init.py", line 54, in getitem
super(benedict, self).getitem(key))
File "/usr/local/lib/python3.10/site-packages/benedict/dicts/keypath/keypath_dict.py", line 36, in getitem
return super(KeypathDict, self).getitem(
File "/usr/local/lib/python3.10/site-packages/benedict/dicts/keylist/keylist_dict.py", line 42, in getitem
return self._getitem_by_keys(key)
File "/usr/local/lib/python3.10/site-packages/benedict/dicts/keylist/keylist_dict.py", line 49, in _getitem_by_keys
raise KeyError('Invalid keys: "{}"'.format(keys))
KeyError: 'Invalid keys: "['outdoorStation', 'sensor', 'latest', 'value']"'
`
Yesterday I noticed this integration stopped updating the sensors, so I tried the phone app and noticed that I got logged out from it, I logged back in with no issues.
Since then, this integration hasn't worked, I tried reloading the integration yesterday and today and I get the following error:
`Log Details (WARNING)
Logger: homeassistant.config_entries
Source: config_entries.py:1088
First occurred: November 6, 2022 at 9:11:06 PM (2 occurrences)
Last logged: 8:43:28 AM
Config entry '*@.com' for mila integration not ready yet: Error communicating with API: Failed to get a valid response from Mila API service; Retrying in background`
Anyone else having the same issue?
I'm suspecting Mila made changes again on their end.
I found another of these in my logfiles but for a different sensor:
2023-01-16 09:17:00.306 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.living_room_voc (<class 'custom_components.mila.entities.appliance.measurement_sensor.MilaApplianceMeasurementSensor'>) is using native unit of measurement 'ppb' which is not a valid unit for the device class ('volatile_organic_compounds') it is using; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Is it related to my setup or a known issue?
Hello,
async_get_registry has been deprecated as of 2022.6.0
Logger: homeassistant.helpers.frame
Source: helpers/frame.py:103
First occurred: June 3, 2022, 11:29:10 PM (1 occurrences)
Last logged: June 3, 2022, 11:29:10 PM
Detected integration that uses deprecated async_get_registry
to access device registry, use async_get instead. Please report issue to the custom component author for mila using this method at custom_components/mila/init.py, line 81: device_registry = await hass.helpers.device_registry.async_get_registry()
I found this in my logfiles:
2023-01-16 09:17:00.469 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor_XXX_aqi (<class 'custom_components.mila.entities.location.aqi_sensor.MilaLocationAqiSensor'>) is using native unit of measurement '' which is not a valid unit for the device class ('aqi') it is using; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Is this a known issue or related to my setup?
Since the Mila server maintenance, I see a lot of error in the HA log relating to updating the pm25 sensor. These seem to happen when ever trying to set the fan speed or when the update coordinator tries to update the sensor. The PM25 sensor appear to have not worked since arounf 18:00 BST 28/05/24
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 492, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1009, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1015, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 543, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/config/custom_components/mila/entities/location/aqi_sensor.py", line 21, in native_value
pm25: float = self.device.get_value("outdoorStation.sensor.latest.value")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/mila/devices/device.py", line 85, in get_value
return self._device_data[data_path]
~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/benedict/dicts/__init__.py", line 54, in __getitem__
super(benedict, self).__getitem__(key))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/benedict/dicts/keypath/keypath_dict.py", line 36, in __getitem__
return super(KeypathDict, self).__getitem__(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/benedict/dicts/keylist/keylist_dict.py", line 42, in __getitem__
return self._getitem_by_keys(key)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/benedict/dicts/keylist/keylist_dict.py", line 49, in _getitem_by_keys
raise KeyError('Invalid keys: "{}"'.format(keys))
KeyError: 'Invalid keys: "[\'outdoorStation\', \'sensor\', \'latest\', \'value\']"'
Looks like something broke after their most recent server maintenance. I can't find any more helpful logs.
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
sys.exit(main())
File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
handle._run()
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/setup.py", line 167, in async_setup_component
result = await _async_setup_component(hass, domain, config)
File "/usr/src/homeassistant/homeassistant/setup.py", line 449, in _async_setup_component
await asyncio.gather(
File "/usr/src/homeassistant/homeassistant/setup.py", line 451, in <genexpr>
create_eager_task(
File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task
return Task(coro, loop=loop, name=name, eager_start=True)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 734, in async_setup_locked
await self.async_setup(hass, integration=integration)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/mila/__init__.py", line 19, in async_setup_entry
coordinator = MilaUpdateCoordinator(hass, entry)
File "/config/custom_components/mila/update_coordinator.py", line 37, in __init__
self._api = MilaApi(MilaConfigEntryAuth(hass, config_entry, MilaOauthImplementation(hass, config_entry)))
I'm getting a large number of errors appearing in the logs
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 899, in _async_registry_updated
await self.platform.async_add_entities([self])
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 673, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 776, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 570, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 969, in state
if (is_on := self.is_on) is None:
File "/config/custom_components/mila/entities/appliance/fan.py", line 66, in is_on
return self.speed is not None and self.speed > 0
File "/config/custom_components/mila/entities/appliance/fan.py", line 57, in speed
return sensor["latest"]["value"] if sensor else None
TypeError: 'NoneType' object is not subscriptable
The relevant code:
ha-mila/custom_components/mila/entities/appliance/fan.py
Lines 53 to 57 in c097220
The release notes show this deprecated module was removed: home-assistant/core#101199
Unexpected error fetching mila data: No module named 'homeassistant.util.distance'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/mila/update_coordinator.py", line 105, in _async_update_data
await self._build_devices(data)
File "/config/custom_components/mila/update_coordinator.py", line 119, in _build_devices
self.devices[id] = MilaAppliance(self, self._api, id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/mila/devices/appliance.py", line 33, in __init__
super().__init__(coordinator, api, device_id)
File "/config/custom_components/mila/devices/device.py", line 24, in __init__
self._build_entities_list()
File "/config/custom_components/mila/devices/device.py", line 92, in _build_entities_list
from ..entities import MilaEntity
File "/config/custom_components/mila/entities/__init__.py", line 3, in <module>
from .location import *
File "/config/custom_components/mila/entities/location/__init__.py", line 3, in <module>
from .distance_sensor import MilaLocationDistanceSensor
File "/config/custom_components/mila/entities/location/distance_sensor.py", line 9, in <module>
from homeassistant.util.distance import convert as distance_convert
ModuleNotFoundError: No module named 'homeassistant.util.distance'
Hi, just got my Mila yesterday, installed your integration and all working great! Thanks for your work!
I did notice an entry in the logs and thought I'd log it here...
Detected integration that uses distance utility. This is deprecated since 2022.10 and will stop working in Home Assistant 2022.4, it should be updated to use unit_conversion.DistanceConverter instead. Please report issue to the custom integration author for mila using this method at custom_components/mila/entities/location/distance_sensor.py, line 34: val = distance_convert(val, LENGTH_KILOMETERS, LENGTH_MILES)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.