Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How do I extract data from this app? #137

Closed
Davetheraveuk opened this issue Sep 10, 2023 · 19 comments
Closed

[Question] How do I extract data from this app? #137

Davetheraveuk opened this issue Sep 10, 2023 · 19 comments

Comments

@Davetheraveuk
Copy link

Hi, I would like to extract data from this app and display it in conky. How do I do this? Thanks, Dave.

@dglent
Copy link
Owner

dglent commented Sep 11, 2023

Hello,

Do you know how to add widgets in Conky ?
Maybe the log file in ~/.config/meteo-qt/meteo-qt.log can help (and add some more specific information for Conky?)

@Davetheraveuk
Copy link
Author

@dglent
Hi, yes, I am fully aware of conky and its widgets (see pic attacted).
I had a look at the log file and this is all that was in there:

`
2023/09/11 19:11:50 ERROR: Your openweathermap key has no access to onecall api - 2781: meteo_qt

2023/09/11 19:11:51 INFO: Actual weather status for: Loughton GB 21.9°

Feels like 22 °C

overcast clouds - 2431: meteo_qt
`

I have no wish to see any meteo-qt icons within conky, just the data from the meteo-gt app.
Hope you can help
Thanks.
Dave.

Screenshot from 2023-09-11 19-16-23

@dglent
Copy link
Owner

dglent commented Sep 11, 2023

In the log file you have some usefull data
`Actual weather status for: Loughton GB 21.9°

Feels like 22 °C

overcast clouds`

I don’t know how you add data in conky. If you read this file every hour for exemple you can exctract the current weather status. If you need more data as forecast it will be easy to add also.
Tell me if this aproach is ok and the needed data.

@Davetheraveuk
Copy link
Author

@dglent
Hi again and thanks for getting back to me so soon. :)
As requested, below is the data I am looking to place on the background desktop via conky:

Location
Day high
Day low
Feels like
Wind
Cloudiness
Humidity
Visibility
Comfort
Precipitation
Sunrise
Sunset
Daylight
Air quality
UV level

Thanks, Dave.

@dglent
Copy link
Owner

dglent commented Sep 19, 2023

You can add this line:

logging.info(
                f'EXPORT:{ {key: value if type(value) == str else " ".join(v for v in value) for key, value in self.weatherDataDico.items()} }'
            )

here just after this line:

logging.info(f'Actual weather status for: {self.notification}')

and tell me if you can use it and if you want more data

@Davetheraveuk
Copy link
Author

Davetheraveuk commented Sep 21, 2023 via email

@dglent
Copy link
Owner

dglent commented Sep 22, 2023

It should work, try the exact following code.
I wanted to know if this way is suitable to import data in Conky.
Then i will format the data (e.g. the time) and i will add more data in this object/dictionary export but firstly test if it is usable like this

εικόνα

        if not self.toggle_tray_action:
            logging.info(f'Actual weather status for: {self.notification}')
            logging.info(
                f'EXPORT:{ {key: value if type(value) == str else " ".join(v for v in value) for key, value in self.weatherDataDico.items()} }'
            )

@Davetheraveuk
Copy link
Author

Davetheraveuk commented Sep 22, 2023 via email

@dglent
Copy link
Owner

dglent commented Oct 4, 2023

I started with this, is the lines format ok for your need ?

logging.info(
    f"\nEXPORT_START\n"
    f"City,{city_label}\n"
    f"Feels like,{self.feels_like_value.text()}\n"
    f"Wind,{self.weatherDataDico['Wind'][4]} {wind_speed} {self.unit_system_wind} {self.weatherDataDico['Wind'][1]}\n"
    f"Cloudiness,{self.weatherDataDico['Clouds']}\n"
    f"EXPORT_END\n"
)

Add this code here (it is at the end of the update of the gui panel):

εικόνα

@Davetheraveuk
Copy link
Author

Davetheraveuk commented Oct 7, 2023 via email

dglent added a commit that referenced this issue Oct 7, 2023
@dglent
Copy link
Owner

dglent commented Oct 7, 2023

Try the above commit to tell me if ok

  • The air quality an UV are arriving after the update of the GUI so you will see them after the next update of the weather.
    It needs to make some modifications to make some variables global etc, check as it and tell me

@dglent dglent closed this as completed Oct 7, 2023
@Davetheraveuk
Copy link
Author

Davetheraveuk commented Oct 19, 2023 via email

@dglent
Copy link
Owner

dglent commented Oct 20, 2023

Ah sorry i didn't precise, the data are logged in the log file which you can find in ~/.config/meteo-qt/meteo-qt.log
You can have a script which extracts (for e.g. every 30 minutes) the data from this file.
You can extract the data and use them directly or create a csv file.
You can use the following awk command:

[dglent@localhost meteo-qt]$ pwd
/home/dglent/.config/meteo-qt
[dglent@localhost meteo-qt]$ awk '/EXPORT_START/{ f=1;r=""; next }f && /EXPORT_END/{f=0} f{ r=(r=="")? $0: r RS $0 }END{ print r }' meteo-qt.log
City,Paris, FR
Temperature,13.87 °C
Feels like,13.79 °C
Wind,South 7.6  km/h  light breeze
Cloudiness,100% overcast clouds
Humidity,95 %
Visibility,10.0 km
Comfort,Comfortable
Precipitation,rain 1.15  mm 
Sunrise,08:17
Sunset,18:52
Daylight,10:35
Air quality,Moderate
UV,2.08 Low
[dglent@localhost meteo-qt]$ awk '/EXPORT_START/{ f=1;r=""; next }f && /EXPORT_END/{f=0} f{ r=(r=="")? $0: r RS $0 }END{ print r }' meteo-qt.log > meteo_exp.csv
[dglent@localhost meteo-qt]$ ls
meteo_exp.csv  meteo-qt.conf  meteo-qt.log

@Davetheraveuk
Copy link
Author

Davetheraveuk commented Oct 21, 2023 via email

@dglent dglent reopened this Oct 22, 2023
@dglent
Copy link
Owner

dglent commented Oct 22, 2023

If you run the commande without the "> meteo_exp.csv" you should see the data in the terminal. If not are you sure do have downloaded the latest meteo_qt.py file from github ? Do you find these data in the log file ?

@Davetheraveuk
Copy link
Author

Davetheraveuk commented Oct 22, 2023 via email

@dglent dglent closed this as completed Oct 31, 2023
@Davetheraveuk
Copy link
Author

Hi @dglent, I have been having problems with the API but I can still see the weather data in the meteo-qt application window. But nothing is displayed within conky. I cleared the meteo-qt log file and restarted the application, below is the information from the log file:

2024/09/18 21:25:16 ERROR: Your openweathermap key has no access to onecall api - 2781: meteo_qt
2024/09/18 21:25:16 INFO: Actual weather status for: Loughton GB 15.1°
Feels like 14.18 °C
clear sky - 2431: meteo_qt

Even with a new API key the error messages are like what I have posted above.

Thanks, David.

@dglent
Copy link
Owner

dglent commented Sep 19, 2024

Do you have the latest version (3.4) ?

@Davetheraveuk
Copy link
Author

Davetheraveuk commented Sep 19, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants