Limych / ha-narodmon

Component to integrate Narodmon cloud into Home Assistant
Other
28 stars 5 forks source link

Компонент не инициализируется из-за entry.source == SOURCE_IMPORT #149

Open lemon777 opened 2 weeks ago

lemon777 commented 2 weeks ago

System Health details

System Information

version core-2024.10.4
installation_type Home Assistant Core
dev false
hassio false
docker false
user homeassistant
virtualenv true
python_version 3.12.6
os_name Linux
os_version 6.6.54-current-sunxi
arch armv7l
timezone Asia/Aqtau
config_dir /home/homeassistant/.homeassistant
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok HACS Data | ok GitHub API Calls Remaining | 5000 Installed Version | 2.0.1 Stage | running Available Repositories | 1460 Downloaded Repositories | 7
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Dashboards dashboards | 2 -- | -- resources | 4 views | 1 mode | storage
Recorder oldest_recorder_run | October 29, 2024 at 1:41 PM -- | -- current_recorder_run | November 7, 2024 at 1:57 PM estimated_db_size | 450.23 MiB database_engine | sqlite database_version | 3.40.1

Checklist

Describe the issue

По установке все сделал по инструкции, но девайса и сенсоров так не и появилось. Включение логирования, дебага ничего не показывало. В логах только одно сообщение от компонента

Narodmon Cloud Integration Version: 2.2.1 This is a custom integration! If you have ANY issues with this you need to open an issue here: https://github.com/Limych/ha-narodmon/issues

Поэтому пришлось самостоятельно расставить дополнительные логи. В итоге не проходит условие if entry.source == SOURCE_IMPORT, потому что в моём случае entry.source является "user". Поменял во всех местах на if entry.source == "user" и интеграция заработала

Reproduction steps

  1. Have HACS installed, this will allow you to easily manage and track updates.
  2. Search for "Narodmon".
  3. Click Install below the found integration.
  4. Сonfigure component via configuration.yaml

Debug logs

2024-11-07 13:57:45.572 INFO (MainThread) [custom_components.narodmon]
-------------------------------------------------------------------
Narodmon Cloud Integration
Version: 2.2.1
This is a custom integration!
If you have ANY issues with this you need to open an issue here:
https://github.com/Limych/ha-narodmon/issues
-------------------------------------------------------------------
2024-11-07 13:57:45.572 INFO (MainThread) [custom_components.narodmon] entry: '<ConfigEntry entry_id=01JC2HX7D3ZKXC2GM99ZWSNGD1 version=1 domain=narodmon title=Home Assistant state=ConfigEntryState.SETUP_IN_PROGRESS unique_id=None>'
2024-11-07 13:57:45.578 INFO (MainThread) [custom_components.narodmon] entry.source: 'user'
2024-11-07 13:57:45.578 INFO (MainThread) [custom_components.narodmon] entry.data: '{}'
2024-11-07 13:57:45.579 INFO (MainThread) [custom_components.narodmon] YAML_DOMAIN: '_yaml_narodmon'
2024-11-07 13:57:45.579 INFO (MainThread) [custom_components.narodmon] New client
2024-11-07 13:57:45.579 INFO (MainThread) [custom_components.narodmon] Devices: [{'name': 'Narodmon', 'search_area_radius': 50.0, 'latitude': 43.295263, 'longitude': 76.937541, 'show_on_map': True, 'sensors': ['temperature', 'humidity', 'pressure'], 'scan_interval': datetime.timedelta(seconds=180)}]
2024-11-07 13:57:45.580 INFO (MainThread) [custom_components.narodmon] New coordinator for: {'name': 'Narodmon', 'search_area_radius': 50.0, 'latitude': 43.295263, 'longitude': 76.937541, 'show_on_map': True, 'sensors': ['temperature', 'humidity', 'pressure'], 'scan_interval': datetime.timedelta(seconds=180)}
2024-11-07 13:57:45.580 INFO (MainThread) [custom_components.narodmon] Init NarodmonDataUpdateCoordinator
2024-11-07 13:57:45.580 INFO (MainThread) [custom_components.narodmon] _async_update_data
2024-11-07 13:57:45.581 INFO (MainThread) [custom_components.narodmon] _async_update_data: {}
2024-11-07 13:57:45.581 INFO (MainThread) [custom_components.narodmon] tps: {1, 2, 3}
2024-11-07 13:57:46.230 INFO (MainThread) [custom_components.narodmon] coordinator.async_refreshed
2024-11-07 13:57:46.231 INFO (MainThread) [custom_components.narodmon] DOMAIN: narodmon
2024-11-07 13:57:46.231 INFO (MainThread) [custom_components.narodmon] hass.data[DOMAIN]: {'01JC2HX7D3ZKXC2GM99ZWSNGD1': {0: <custom_components.narodmon.NarodmonDataUpdateCoordinator object at 0xb4091a80>}}
2024-11-07 13:57:46.231 INFO (MainThread) [custom_components.narodmon] async_forward_entry_setups
2024-11-07 13:57:46.231 INFO (MainThread) [custom_components.narodmon] entry: <ConfigEntry entry_id=01JC2HX7D3ZKXC2GM99ZWSNGD1 version=1 domain=narodmon title=Home Assistant state=ConfigEntryState.SETUP_IN_PROGRESS unique_id=None>
2024-11-07 13:57:50.675 INFO (MainThread) [homeassistant.components.sensor] Setting up narodmon.sensor
2024-11-07 13:57:50.689 INFO (MainThread) [custom_components.narodmon] async_forward_entry_setups DONE
2024-11-07 13:57:50.690 INFO (MainThread) [custom_components.narodmon] add_update_listener

Diagnostics dump

No response

strk90 commented 4 hours ago

Спасибо, за решение проблемы! Тоже заменил if entry.source == SOURCE_IMPORT на if entry.source == "user" и все заработало.