Yio Remote Community

OpenWeather integration

I added a weather integration using OpenWeather (https://openweathermap.org/). They offer a free access, sufficient for our needs.

Rain and snow is faked, to show the icons.

Config.json :

    "openweather":
    {
        "data":
        [
            {
                "friendly_name": "OpenWeather",
                "id": "openweather",
                "key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                "language": "de",
                "units": "metric",
                "log": "debug"
            }
        ]
    }

You can configure one ore more locations. The entity_id is the openweather location.

    "weather": [
        {
            "entity_id": "Vienna, AT",
            "supported_features": [],
            "friendly_name": "Wien",
            "integration": "openweather"
        }
    ],

@marton:

Please create a integration.openweather repository, I will push it there.

I am thinking when I should fetch data from the server. I do not fully understand the standby modes.
There is a normal standby and a wifi off mode. After wifi off a connect is initiated for all integratrions. But during normal standby the integration activity should also be reduced to save power. I propose to add standby on/off functions to the integrations similar to connect/disconnect.

1 Like

Poh! You are on fire m8 :ok_hand:

Thanks @ChristianRiedl! I haven’t seen your message just now, but I can see someone already created a repo for you.

When the user sets to turn off the wifi after some period of time. The remote disconnects all intergrations, to avoid timeout and connection errors.

During normal standby, the integrations are kept connected, because it could be the case that we want the remote to turn on when a specific event happens. However this functionality is not implemented yet. If we disconnect the integrations in standby mode, that could save power. Maybe it should be user configurable.

@marton

OK, I understand. As power consumption is a critical thing on the YIO, integrations using polling should increase their polling cycle during standby. Instead of connecting to StandbyControl I propose to add a standby on/off function to the integrationinterface. It remembers integration developers to save power.

As promised, I also updated the wiki entities chapter.

Shall I prepare a feature branch for the weather stuff ?

An option also could be to just turn off the integrations when in standby. Right now there are nothing that requires to wake the remote up. A logic could prevent the integrations to disconnect when for example watching a movie or listening to music, so you have immediate control over volume, etc. When nothing is playing, it will disconnect.

Please do prepare a branch @ChristianRiedl! Thank you.

@marton
I pushed the weather entities including the UI components I created. Additionally a small change in Logger to log the files in a separate directory, it is easier to clean.

In the entities.* entitiesinterface.h files I added the changes we allready discussed. The integrations should not use QObjects*, only interfaces. I also made some changes using the “optimized” config functions.

In config.* I removed 2 unused signals, and corrected wrong namings.

Thank you @ChristianRiedl!

Maybe for the logger we can think of a cleanup/log file rotation logic, so we don’t end up filling up the card.

@marton

I updated openweather integration to support languages and imperial units.

Current, updated integration configuration :

    "openweather": {
        "data": [
            {
                "data": {
                    "cacheDir": "/temp/openweather",
                    "key": "1e80be4999af33b2461e17ed0211009c",
                    "cycleHours": "2",
                    "url": "https://api.openweathermap.org/data/2.5/",
                    "iconUrl": "https://openweathermap.org/img/wn/"
                },
                "friendly_name": "RicOpenWeather",
                "friendly_name_search_term": "RicOpenWeather",
                "id": "cd864f73-1935-32f5-3f36-7ac69d5b0c81"
            }
        ],
        "mdns": ""
    },
  • key: required, requires free account from openWeatherMap
  • cacheDir (optional): directory for cached weather icons, defaults to /tmp, created it not existing
  • cycleHours (optional) : weather update cycle, defaults to 2
  • url (optional) : for rest api, defaults to https://api.openweathermap.org/data/2.5/
  • iconUrl (optional) : for icons, defaults to https://openweathermap.org/img/wn/

The entities looks like this. Some cities are created as available entities :

    "weather": [
        {
            "entity_id": "Vienna, AT",
            "friendly_name": "Wien",
            "integration": "cd864f73-1935-32f5-3f36-7ac69d5b0c81",
            "supported_features": [
            ]
        }
    ]

The entity_id must be a valid openWeatherMap query string. See https://openweathermap.org/.

Great! Thanks, @ChristianRiedl

@marton

I am playing with openweather integtration on YIO remote and noticed a problem with scaling of images.
The images (png, size 100*100) are stored as files (by my ImageCache). Without specifying width and height they are correct shown on the YIO remote but when I try to increase them I get strange artifacts.

Image {
   id: image
   asynchronous: false
   width: 80
   height: 80
   fillMode: Image.PreserveAspectCrop
   anchors { left: parent.left; leftMargin: 10; verticalCenter: parent.verticalCenter }
   source: obj.current.imageurl;
   visible: weatherButton.state == "closed" ? true : false
}

On the PC it looks correct :

On the PI it looks like this :

Do you have an idea ? The problem is not related with the button. The list in Card.qml shows the same effect.

I don’t know why it is acting weird on the remote. My first guess is in the difference of libraries that you have and that is on the remote. Have to look into this.