项目作者: kpisacic

项目描述 :
Home Assistant Custom Components for DHMZ service ("Državni hidrometeorološki zavod Republike Hrvatske / "Croatian Meteorological and Hydrological Service" )
高级语言: Python
项目地址: git://github.com/kpisacic/DHMZ-home-assistant-custom-component.git
创建时间: 2019-11-16T12:01:20Z
项目社区:https://github.com/kpisacic/DHMZ-home-assistant-custom-component

开源协议:MIT License

下载


DHMZ-home-assistant-custom-component

Home Assistant Custom Components for DHMZ weather service (“Državni hidrometeorološki zavod Republike Hrvatske” / “Croatian Meteorological and Hydrological Service”)

The dhmz weather platform provide meteorological data for DHMZ service (“Državni hidrometeorološki zavod Republike Hrvatske / “Croatian Meteorological and Hydrological Service”) - https://meteo.hr/ . Data from DHMZ is listed on https://meteo.hr/proizvodi.php?section=podaci¶m=xml_korisnici and provided under Open Licence of Republic of Croatia - https://data.gov.hr/otvorena-dozvola and https://data.gov.hr/open-licence-republic-croatia .
Custom weather card is also included in the package, combining graphical forecast data in weather card.

The following device types and data are supported:

Installation

There are two options; manual or HACS installation:

Manual installation

  • Copy dhmz folder in custom_components from repository to your Home Assistant configuration custom_components folder. Don’t copy any other YAML files from repository root not to overwrite your own configuration.
  • Copy dhmz-weather-card.js from www repocitory folder to your Home Assistant configuration www folder

HACS installation

hacs_badge

Location Selection

Each platform does not choose automatically which weather station’s data to use. Selection of different identifiers is under configuration section of this document. Current version does not validate nor enforces configuration choices, but this is down the development roadmap.

For each platform, the location to use is determined according to the following list:

Weather

The dhmz weather platform populates a weather card with DHMZ current conditions and forecast data.
To add DHMZ weather to your installation, add the following to your configuration.yaml file:

  1. # Example configuration.yaml entry
  2. weather:
  3. - platform: dhmz
  4. name: DHMZ Maksimir
  5. station_name: Zagreb-Maksimir
  6. forecast_region_name: Zagreb
  7. forecast_text: zg_text
  8. forecast_station_name: Zagreb_Maksimir
  • The platform checks for new data every 20 minutes, and the source data is typically updated hourly within 10 minutes after the hour.
  • If no name is given, the weather entity will be named weather.dhmz.

Configuration

  • name:
    • description: Name to be used for the entity ID, e.g. weather.<name>.
    • required: false
    • type: string
  • station_name:
    • description: The station code of a specific weather station to use - see (#station_name)
    • required: true
    • type: string
  • forecast_region_name:
    • description: The forecase region_name - see (#forecast_region_name)
    • required: true
    • type: string
  • forecast_text:
    • description: The forecast text identifier - see ##forecast_text
    • required: true
    • type: string
  • forecast_station_name:
    • description: The forecast station name - see ##forecast_station_name
    • required: true
    • type: string

Sensor

The dhmz sensor platform creates sensors based on DHMZ current conditions data and daily forecasts.

To add DHMZ weather to your installation, add the following to your configuration.yaml file:

  1. # Example configuration.yaml entry
  2. sensor:
  3. - platform: dhmz
  4. name: DHMZ Sensor Maksimir
  5. station_name: Zagreb-Maksimir
  6. forecast_region_name: Zagreb
  7. forecast_text: zg_text
  8. forecast_station_name: Zagreb_Maksimir
  9. monitored_conditions:
  10. - temperature
  11. - pressure
  12. - pressure_tendency
  13. - humidity
  14. - wind_speed
  15. - wind_bearing
  16. - condition
  17. - precipitation
  18. - forecast_text_today
  19. - forecast_text_tommorow
  • A sensor will be created for each of the following conditions, with a default name like sensor.<name>_temperature:
    • temperature - The current temperature, in ºC.
    • pressure - The current air pressure, in kPa.
    • pressure_tendency - The current air pressure tendency, e.g. “+0.5” in last hour.
    • humidity - The current humidity, in %.
    • condition - A brief text statement of the current weather conditions, e.g. “Sunny”.
    • wind_speed - The current sustained wind speed, in km/h.
    • wind_bearing - The current cardinal wind direction, e.g. “SSW”.
    • precipitation - precipitation in last 24 hours, in mm.
    • forecast_text_today - A textual description of today’s forecast
    • forecast_text_tommorow - A textual description of tommorow’s forecast

Configuration

  • name:
    • description: Name to be used for the entity ID, e.g. sensor.<name>_temperature.
    • required: false
    • type: string
  • station_name:
    • description: The station code of a specific weather station to use - see (#station_name)
    • required: true
    • type: string
  • forecast_region_name:
    • description: The forecase region_name - see (#forecast_region_name)
    • required: true
    • type: string
  • forecast_text:
    • description: The forecast text identifier - see ##forecast_text
    • required: true
    • type: string
  • forecast_station_name:
    • description: The forecast station name - see ##forecast_station_name
    • required: true
    • type: string
  • monitored_conditions:
    • description: List of sensors to monitor, create in home assistant
    • required: true
    • type: list or
      • temperature
      • pressure
      • pressure_tendency
      • humidity
      • wind_speed
      • wind_bearing
      • condition
      • precipitation
      • forecast_text_today
      • forecast_text_tommorow

Camera

The dhmz camera platform displays DHMZ [radar imagery].

To add DHMZ radar imagery to your installation, add the desired lines from the following example to your configuration.yaml file:

  1. # Example configuration.yaml entry
  2. camera:
  3. - platform: dhmz
  4. name: DHMZ Radar
  5. delta: 300
  6. previous_images_time: 125
  7. current_image_time: 2000
  8. longitude: 48
  9. latitude: 16
  10. mark_location: True
  11. image_format: WebP

Configuration

  • name:
    • description: Name to be used for the entity ID, e.g. camera.<name>.
    • required: false
    • type: string
  • delta:
    • description: Time in seconds between check for new radar images, defaults to 300 sec
    • required: false
    • type: integer
  • previous_images_time:
    • description: Time in miliseconds that determines how long old radar images in animation will be displayed, defaults to 125 ms
    • required: false
    • type: integer
  • current_image_time:
    • description: Time in miliseconds that determines how long last (current) radar image in animation will be displayed, defaults to 2000 ms
    • required: false
    • type: integer
  • mark_location:
    • description: mark red circle on geographical coordinates of current location, default is False (not to display location). Allowed values are: True or False
    • required: false
    • type: string
  • longitude:
    • description: Longitude of location to use for closest station determination, if not present will be taken from HA configuration
    • required: false
    • type: float
  • latitude:
    • description: Latitude of location to use for closest station determinationdetermination, if not present will be taken from HA configuration
    • required: false
    • type: float
  • image_format:

    • description: Animated image format that will be created, can be one of: WebP or GIF. Defaut is WebP.
    • required: false
    • type: string
  • If no name is given, the camera entity will be named camera.dhmz.

  • If no delta is given, default is set to 300 seconds (every 5 minutes). Since radar images on DHMZ are refreshed every 5 minutes, it is recommented to put this not less then 60 seconds (every minute). Components checks if image was actually updated and will not re-download it’s contant if it is unchanged from last check.
  • previous_images_time and current_image_time can determine how radar image animation will be generated. All old but current radar images are show for previous_images_time and only last and current radar image is shown for current_image_time. Please note that since HA refreshes images every 10 seconds, best results are achieved if sum of all image times can be multiplied to this 10 seconds. This is why default values of 125 ms and 2000 ms - which sum up to 5 seconds (24x125+2000=5000) - which is nicely shown in the previes window without jerky and skipping frames. If changing these times it is strongly suggested to keep it to match to: 24 x previous_images_time + current_image_time = 10 sec or any other common denominator of 10 sec.
  • logitude and latitude are only usefull when setting mark_location as True. mark_location will work without explicitly stated logitude and latitude if HA has home location correctly configured.
  • image_format that animated image will be created in. Default is WebP, since it yields smaller image sizes. If you face issue in displaying WebP in your web browser, you can change to GIF, but files shall be larger and producing more traffic towards browser.

Known issues

  • When displaying radar image in home assistant’s dashboard picture entity card, use “auto” not “live” mode. Ddifference is that in “auto” browser will fetch new picture every 10 seconds. And in “live” it will fetch every half seconds. This unfortunately cannot be changed, and for our purpose, more kless frequent refresh e.g. one per minute or even every 5 minutes, would be sufficient. This every 10 seconds refresh will cause only traffic between browser and home assistant server, not towards service provider DHMZ, since all images are cached. However, improvement would be to use some alternative to stock picture entity card which allows custom refresh rates. One such is https://github.com/dimagoltsman/refreshable-picture-card , but unfortunately, it does not work correctly for camera_image methods, only for static entity images.

Custom card

To add custom card for DHMZ weather, add following to your lovelace configuration YAML file:

  1. Under resources section add custom card definition
  1. resources:
  2. - type: js
  3. url: /local/dhmz-weather-card.js
  1. In views and cards section add following card
  1. cards:
  2. - mode: hourly
  3. type: 'custom:dhmz-weather-card'
  4. weather: weather.dhmz_maksimir
  5. show_today_text: true
  6. show_tomorrow_text: true

With weather attribute you should state name of the entity configured in weather compontent.
For mode, please use daily or hourly, since hourly was mostly customized and tested and is preffered to be used.
Attribute show_today_text - shows today’s text forecast (true|false), default is true.
Attribute show_tomorrow_text - shows tomorrow’s text forecast (true|false), default is true.

station_name

  1. RC Bilogora
  2. Bjelovar
  3. Crikvenica
  4. Crni Lug-NP Risnjak
  5. Daruvar
  6. Delnice
  7. Dubrovnik
  8. Dubrovnik-aerodrom
  9. Gospić
  10. RC Gorice (kod Nove Gradiške)
  11. RC Gradište (kod Županje)
  12. Gruda
  13. Hvar
  14. Imotski
  15. Karlovac
  16. Knin
  17. Komiža
  18. Krapina
  19. Krk
  20. Križevci
  21. Kukuljanovo
  22. Kutjevo
  23. Lastovo
  24. Lipik
  25. Malinska
  26. Makarska
  27. Mali Lošinj
  28. NP Mljet
  29. RC Monte Kope
  30. Ogulin
  31. Opatija
  32. RC Osijekepin
  33. Osijek-aerodrom
  34. Palagruža
  35. Pargabar
  36. Pazin
  37. NP Plitvička jezera
  38. Ploče
  39. Poreč
  40. Porer - svjetionik
  41. Prevlaka
  42. Pula
  43. Pula-aerodrom
  44. RC Puntijarka
  45. Rab
  46. Rijeka
  47. Rijeka-aerodrom
  48. Sv. Ivan na pučini - svjetionik
  49. Senj
  50. Sinj
  51. Sisak
  52. Slavonski Brod
  53. Split-Marjan
  54. Split-aerodrom
  55. Šibenik
  56. Varaždin
  57. Veli Rat - svjetionik
  58. Vinkovci
  59. Zadar
  60. Zadar-aerodrom
  61. Zagreb-Grič
  62. Zagreb-Maksimir
  63. Zagreb-aerodrom
  64. Zavižan

forecast_region_name

  1. sredisnja
  2. istocna
  3. gorska
  4. unutrasnjost Dalmacije
  5. sjeverni Jadran
  6. srednji Jadran
  7. juzni Jadran
  8. Zagreb

forecast_text

  1. rh_text
  2. zg_text

forecast_station_name

  1. Beli_Manastir
  2. Bilogora
  3. Bjelovar
  4. Cavtat
  5. Cakovec
  6. Zracna_luka_Dubrovni
  7. Daruvar
  8. Delnice
  9. Donji_Miholjac
  10. Dubrovnik
  11. Dakovo
  12. Fuzine
  13. Glina
  14. Gospic
  15. Gracac
  16. Gradiste
  17. Hreljin
  18. Hrvatska_Kostajnica
  19. Hvar
  20. Ilok
  21. Imotski
  22. Karlovac
  23. Knin
  24. Komiza
  25. Koprivnica
  26. Korcula
  27. Krapina
  28. Krizevci
  29. Krk
  30. Lastovo
  31. Mali_Losinj
  32. Makarska
  33. Maslenica
  34. Metkovic
  35. Korita-NP_Mljet
  36. Most_Krk
  37. Nasice
  38. Nin
  39. Nova_Gradiska
  40. Novska
  41. Ogulin
  42. Orebic
  43. Osijek
  44. Pag
  45. Palagruza
  46. cabar
  47. Pazin
  48. NP_Plitvicka_jezera
  49. Ploce
  50. Pokupsko
  51. Porec
  52. Pozega
  53. Pula
  54. Rab
  55. Rijeka
  56. Rovinj
  57. Rupa
  58. Senj
  59. Sinj
  60. Sisak
  61. Slatina
  62. Slavonski_Brod
  63. Slunj
  64. Split
  65. Sibenik
  66. Udbina
  67. Varazdin
  68. Vela_Luka
  69. Vinkovci
  70. Virovitica
  71. Vukovar
  72. Zadar
  73. Zagreb_Maksimir
  74. Zavizan
  75. Zracna_luka_Zadar