Weather Platform - IPMA

Bem, na API do ipma que uso essa informação não vem…

Mas como já encontrei N api’s diferentes do ipma, já não digo nada…

Esta é a oficial para Android que está no Google play

É a APP oficial android, que por sua vez uma API para ir buscar os dados.

Não sei qual é a API que essa app usa… mas sei por experiência que no próprio site do IPMA conforme a pagina, usam API’s diferentes.

@dgomes há pessoas que gostam de complicar coisas que são simples. Para que ter só uma API quando se podem ter dezenas delas e dar dinheiro a ganhar a empresas de amigos e familiares?

Boa noite,

Gostaria de adicionar este componente ao meu HA. Tenho no configuration.yaml assim

weather:
  - platform: ipma
     name: Porto
       latitude: 41.14857508
       longitude: -8.61300808

  - platform: ipma
     name: Santa Maria da Feira
       latitude: 40.99249661
       longitude: -8.57089248

Ja vi que muitos colocam isto num “impa.yaml”, depois tenho que o incluir no configurator?

Desculpem, mas só agora estou a começar neste mundo do HA. :slight_smile:

@imaNuS

Podes utilizar a separação das configurações para fazeres o que queres e, também, para manter o teu ficheiro principal de configuração o mais limpo possível. Assim poderás, e deverás pois fica mais simples encontrar as configurações que precisas, separando as configurações por tipo de componente (light, switch, sensor, etc.). Para saberes como fazer o que pretendes deves ler isto:

Podes também dar uma vista de olhos nos GitHub de alguns dos utilizadores do fórum para tirares alguma duvida que te possa surgir.

ja coloquei a conf no impa.yaml e coloquei no configuration.yaml o seguinte:

weather: !include ipma.yaml

Quando faço check à conf dá o seguinte erro:

Error loading /config/configuration.yaml: mapping values are not allowed here
in “/config/ipma.yaml”, line 2, column 9

Obrigado desde já pela ajuda

Precisamos de ver a teus ficheiros configuration.yaml e o ipma.yaml para saber qual é o erro. Não esqueças de retirar os dados pessoais dos ficheiros e de colar os ficheiros como código.

configutation.yaml

homeassistant:
  # Name of the location where Home Assistant is running
  name: Casa
  # Location required to calculate the time the sun rises and sets
  latitude: 40.*******
  longitude: -8.************
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 159
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: UTC
  # Customization file
  customize: !include customize.yaml

# Show links to resources in log and frontend
#introduction:

# Enables the frontend
frontend:

# Enables configuration UI
config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
   api_password: ******************
   base_url: ******************:8123
   ssl_certificate: /ssl/fullchain.pem
   ssl_key: /ssl/privkey.pem

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  # include_used_components: true

# Discover some devices automatically
#discovery:

homekit:

mqtt:
    broker: 192.168.*.***
    port: 1883
    username: ***************
    password: *************************

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# #Tempo
weather: !include ipma.yaml
#   - platform: ipma
#      name: Porto
#        latitude: 41.14857508
#        longitude: -8.61300808

#   - platform: ipma
#      name: Santa Maria da Feira
#        latitude: 40.99249661
#        longitude: -8.57089248

# Sensors
sensor: !include sensors.yaml


# Text to speech
tts:
  - platform: google

# Cloud
cloud:

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

panel_iframe:
    configurator:
     title: Configurador
     icon: mdi:wrench
     url: *****************************
    tasmoadmin:
     title: TasmoAdmin
     icon: mdi:flash
     url: *************************
    mdiindex:
     title: MDI Icon Index
     icon: mdi:vector-square
     url: https://cdn.rawgit.com/james-fry/home-assistant-mdi/efd95d7a/home-assistant-mdi.html

xiaomi_aqara:
  discovery_retry: 5
  gateways:
      - key: ********************

ipma.yaml

- platform: ipma
    name: Porto
    latitude: 41.14857508
    longitude: -8.61300808

- platform: ipma
    name: Santa Maria da Feira
    latitude: 40.99249661
    longitude: -8.57089248

Assim rapidamente o espaçamento do ipma.yaml está errado…

- platform: ipma
  name: Porto
  latitude: 41.14857508
  longitude: -8.61300808

- platform: ipma
  name: Santa Maria da Feira
  latitude: 40.99249661
  longitude: -8.57089248
1 Curtiu

image

Home Assistant
0.83.1

Bom dia,

desde a ultima atualização do HA (0.84.3) que reparo que nem sempre me aparece a info meteorológica.
Foi aos logs e tenho isto:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 347, in async_device_update
    await self.async_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/weather/ipma.py", line 95, in async_update
    self._condition = await self._station.observation()
  File "/usr/local/lib/python3.6/site-packages/pyipma/station.py", line 65, in observation
    observations = await self.api.observations()
  File "/usr/local/lib/python3.6/site-packages/pyipma/api.py", line 130, in observations
    headers={'Referer': 'http://www.ipma.pt'})
  File "/usr/local/lib/python3.6/site-packages/pyipma/api.py", line 29, in retrieve
    return await res.json()
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 947, in json
    return loads(stripped.decode(encoding))
  File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 28772 column 21 (char 622745)
1 Curtiu

Boa Noite,

HA: 0.84.4

---
platform: ipma
---
id: weather
title: Tempo
icon: mdi:nature-people
cards:
  - type: weather-forecast
    entity: weather.vila_real
Log Details (ERROR)
Thu Dec 20 2018 21:28:21 GMT+0000 (Western European Standard Time)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/src/app/homeassistant/components/weather/__init__.py", line 122, in state_attributes
    self.hass, self.temperature, self.temperature_unit,
  File "/usr/src/app/homeassistant/components/weather/ipma.py", line 120, in temperature
    return self._condition.temperature
AttributeError: 'NoneType' object has no attribute 'temperature

Sempre este erro ?

Parece-me a um problema pontual na plataforma do IPMA…

Alterei e fiz restart e resolveu. Poderá ser temporario.

---
platform: ipma
latitude: !secret zone_home_latitude
longitude: !secret zone_home_longitude
---
id: weather
title: Tempo
icon: mdi:apple-icloud
cards:
  - type: weather-forecast
    entity: weather.vila_real

sim, vai-me aparecendo uns erros de “Update for weather.lisboa fails” no log. deve ser mesmo do ipma, não?

Depende se aparece sempre ou as vezes…

Viva pessoal!

Há algum tempo que deixei de ter weather do IPMA.

Penso que foi a partir da actualização do HA para o 0.82.

O erro que dá é o que está em baixo.

Mais alguém tem esteve problema? Como o resolveram?

Obrigado.

2019-01-29 08:24:14 ERROR (MainThread) [homeassistant.components.weather] Error while setting up platform ipma
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/weather/ipma.py", line 72, in async_setup_platform
    float(longitude))
  File "/usr/local/lib/python3.6/site-packages/pyipma/station.py", line 42, in get
    stations = await self.api.stations()
  File "/usr/local/lib/python3.6/site-packages/pyipma/api.py", line 59, in stations
    for station in data['data']:
TypeError: 'NoneType' object is not subscriptable
2019-01-29 08:24:14 ERROR (MainThread) [homeassistant.components.weather] Error while setting up platform ipma
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/weather/ipma.py", line 72, in async_setup_platform
    float(longitude))
  File "/usr/local/lib/python3.6/site-packages/pyipma/station.py", line 42, in get
    stations = await self.api.stations()
  File "/usr/local/lib/python3.6/site-packages/pyipma/api.py", line 59, in stations
    for station in data['data']:
TypeError: 'NoneType' object is not subscriptable
2019-01-29 08:24:14 ERROR (MainThread) [homeassistant.components.weather] Error while setting up platform ipma
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/weather/ipma.py", line 72, in async_setup_platform
    float(longitude))
  File "/usr/local/lib/python3.6/site-packages/pyipma/station.py", line 42, in get
    stations = await self.api.stations()
  File "/usr/local/lib/python3.6/site-packages/pyipma/api.py", line 59, in stations
    for station in data['data']:
TypeError: 'NoneType' object is not subscriptable
2019-01-29 08:24:14 ERROR (MainThread) [homeassistant.components.weather] Error while setting up platform ipma
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/weather/ipma.py", line 72, in async_setup_platform
    float(longitude))
  File "/usr/local/lib/python3.6/site-packages/pyipma/station.py", line 42, in get
    stations = await self.api.stations()
  File "/usr/local/lib/python3.6/site-packages/pyipma/api.py", line 59, in stations
    for station in data['data']:
TypeError: 'NoneType' object is not subscriptable

Espero que não estejas a usar este componente como custom!

Apaga o IPMA da tua pasta custom_component. Certifica-te que tens a ultima versao 0.86.3.

Apesar de não perceber muito disto penso que não estou a usar custom.
Agora a versão é que não consigo ver pois em termos de Hass.io -> sytem a information é:

Hass.io supervisor
Version 142
Latest version 142

Antes da actualização lembro-me de ver um sitio onde dizia que a versão era a 0.72 mas agora já não encontro isso.

O configuration.yaml é:

weather:
  - platform: ipma
    name: Sobreda
    latitude: 38.64637
    longitude: -9.17539

  - platform: ipma
    name: Aljezur
    latitude: 37.31661
    longitude: -8.80372

  - platform: ipma
    name: Faro
    latitude: 37.01936
    longitude: -7.93044

  - platform: ipma
    name: Porto
    latitude: 41.14976
    longitude: -8.59901

A config do lovelace é a seguinte

title: Home
# Include external resources
resources:
  - url: /local/my-webfont.css
    type: css
  - url: /local/gauge-card.js?v=1
    type: js
  - url: /local/vertical-stack-in-card.js?v=0.0.2
    type: js

views:
#------------------------------------------------------------
  - icon: mdi:weather-cloudy
    id: Weather
    title: Weather
    cards:
      - type: vertical-stack
        cards:
         - type: markdown
           title: Meteo
           content: ' '
         - type: weather-forecast
           entity: weather.sobreda
         - type: weather-forecast
           entity: weather.aljezur
         - type: weather-forecast
           entity: weather.faro

Copyright © 2017-2021. Todos os direitos reservados
CPHA.pt - info@cpha.pt


FAQ | Termos de Serviço/Regras | Política de Privacidade