dglent / meteo-qt

System tray application for weather status information
GNU General Public License v3.0
82 stars 21 forks source link

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

Closed Davetheraveuk closed 10 months ago

Davetheraveuk commented 1 year ago

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

dglent commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@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 commented 11 months ago

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: https://github.com/dglent/meteo-qt/blob/92ec15380a227fc28ddb0179ab51639cfcbdd4a6/meteo_qt/meteo_qt.py#L2431

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

Davetheraveuk commented 11 months ago

Hi, I added the line you told me to and now the program will not start at startup. I try to start the program manually via the start-menu and nothing. I have since removed the 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()}                 }'
        )

and the program works fine again.

On Tue, 19 Sept 2023 at 04:03, Dimitrios Glentadakis < @.***> wrote:

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:

https://github.com/dglent/meteo-qt/blob/92ec15380a227fc28ddb0179ab51639cfcbdd4a6/meteo_qt/meteo_qt.py#L2431

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

— Reply to this email directly, view it on GitHub https://github.com/dglent/meteo-qt/issues/137#issuecomment-1724763653, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ2QZTI7JGWSQWXEYWNDLTX3EDRNANCNFSM6AAAAAA4SGOZMI . You are receiving this because you authored the thread.Message ID: @.***>

dglent commented 11 months ago

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 commented 11 months ago

Hi, So I got it working, all works well. You mentioned if I required any other parameters I should ask. Can moonrise and moonfall be added? Also, can the exported data be in CSV database format? Like:

Parameter,Value Sunrise,06:48 Sunset,19:03 Feels_Like,10.52 C ...

Dave.

On Fri, 22 Sept 2023 at 04:28, Dimitrios Glentadakis < @.***> wrote:

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

[image: εικόνα] https://user-images.githubusercontent.com/4337756/269820192-be4a791d-d77a-4dac-87b0-381cf2f60b09.png

    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()} }'
        )

— Reply to this email directly, view it on GitHub https://github.com/dglent/meteo-qt/issues/137#issuecomment-1730752422, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ2QZVTUYFREUCPZRKNE6LX3UAXHANCNFSM6AAAAAA4SGOZMI . You are receiving this because you authored the thread.Message ID: @.***>

dglent commented 11 months ago

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): https://github.com/dglent/meteo-qt/blob/92ec15380a227fc28ddb0179ab51639cfcbdd4a6/meteo_qt/meteo_qt.py#L821

εικόνα

Davetheraveuk commented 11 months ago

Yes, its fine. Thank you.

On Wed, 4 Oct 2023 at 05:28, Dimitrios Glentadakis @.***> wrote:

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):

https://github.com/dglent/meteo-qt/blob/92ec15380a227fc28ddb0179ab51639cfcbdd4a6/meteo_qt/meteo_qt.py#L821

[image: εικόνα] https://user-images.githubusercontent.com/4337756/272461184-4ecca40d-24b6-40b3-855c-bf42c5a315ad.png

— Reply to this email directly, view it on GitHub https://github.com/dglent/meteo-qt/issues/137#issuecomment-1746114607, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ2QZWB6BFQC7WKWRWIXYLX5TQWLAVCNFSM6AAAAAA4SGOZMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBWGEYTINRQG4 . You are receiving this because you authored the thread.Message ID: @.***>

dglent commented 11 months ago

Try the above commit to tell me if ok

Davetheraveuk commented 10 months ago

Hi, I cannot seem to find the exported information in a CSV database file anywhere. Where would the CSV file be saved to? Thanks. David.

On Sat, 7 Oct 2023 at 07:13, Dimitrios Glentadakis @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/dglent/meteo-qt/issues/137#issuecomment-1751615997, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ2QZSWP3OV33JIQVVGR5TX6DXI5AVCNFSM6AAAAAA4SGOZMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJRGYYTKOJZG4 . You are receiving this because you authored the thread.Message ID: @.***>

dglent commented 10 months ago

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 commented 10 months ago

Hi again, I'm sorry to be a PITA but the CSV file has no data inside it. I executed the following command: 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

But the file was empty. I have attached the generated file. Thanks, Dave.

On Fri, 20 Oct 2023 at 05:37, Dimitrios Glentadakis < @.***> wrote:

Ah sorry i didn't precise, the data are logged in the log file which you can find in the folder ~/.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:

@. meteo-qt]$ @. 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.logCity,Paris, FRTemperature,13.87 °CFeels like,13.79 °CWind,South 7.6 km/h light breezeCloudiness,100% overcast cloudsHumidity,95 %Visibility,10.0 kmComfort,ComfortablePrecipitation,rain 1.15 mm Sunrise,08:17Sunset,18:52Daylight,10:35Air quality,ModerateUV,2.08 @. 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-qt]$ lsmeteo_exp.csv meteo-qt.conf meteo-qt.log

— Reply to this email directly, view it on GitHub https://github.com/dglent/meteo-qt/issues/137#issuecomment-1772067424, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ2QZW3OFMUDRXFNVLE7FLYAH5XHAVCNFSM6AAAAAA4SGOZMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZSGA3DONBSGQ . You are receiving this because you authored the thread.Message ID: @.***>

dglent commented 10 months ago

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 commented 10 months ago

OK so I downloaded the new meteo_qt.py file from github and yes I see the data in the log file. Thanks. David.

On Sun, 22 Oct 2023 at 06:24, Dimitrios Glentadakis < @.***> wrote:

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 ?

— Reply to this email directly, view it on GitHub https://github.com/dglent/meteo-qt/issues/137#issuecomment-1773998651, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ2QZU7W2XUBGJWJHAB6WTYASUZ3AVCNFSM6AAAAAA4SGOZMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZTHE4TQNRVGE . You are receiving this because you authored the thread.Message ID: @.***>