Limych / ha-gismeteo

Gismeteo Weather Provider for Home Assistant
Other
119 stars 21 forks source link

Minimal yaml-config causes errors #193

Closed ildar170975 closed 4 months ago

ildar170975 commented 4 months ago

System Health details

System Information

version core-2024.5.3
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 5.10.0-16-amd64
arch x86_64
timezone Europe/Moscow
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1414 Downloaded Repositories | 54 HACS Data | failed to load: timeout
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Dashboards dashboards | 16 -- | -- resources | 39 views | 469 mode | storage
Recorder oldest_recorder_run | May 11, 2024 at 21:38 -- | -- current_recorder_run | May 18, 2024 at 04:17 estimated_db_size | 578.91 MiB database_engine | sqlite database_version | 3.44.2

Checklist

Describe the issue

According to Docs - all options are optional:

изображение

But this minimal config

gismeteo:
  home_gismeteo:

causes an error: изображение

This config

gismeteo:
  home_gismeteo:
    sensors:

causes an error: изображение

This minimal config (provided in Docs) does NOT cause errors:

gismeteo:
  home_gismeteo:
    sensors: {}

Also, it is said in Docs that the sensors option is a list: изображение but it is surely not a list since it has one sub-option forecast_days (declared as optional).

Reproduction steps

see above

Debug logs

2024-05-18 04:17:19.507 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration gismeteo 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
2024-05-18 04:17:21.657 INFO (MainThread) [homeassistant.bootstrap] Setting up stage 2: {'narodmon', 'stt', 'iphonedetect', 'energy', 'template', 'search', 'input_boolean', 'system_health', 'input_number', 'input_datetime', 'input_button', 'places', 'season', 'history', 'hardware', 'image_upload', 'default_config', 'tag', 'openweathermap', 'custom_templates', 'diagnostics', 'version', 'media_source', 'notify', 'command_line', 'lock', 'counter', 'switch', 'zone', 'timer', 'application_credentials', 'file_upload', 'weather', 'persistent_notification', 'light', 'met', 'input_select', 'systemmonitor', 'analytics', 'schedule', 'intent', 'person', 'fontawesome', 'onboarding', 'script', 'backup', 'asuswrt', 'python_script', 'logbook', 'traccar_server', 'trace', 'mobile_app', 'map', 'hacs', 'group', 'input_text', 'composite', 'blueprint', 'filesize', 'uptime', 'lovelace', 'scene', 'ffmpeg', 'tts', 'device_automation', 'cover', 'gismeteo', 'ping', 'homeassistant_alerts', 'automation', 'fan', 'wake_word', 'starline', 'virtual', 'assist_pipeline', 'device_tracker', 'waze_travel_time', 'kodi', 'sun', 'sensor', 'stream', 'conversation', 'telegram_bot', 'config', 'my', 'simpleicons'}
2024-05-18 04:17:21.812 INFO (MainThread) [homeassistant.setup] Setting up gismeteo
2024-05-18 04:17:21.812 INFO (MainThread) [custom_components.gismeteo]
Gismeteo
https://github.com/Limych/ha-gismeteo/issues
2024-05-18 04:17:21.812 INFO (MainThread) [homeassistant.setup] Setup of domain gismeteo took 0.00 seconds
2024-05-18 04:17:22.430 DEBUG (MainThread) [custom_components.gismeteo.cache] Initializing cache
2024-05-18 04:17:22.430 DEBUG (MainThread) [custom_components.gismeteo.api] Place coordinates: xxx, xxx
2024-05-18 04:17:22.430 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://services.gismeteo.ru/inform-service/inf_chrome/cities/?lat=xxx&lng=xxx&count=1&lang=en
2024-05-18 04:17:45.600 DEBUG (MainThread) [custom_components.gismeteo.api] Data retrieved from https://services.gismeteo.ru/inform-service/inf_chrome/cities/?lat=xxx&lng=xxx&count=1&lang=en, status: 200
2024-05-18 04:17:45.601 DEBUG (MainThread) [custom_components.gismeteo.cache] Store cache file /config/.storage/gismeteo.location_xxx_xxx.xml
2024-05-18 04:17:45.602 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en
2024-05-18 04:17:48.819 DEBUG (MainThread) [custom_components.gismeteo.api] Data retrieved from https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en, status: 200
2024-05-18 04:17:48.820 DEBUG (MainThread) [custom_components.gismeteo.cache] Store cache file /config/.storage/gismeteo.forecast_yyyyy.xml
2024-05-18 04:17:48.822 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en
2024-05-18 04:17:48.823 DEBUG (MainThread) [custom_components.gismeteo.api] Cached response used
2024-05-18 04:17:48.823 DEBUG (MainThread) [custom_components.gismeteo.cache] Read cache file /config/.storage/gismeteo.forecast_yyyyy.xml
2024-05-18 04:17:48.825 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://www.gismeteo.ru/weather-yyyyy-yyyyy/10-days/
2024-05-18 04:17:51.206 DEBUG (MainThread) [custom_components.gismeteo.api] Data retrieved from https://www.gismeteo.ru/weather-yyyyy-yyyyy/10-days/, status: 200
2024-05-18 04:17:51.213 DEBUG (MainThread) [custom_components.gismeteo.cache] Store cache file /config/.storage/gismeteo.forecast_parsed_yyyyy.xml
2024-05-18 04:17:51.323 DEBUG (MainThread) [custom_components.gismeteo] Finished fetching gismeteo data in 5.721 seconds (success: True)
2024-05-18 04:17:51.392 INFO (MainThread) [homeassistant.components.sensor] Setting up gismeteo.sensor
2024-05-18 04:17:51.392 INFO (MainThread) [homeassistant.components.weather] Setting up gismeteo.weather
2024-05-18 04:17:51.392 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new weather.gismeteo entity: weather.home_gismeteo
2024-05-18 04:19:58.840 WARNING (MainThread) [homeassistant.core] Something is blocking Home Assistant from wrapping up the start up phase. We're going to continue anyway. Please report the following info at https://github.com/home-assistant/core/issues: season.sensor, homeassistant.scene, systemmonitor.binary_sensor, repairs, stt, kodi.media_player, api, template, search, template.binary_sensor, template.switch, system_health, xiaomi_miio_airpurifier.fan, cloud.tts, iphonedetect.device_tracker, ssdp, input_button, snmp.sensor, auth, recorder, hardware, bluetooth, tag, openweathermap.sensor, openweathermap, diagnostics, custom_templates, version, media_source, systemmonitor.sensor, default_config, command_line, counter, switch, weather, file_upload, zeroconf, mobile_app.notify, met.weather, persistent_notification, starline.button, intent, person, system_log, backup, starline.sensor, starline.switch, netdata.sensor, openhardwaremonitor.sensor, python_script, version.binary_sensor, mobile_app.binary_sensor, traccar_server, template.fan, mobile_app, hacs, webhook, virtual.fan, starline.device_tracker, filesize, lovelace, virtual.lock, ping.device_tracker, device_automation, logger, gismeteo, cover, ping.binary_sensor, gismeteo.weather, virtual.light, wake_word, fan, history_stats.sensor, ping.sensor, starline, filesize.sensor, network, websocket_api, virtual, waze_travel_time, template.cover, sun.sensor, derivative.sensor, kodi, http, virtual.device_tracker, sensor, config, telegram_bot, my, simpleicons, google_translate.tts, command_line.sensor, binary_sensor, template.sensor, narodmon, iphonedetect, energy, input_boolean, input_number, uptime.sensor, telegram.notify, input_datetime, media_player, places, season, history, image_upload, usb, composite.device_tracker, notify, lock, zone, timer, application_credentials, websocket_api.sensor, light, met, input_select, systemmonitor, update, hacs.update, clear_grass.sensor, analytics, schedule, fontawesome, onboarding, mobile_app.device_tracker, script, asuswrt, logbook, trace, energy.sensor, map, integration.sensor, starline.lock, gismeteo.sensor, group, input_text, composite, homeassistant, blueprint, mobile_app.sensor, uptime, version.sensor, scene, ffmpeg, tts, homeassistant_alerts, ping, cloud, starline.binary_sensor, automation, hacs.sensor, button, dhcp, frontend, assist_pipeline, device_tracker, composite.sensor, sun, image, waze_travel_time.sensor, stream, conversation, openweathermap.weather, template.image, places.sensor The system is waiting for tasks: {<Task pending name='Task-3293' coro=<HacsBase.startup_tasks() running at /config/custom_components/hacs/base.py:687> wait_for=<_GatheringFuture pending cb=[Task.task_wakeup()]> cb=[set.remove()]>}
2024-05-18 04:22:51.141 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en
2024-05-18 04:22:51.451 DEBUG (MainThread) [custom_components.gismeteo.api] Data retrieved from https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en, status: 200
2024-05-18 04:22:51.452 DEBUG (MainThread) [custom_components.gismeteo.cache] Store cache file /config/.storage/gismeteo.forecast_yyyyy.xml
2024-05-18 04:22:51.454 DEBUG (MainThread) [custom_components.gismeteo] Finished fetching gismeteo data in 0.313 seconds (success: True)
2024-05-18 04:27:51.141 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en
2024-05-18 04:27:51.142 DEBUG (MainThread) [custom_components.gismeteo.api] Cached response used
2024-05-18 04:27:51.142 DEBUG (MainThread) [custom_components.gismeteo.cache] Read cache file /config/.storage/gismeteo.forecast_yyyyy.xml
2024-05-18 04:27:51.144 DEBUG (MainThread) [custom_components.gismeteo] Finished fetching gismeteo data in 0.002 seconds (success: True)
2024-05-18 04:32:51.142 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en
2024-05-18 04:33:01.143 ERROR (MainThread) [custom_components.gismeteo] Timeout fetching gismeteo data
2024-05-18 04:33:01.144 DEBUG (MainThread) [custom_components.gismeteo] Finished fetching gismeteo data in 10.002 seconds (success: False)
2024-05-18 04:38:01.140 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en
2024-05-18 04:38:11.141 DEBUG (MainThread) [custom_components.gismeteo] Finished fetching gismeteo data in 10.001 seconds (success: False)
2024-05-18 04:43:11.141 DEBUG (MainThread) [custom_components.gismeteo.api] Requesting URL https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en
2024-05-18 04:43:11.184 DEBUG (MainThread) [custom_components.gismeteo.api] Data retrieved from https://services.gismeteo.ru/inform-service/inf_chrome/forecast/?city=yyyyy&lang=en, status: 200
2024-05-18 04:43:11.185 DEBUG (MainThread) [custom_components.gismeteo.cache] Store cache file /config/.storage/gismeteo.forecast_yyyyy.xml
2024-05-18 04:43:11.187 INFO (MainThread) [custom_components.gismeteo] Fetching gismeteo data recovered
2024-05-18 04:43:11.187 DEBUG (MainThread) [custom_components.gismeteo] Finished fetching gismeteo data in 0.046 seconds (success: True)

Diagnostics dump

No response

ildar170975 commented 4 months ago

In addition: it is unclear how to add sensors & keep a default forecast_days.

Limych commented 4 months ago

In addition: it is unclear how to add sensors & keep a default forecast_days.

Let's first solve the problem of adding sensors that is unclear.

Now it is possible to change the format of the settings. I see several ways:

Your suggestion?

Limych commented 4 months ago

BTW, minimal config now is

gismeteo:
  home_gismeteo: {}
ildar170975 commented 4 months ago

My assumptions are based on Docs; so I could be wrong if an implementation is different.

Currently we have this structure:

sensors:
  forecast_days: xxx

Seems the sensors option is a dictionary with the only sub-option forecast_days. Probably you may add more sub-options inside.

If you move the sensors options into another option or replace it with another option - it could be considered as a breaking change; not cool to have it again after "3.0.0-beta1" - some users have already considered 1st breaking changes in their HA setups. From another side, these are still "beta" updates (people are using betas on their own risk), so you still can change everything. Besides, I guess most people using UI config & do not care about changes in yaml config.

Assume you decide to keep the current structure "sensors -> forecast_days". What we may wish to configure is: 1.Create (or not) forecast sensors; if yes - for how many days. If forecast_days is 0..6 - then forecast sensors are created. If forecast_days is missing - not created.

2.Create or not sensors. Here there are 2 ways: 2.1.If "yes" - then ALL sensors are created - but only SOME of them (up to a developer to decide) are enabled, rest are disabled. By default - none sensors are created (only a weather entity). This way may be achieved by adding a new option:

sensors:
  ... other possible options ...
  add_sensors: true

If the option is false or missing - none sensors are created. Note that forecast_days must be ignored if add_sensors: false: not possible to add forecast sensors if you do not add "usual" sensors.

User may define add_sensors: true, then enable/disable sensors as he wishes. If needed - may define forecast_days.

2.2.Another way - user may list all sensors which should be created:

sensors:
  ... other possible options ...
  add_sensors:
    - temperature
    - pressure
    - humidity

Here 3 sensors are created and enabled, other sensors not even created. This value causes "none sensors are created":

  add_sensors: []

Same - if the add_sensors is missing. And probably add_sensors & forecast_days should be independent (contrary to way 1 above), i.e. it could be possible to define

sensors:
  ... other possible options ...
  add_sensors: []
  forecast_days: 2

since the add_sensors option is only used for "usual" sensors. Although this way allows to define only needed sensors (and do not depend on UI - which is great for users who prefer configs in packages) - I find it confusing: -- need to check entries in add_sensors, a user may define temprature instead of temperature; -- some parameters may be renamed in future, a user have to track these changes; -- imho there is a little of sense in having options add_sensors & forecast_days independent.

So, I would choose way 1.


As for a minimal config. Assume we have a structure:

gismeteo:
  home:
    sensors:
      add_sensors: true
      forecast_days: 2

Since both sub-options are optional - this leads to the minimal config

gismeteo:
  home:
    sensors:

which has no sense. So I would choose these minimal configs as allowed:

gismeteo:
  home:
    sensors:
      add_sensors: true
gismeteo:
  home:

As for this

gismeteo:
  home: {}

imho it does not follow usual ways in HA: check these examples of minimal default config:

input_boolean:
  some_boolean:

recorder:

demo:
Limych commented 4 months ago

The option with an explicit indication of the sensors to be added is untenable. That's why it was initially removed from version 3.

As for a minimal config. Assume we have a structure:

gismeteo:
  home:
    sensors:
      add_sensors: true
      forecast_days: 2

Correct. But what’s the point in the sensor group? You can write it shorter like this:

gismeteo:
home:
add_sensors: true
forecast_days: 2
ildar170975 commented 4 months ago

But what’s the point in the sensor group? You can write it shorter like this:

gismeteo:

Sure, I proposed to keep forecast_days inside sensors only to avoid "breaking changes". But it is definitely simpler & clearer to get rid of this sensors option. So - yes, totally agree with

gismeteo:
  home:
    add_sensors: true
    forecast_days: 2

where both add_sensors & forecast_days are optional.

The final question - can it be defined as below? (minimal config)

gismeteo:
  home:

w/o that "{}".

Limych commented 4 months ago

The final question - can it be defined as below? (minimal config)

gismeteo:
  home:

w/o that "{}".

Already done but not pushed to github yet.

ildar170975 commented 4 months ago

Well done, thanks a lot! Awaiting for testing then.

Limych commented 4 months ago

Another question: does it make sense to give the user the opportunity to create forecast sensors without current weather sensors? I'm not sure.

ildar170975 commented 4 months ago

create forecast sensors without current weather sensors?

Imho this is meaningless. Earlier proposed:

Note that forecast_days must be ignored if add_sensors: false: not possible to add forecast sensors if you do not add "usual" sensors.

ildar170975 commented 4 months ago

I think this issue can be closed. Can see changes in beta4. Tested a bit, works as expected. Thanks a lot!