syssi / xiaomi_airpurifier

Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier integration for Home Assistant
Apache License 2.0
449 stars 110 forks source link

Component not loading when HA starts - HA 2021.3.x #162

Closed austwhite closed 3 years ago

austwhite commented 3 years ago

I have installed the Custom Component via HACS, but are unable to find it in the Integrations menu of Home Assistant. I installed the Custom Component using HACS method. I restarted Home Assistant. I checked integration menu and only the official Xiaomi Mi integration, which does not support the Air Purifier, is showing.

I checked the logs and although HACS has the component as Installed, there is absolutely no indication in the logs that it is loading. Below shows the only lines corresponding to Custom Components, and there is no indication of the xiaomi_airpurifier custom component loading. I am using HA 2021.3.1 currently using HASSOS install on a VM within ProxMox, but also tested on a Raspberry Pi 3B+ install and same issue occurred.

2021-04-06 17:36:19 WARNING (MainThread) [homeassistant.loader] You are using a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-04-06 17:36:30 WARNING (MainThread) [homeassistant.loader] You are using a custom integration bureau_of_meteorology which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-04-06 17:36:31 WARNING (MainThread) [homeassistant.loader] You are using a custom integration weatherbit which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-04-06 17:36:31 WARNING (MainThread) [homeassistant.loader] You are using a custom integration blueiris which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
foreignerby commented 3 years ago

@austwhite As I know, this component does not have any UI integration. You just need to add your humidifier editing your configuration.yaml

austwhite commented 3 years ago

In that case this has very misleading Install instructions as the install instruction states this:

You will find the custom component in the integration menu afterwards, look for 'Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier Integration'.

Yet there is no integration named that.

However, that aside, the component is actually not even loading, as shown in my log extracts. They are the only custom components loading, this one does not load and I have the exact same sensors/entities as I do when using the official component.

syssi commented 3 years ago

Do you use the official component or this custom component? The official version has config flow support and is shown at the integration page. This custom component doesn't support config flow right now. Where did you find the quoted instruction?

austwhite commented 3 years ago

The OFFICIAL component does not support Air Purifiers via Integration and never has done. I have this component installed in Custom Component, as per Install Instruction using HACS, though I have also done it manually. As you should be aware, in Home Assistant a Custom Component will override the official component if it is written correctly. This behaviour was present long before integrations ever were dreamt of.

As I have shown in logs in my original post, this custom component is not loading for me, despite being installed in Custom Components.

Does it load for you? IF you check your Core logs, does it have a warning stating the custom component is being loaded, as per my other 4 custom components that actually do load?

If it loads for you, then I need to work out why it does not load for me. As a note, same issue on Raspberry Pi as on the VM, as I noted in my OP. There is no log entry stating the custom component is loading.

As far as what I quoted you, that is directly from your own Install Instructions in your readme.md file.

Install You can install this custom component by adding this repository (https://github.com/syssi/xiaomi_airpurifier) to HACS in the settings menu of HACS first. You will find the custom component in the integration menu afterwards, look for 'Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier Integration'. Alternatively, you can install it manually by copying the custom_component folder to your Home Assistant configuration folder.

syssi commented 3 years ago

The OFFICIAL component does not support Air Purifiers via Integration and never has done.

The official component supports a few Air Purifiers. Is your device supported? If not use this custom component.

https://www.home-assistant.io/integrations/xiaomi_miio/#xiaomi-air-purifier-and-humidifier

​I have this component installed in Custom Component, as per Install Instruction using HACS, though I have also done it manually.

In both cases this custom component is copied to the custom_components folder. You should find a directory called xiaomi_miio_airpurifier here.

As you should be aware, in Home Assistant a Custom Component will override the official component if it is written correctly.

You are a bit harsh. In some cases a developer wants to override the official component. In this case the custom compoent has it's own namespace (xiaomi_miio_airpurifier vs xiaomi_miio). So please don't expect the official component is overridden. It's not!

This behaviour was present long before integrations ever were dreamt of.

This is true.

As I have shown in logs in my original post, this custom component is not loading for me, despite being installed in Custom Components.

Did you add the required config section of the custom component to the configuration.yaml? This is required to load the custom component:

https://github.com/syssi/xiaomi_airpurifier/#setup

Does it load for you? IF you check your Core logs, does it have a warning stating the custom component is being loaded, as per my other 4 custom components that actually do load?

It does load for me and I can see the warning.

If it loads for you, then I need to work out why it does not load for me. As a note, same issue on Raspberry Pi as on the VM, as I noted in my OP. There is no log entry stating the custom component is loading.

Please provide your relevant parts of the configuration.yaml.

As far as what I quoted you, that is directly from your own Install Instructions in your readme.md file.

Install You can install this custom component by adding this repository (https://github.com/syssi/xiaomi_airpurifier) to HACS in the settings menu of HACS first. You will find the custom component in the integration menu afterwards, look for 'Xiaomi Mi Air Purifier and Xiaomi Mi Air Humidifier Integration'. Alternatively, you can install it manually by copying the custom_component folder to your Home Assistant configuration folder.

This is the installation instruction. Did you read the paragraph about the setup?

austwhite commented 3 years ago

Apologies if I seem a bit harsh in the way I word things. Not my intention, it is just the way I tend to write things.

The official component does support majority of air purifiers, what I meant was air purifiers are not supported in the official Xiaomi Miio integration. Maybe a couple are, so I will say most air purifiers are not supported in the Xiaomi Miio Integration and can only be setup in yaml with no integration. That is something that attracted me here as the Install Instruction leads one to believe there is an integration, and even names it.

As far as my YAML

fan:  
  # Xiaomi Air Purifier Setup
  - platform: xiaomi_miio_airpurifier
    host: !secret xiaomi_ap_ip
    name: Air Purifier
    token: !secret xiaomi_ap_token
    model: !secret xiaomi_ap_model 

To use the official component I would load as follows:

fan:  
  # Xiaomi Air Purifier Setup
  - platform: xiaomi_miio
    host: !secret xiaomi_ap_ip
    name: Air Purifier
    token: !secret xiaomi_ap_token
    model: !secret xiaomi_ap_model

Obviously I am not going to paste my token here, but it seems to look okay, please let me know if it is not.

In my Custom Component folder I can see the xiaomi_miio_airpurifier folder and all the relevant files.

I am not quite sure why this particular component seems to just refuse to load.....

I appreciate the work you put in, I know it is all voluntary. I do often donate money to projects on Github and I do pay for the Home Assistant cloud component to support them also.

syssi commented 3 years ago

Looks good to me. May be a single piece of the puzzle is missing: This custom component doesn't show up as integration at the integration page of HA. I single entity at the fan platform is registered. Please check the http://your-hass-instace/developer-tools/state page. Do you see a entity called fan.air_purifier here?

austwhite commented 3 years ago

Unfortunately no, I can't see it listed...... It's baffling me to be honest

syssi commented 3 years ago
$ mkdir /tmp/austwhite
$ cd /tmp/austwhite
$
$ python3.8 -m venv .
$ source bin/activate
$ python3 -m pip install wheel

Collecting wheel
  Using cached https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl
Installing collected packages: wheel
Successfully installed wheel-0.36.2
$
$ pip3 install homeassistant
Collecting homeassistant
  Cache entry deserialization failed, entry ignored
  Using cached https://files.pythonhosted.org/packages/9e/bb/fbb6441cde045642b258a4ac96b4cfa2aa8f6d4befe6e91e5a74279d6bf7/homeassistant-2021.3.4-py3-none-any.whl
[...]
$
$ mkdir /tmp/austwhite/config
$ mkdir /tmp/austwhite/config/custom_components
$
$ cd /tmp
$ wget https://github.com/syssi/xiaomi_airpurifier/archive/refs/tags/0.6.4.zip
$ unzip 0.6.4
$ mv xiaomi_airpurifier-0.6.4/custom_components/xiaomi_miio_airpurifier /tmp/austwhite/config/custom_components/

$ cat > config/configuration.yaml <<EOF
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

fan:
  - platform: xiaomi_miio_airpurifier
    name: Air Purifier
    host: !secret xiaomi_airpurifier_host
    token: !secret xiaomi_airpurifier_token
    model: zhimi.airpurifier.m1
EOF

$ bin/hass -c ./config
2021-04-06 13:35:12 WARNING (MainThread) [homeassistant.loader] You are using a custom integration xiaomi_miio_airpurifier which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

I've made a fresh install as PoC ;-)

entities

austwhite commented 3 years ago

Yes, that is how I would have expected to see it also...

I'll have to play with it more tomorrow as it is almost 10pm here ( I am in Australia ).

Thanks for your help so far. I do apprciate it

austwhite commented 3 years ago

I really don't know why this doesn't work for me, but the latest release of Home Assistant seems to be happy supporting my Air Purifier via integration with official component, so I will close this issue as I will use official integration :).

I appreciate all your help, This issue must just be something specific on my system.