Weewx Send dato to Twitter Account

1,359 views
Skip to first unread message

Marco Morgia

unread,
Sep 21, 2014, 7:31:17 AM9/21/14
to weewx...@googlegroups.com
Good Morning,

I've installed weewx on my raspberry . Previously I used Cumulus, it can be configured to send data to a twitter account. It's possibile to do the same thing with weewx?

Thomas Keffer

unread,
Sep 21, 2014, 9:18:27 AM9/21/14
to weewx-user
Hello, Marco

Unfortunately, there is no Twitter feed that is part of weewx.

I know there has been interest in the past. Perhaps someone has implemented this as an extension?

-tk

On Sun, Sep 21, 2014 at 4:31 AM, Marco Morgia <marco....@saedi.it> wrote:
Good Morning,

I've installed weewx on my raspberry . Previously I used Cumulus, it can be configured to send data to a twitter account. It's possibile to do the same thing with weewx?

--
You received this message because you are subscribed to the Google Groups "Weewx user's group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mwall

unread,
Sep 21, 2014, 11:35:34 AM9/21/14
to weewx...@googlegroups.com
On Sunday, September 21, 2014 7:31:17 AM UTC-4, Marco Morgia wrote:
I've installed weewx on my raspberry . Previously I used Cumulus, it can be configured to send data to a twitter account. It's possibile to do the same thing with weewx?

marco,

you could try this weewx extension:

http://lancet.mit.edu/mwall/projects/weather/releases/weewx-twitter-0.1.tgz

it has not been tested, but it should be pretty close to working.  let me know how it works for you.

installation instructions are in the readme.txt file

m

Steve

unread,
Sep 21, 2014, 11:17:44 PM9/21/14
to weewx...@googlegroups.com
Hi Matthew,

I gave it a shot and have attached a snippet of the log where it failed. :( (My Pi is already tweeting my energy consumption figures, so twython & all my keys were set up / work ok).

Regards,

Steve
twitter_fail.txt

mwall

unread,
Sep 22, 2014, 10:13:49 AM9/22/14
to weewx...@googlegroups.com
On Sunday, September 21, 2014 11:17:44 PM UTC-4, Steve wrote:
Hi Matthew,

I gave it a shot and have attached a snippet of the log where it failed. :( (My Pi is already tweeting my energy consumption figures, so twython & all my keys were set up / work ok).

Regards,

Steve


hi steve,

thanks for testing.  this time i actually installed twython and ran it.  here is 0.2rc1.  be sure to specify the following in your weewx.conf:

[StdRESTful]                                                                   
    [[Twitter]]                                                                
        station = STATION_IDENTIFIER                                           
        app_key = APP_KEY                                                      
        app_key_secret = APP_KEY_SECRET                                        
        oauth_token = OAUTH_TOKEN                                              
        oauth_token_secret = OAUTH_TOKEN_SECRET                                

this should result in tweets something like this:

STATION_IDENTIFIER: ts: 1411392649; P: 32.12; iT: 72; oT: 64; iH: 45; oH: 35; Ws: 4; Wg: 5; Wd: 180; R: 0

m

 
twitter-0.2rc1.py

Steve

unread,
Sep 22, 2014, 7:31:39 PM9/22/14
to weewx...@googlegroups.com
Thank Matthew,

Up and running now thanks.

I did get caught out on the 1st attempt as app_secret became app_key_secret (The instructions are correct in the new file, I was using yesterday's readme, not what you posted here ;) )

Regards,

Steve.

Steve

unread,
Sep 22, 2014, 7:43:30 PM9/22/14
to weewx...@googlegroups.com
Matthew,

It's tweeting OK, but looks like it tries 3 times every time? Log attached.

Steve.
twitter_duplicates.txt

mwall

unread,
Sep 22, 2014, 7:56:53 PM9/22/14
to weewx...@googlegroups.com

sorry about that.  forgot to return after a successful tweet.

version 0.3 is now available:

https://sourceforge.net/p/weewx/wiki/twitter/

this also does some formatting to help keep the number of characters in each tweet less than the 140 character limit.

m

Steve

unread,
Sep 22, 2014, 8:18:24 PM9/22/14
to weewx...@googlegroups.com
It appears all is now good thanks Matthew.

Steve.

Marco Morgia - Saedi

unread,
Sep 24, 2014, 3:31:40 PM9/24/14
to weewx...@googlegroups.com

Good Evening at all,

 

i’ve have downloaded the new file (version 0.3). I have extracted the twitter.py file and I’ve copy it to /home/weewx/bin/user/     folder. I’ve installed twython and I have insert the key of my twitter app and the [Engine] tag in weewx.conf file, as indicaded. But if I try to restart weewx service it’s not start.

 

Anyone had the same problem?

 

Marco Morgia

Microsoft Certified Technology Specialist

Sviluppo Software

 

LogoSaediGruppo

 

.: Saedi Srl

.: Via Cerere Navicella, 64 – 03012 Anagni - Fr

.: Tel. +39 0775 706923

.: Mob. +39 3471199044

.: email: marco....@saedi.it

.: web: http://www.saedi.it

Questo messaggio ed ogni documento trasmesso con esso è confidenziale ed esclusivamente la persona a cui è indirizzato è autorizzata ad utilizzarlo. Se avete ricevuto questo messaggio per errore rispeditelo cortesemente al mittente. La pubblicazione, l'utilizzo, la distribuzione, la stampa, o la copia non autorizzata di questo messaggio e dei documenti allegati è strettamente proibito.

This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual to whom it is addressed.

If you have received this e-mail in error please send it back to the person that sent it to you. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited.

 

Da: weewx...@googlegroups.com [mailto:weewx...@googlegroups.com] Per conto di Steve
Inviato: martedì 23 settembre 2014 02:18
A: weewx...@googlegroups.com
Oggetto: [weewx-user] Re: Weewx Send dato to Twitter Account

--
You received this message because you are subscribed to a topic in the Google Groups "Weewx user's group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/DdzE-7CAeDM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.

image001.jpg

mwall

unread,
Sep 24, 2014, 3:56:52 PM9/24/14
to weewx...@googlegroups.com
On Wednesday, September 24, 2014 3:31:40 PM UTC-4, Marco Morgia wrote:

Good Evening at all,

i’ve have downloaded the new file (version 0.3). I have extracted the twitter.py file and I’ve copy it to /home/weewx/bin/user/     folder. I’ve installed twython and I have insert the key of my twitter app and the [Engine] tag in weewx.conf file, as indicaded. But if I try to restart weewx service it’s not start.

Anyone had the same problem?


marco,

it is impossible to diagnose without more information.  please post the output from your log file.

m

Marco Morgia

unread,
Sep 25, 2014, 2:38:37 PM9/25/14
to weewx...@googlegroups.com
Good Evening,
in syslog I see only "Error while parsing confgiuration file

--
You received this message because you are subscribed to a topic in the Google Groups "Weewx user's group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/DdzE-7CAeDM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
 
Morgia Marco
Programmatore / Developer

S.A.ED I. srl
Via Cerere Navicella, 64
03012 Anagni (FR)
Cell. +39 347 11.99.044

mwall

unread,
Sep 25, 2014, 3:52:18 PM9/25/14
to weewx...@googlegroups.com
On Thursday, September 25, 2014 2:38:37 PM UTC-4, Marco Morgia wrote:
Good Evening,
in syslog I see only "Error while parsing confgiuration file

marco,

apparently you introduced errors when you modified the configuration file.

if you post the actual log messages (instead of paraphrasing), and if you post the actual configuration file, then we might be able to help.

m

Marco Morgia - Saedi

unread,
Oct 11, 2014, 3:12:20 AM10/11/14
to weewx...@googlegroups.com

Good Morning,

 

in attachment my weewx conf file.

 

Marco Morgia

Microsoft Certified Technology Specialist

Sviluppo Software

 

LogoSaediGruppo

 

.: Saedi Srl

.: Via Cerere Navicella, 64 – 03012 Anagni - Fr

.: Tel. +39 0775 706923

.: Mob. +39 3471199044

.: email: marco....@saedi.it

.: web: http://www.saedi.it

Questo messaggio ed ogni documento trasmesso con esso è confidenziale ed esclusivamente la persona a cui è indirizzato è autorizzata ad utilizzarlo. Se avete ricevuto questo messaggio per errore rispeditelo cortesemente al mittente. La pubblicazione, l'utilizzo, la distribuzione, la stampa, o la copia non autorizzata di questo messaggio e dei documenti allegati è strettamente proibito.

This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual to whom it is addressed.

If you have received this e-mail in error please send it back to the person that sent it to you. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited.

 

Da: weewx...@googlegroups.com [mailto:weewx...@googlegroups.com] Per conto di mwall
Inviato: giovedì 25 settembre 2014 21:52
A: weewx...@googlegroups.com
Oggetto: Re: [weewx-user] Re: Weewx Send dato to Twitter Account

--

image001.jpg
weewx.conf

Steve

unread,
Oct 11, 2014, 6:16:48 AM10/11/14
to weewx...@googlegroups.com
Last line in the conf file is -         restful_services = ... , user.twitter.Twitter

Add the user.twitter.Twitter to the end of the existing resful_sevices= line

It should be something link this (all on one line, no CR)

    [[WxEngine]]

        # The list of services the main weewx engine should run:
        prep_services = weewx.wxengine.StdTimeSynch
        process_services = weewx.wxengine.StdConvert, weewx.wxengine.StdCalibrate, weewx.wxengine.StdQC
        archive_services = weewx.wxengine.StdArchive
        restful_services = weewx.restx.StdStationRegistry, weewx.restx.StdWunderground, weewx.restx.StdPWSweather, weewx.restx.StdCWOP, weewx.restx.StdWOW, weewx.restx.StdAWEKAS, user.twitter.Twitter
        report_services = weewx.wxengine.StdPrint, weewx.wxengine.StdReport

Marco Morgia - Saedi

unread,
Oct 11, 2014, 9:20:08 AM10/11/14
to weewx...@googlegroups.com

Thankssss,

 

now it works…

 

Marco Morgia

Microsoft Certified Technology Specialist

Sviluppo Software

 

LogoSaediGruppo

 

.: Saedi Srl

.: Via Cerere Navicella, 64 – 03012 Anagni - Fr

.: Tel. +39 0775 706923

.: Mob. +39 3471199044

.: email: marco....@saedi.it

.: web: http://www.saedi.it

Questo messaggio ed ogni documento trasmesso con esso è confidenziale ed esclusivamente la persona a cui è indirizzato è autorizzata ad utilizzarlo. Se avete ricevuto questo messaggio per errore rispeditelo cortesemente al mittente. La pubblicazione, l'utilizzo, la distribuzione, la stampa, o la copia non autorizzata di questo messaggio e dei documenti allegati è strettamente proibito.

This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual to whom it is addressed.

If you have received this e-mail in error please send it back to the person that sent it to you. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited.

 

Da: weewx...@googlegroups.com [mailto:weewx...@googlegroups.com] Per conto di Steve
Inviato: sabato 11 ottobre 2014 12:17
A: weewx...@googlegroups.com
Oggetto: [weewx-user] Re: Weewx Send dato to Twitter Account

--

image001.jpg

Marco Morgia - Saedi

unread,
Oct 13, 2014, 11:39:14 AM10/13/14
to weewx...@googlegroups.com

Another question,

 

how to change °F to °C ?

 

Thanks

 

Marco Morgia

Microsoft Certified Technology Specialist

Sviluppo Software

 

LogoSaediGruppo

 

.: Saedi Srl

.: Via Cerere Navicella, 64 – 03012 Anagni - Fr

.: Tel. +39 0775 706923

.: Mob. +39 3471199044

.: email: marco....@saedi.it

.: web: http://www.saedi.it

Questo messaggio ed ogni documento trasmesso con esso è confidenziale ed esclusivamente la persona a cui è indirizzato è autorizzata ad utilizzarlo. Se avete ricevuto questo messaggio per errore rispeditelo cortesemente al mittente. La pubblicazione, l'utilizzo, la distribuzione, la stampa, o la copia non autorizzata di questo messaggio e dei documenti allegati è strettamente proibito.

This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual to whom it is addressed.

If you have received this e-mail in error please send it back to the person that sent it to you. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited.

 

Da: Marco Morgia - Saedi [mailto:marco....@saedi.it]
Inviato: sabato 11 ottobre 2014 15:20
A: weewx...@googlegroups.com
Oggetto: R: [weewx-user] Re: Weewx Send dato to Twitter Account

image001.jpg

Steve

unread,
Oct 14, 2014, 8:18:03 AM10/14/14
to weewx...@googlegroups.com
Message has been deleted
Message has been deleted

mwall

unread,
Oct 14, 2014, 11:04:13 AM10/14/14
to weewx...@googlegroups.com
On Monday, October 13, 2014 11:39:14 AM UTC-4, Marco Morgia wrote:
 how to change °F to °C ?

ok, maybe this time.  try twitter 0.4rc3 (one of these days i'll learn that even trivial changes need to be tested :)

m
 
twitter-0.4rc3.py

Marco Morgia - Saedi

unread,
Oct 14, 2014, 4:00:01 PM10/14/14
to weewx...@googlegroups.com

Thanks soo much,

 

it’s work

 

 

 

Marco Morgia

Microsoft Certified Technology Specialist

Sviluppo Software

 

LogoSaediGruppo

 

.: Saedi Srl

.: Via Cerere Navicella, 64 – 03012 Anagni - Fr

.: Tel. +39 0775 706923

.: Mob. +39 3471199044

.: email: marco....@saedi.it

.: web: http://www.saedi.it

Questo messaggio ed ogni documento trasmesso con esso è confidenziale ed esclusivamente la persona a cui è indirizzato è autorizzata ad utilizzarlo. Se avete ricevuto questo messaggio per errore rispeditelo cortesemente al mittente. La pubblicazione, l'utilizzo, la distribuzione, la stampa, o la copia non autorizzata di questo messaggio e dei documenti allegati è strettamente proibito.

This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual to whom it is addressed.

If you have received this e-mail in error please send it back to the person that sent it to you. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited.

 

Da: weewx...@googlegroups.com [mailto:weewx...@googlegroups.com] Per conto di mwall
Inviato: martedì 14 ottobre 2014 17:04
A: weewx...@googlegroups.com
Oggetto: Re: [weewx-user] Re: Weewx Send dato to Twitter Account

--

image001.jpg

mwall

unread,
Oct 16, 2014, 12:15:20 PM10/16/14
to weewx...@googlegroups.com
for all of you twits out there,

it can be a challenge to obtain twitter oauth credentials if you just read the twitter docs (https://dev.twitter.com/oauth/overview)

here is a step-by-step guide that is easier to follow:

http://www.prophoto.com/support/twitter-api-credentials/

m

Steve

unread,
Oct 17, 2014, 11:24:06 AM10/17/14
to weewx...@googlegroups.com
That's working ok for me.

Is it much drama to be able to choose what is tweeted and in what order?

At the moment I get:

Bacchus Marsh: ts: 1413558288; Wd: None; oT: 7.00; Ws: 0.0; P: 1025.307; iT: 15.80; Wg: 1.1; oH: 97.00; iH: 58.00; R: 0.000

For my OCD, I'd like all the wind info, then temps, then humidity etc rather than the wind info interrupted with the outside temperature, pressure and inside temperature :) or whatever order, but grouped.

Something like:

Bacchus Marsh: ts: 1413558288; Wd: None; Ws: 0.0; Wg: 1.1; oT: 7.00; iT: 15.80; oH: 97.00; iH: 58.00; P: 1025.307; R: 0.000

If I could, if it was optional, I'd ditch the time stamp as hovering over the tweet time stamp tells me when it was posted anyway.

Regards,

Steve.

Jan Valkenier

unread,
Oct 19, 2014, 8:32:40 AM10/19/14
to weewx...@googlegroups.com
Another question: Is it possible to set an interval for posting data on twitter? I noticed a post-interval variable in the code: post-interval=300. Is this te place to change it?


mwall

unread,
Oct 19, 2014, 8:43:43 AM10/19/14
to weewx...@googlegroups.com
On Sunday, October 19, 2014 8:32:40 AM UTC-4, Jan Valkenier wrote:
Another question: Is it possible to set an interval for posting data on twitter? I noticed a post-interval variable in the code: post-interval=300. Is this te place to change it?

if you want to tweet every LOOP, then set binding=loop.  the default is to tweet every archive record, i.e., binding=archive.

if you want at most one tweet per hour (whether loop or archive), then set post_interval=3600

m

Jan Valkenier

unread,
Oct 19, 2014, 8:55:31 AM10/19/14
to weewx...@googlegroups.com
Thnx, I'll try it.

Op zondag 19 oktober 2014 14:43:43 UTC+2 schreef mwall:

Steve

unread,
Oct 19, 2014, 11:47:14 AM10/19/14
to weewx...@googlegroups.com
The post_interval= 3600 works perfectly for me.

As I'm a want, want type, is it possible to include that in the weewx.conf under:

[StdRESTful]
    [[Twitter]]

So each new and improved version doesn't mean altering the twiiter.py file as it's released

Regards,

Steve.

mwall

unread,
Oct 19, 2014, 11:58:26 AM10/19/14
to weewx...@googlegroups.com
On Sunday, October 19, 2014 11:47:14 AM UTC-4, Steve wrote:
The post_interval= 3600 works perfectly for me.

As I'm a want, want type, is it possible to include that in the weewx.conf under:

[StdRESTful]
    [[Twitter]]

So each new and improved version doesn't mean altering the twiiter.py file as it's released


steve,

did you try?  all of the standard restful options should work for twitter and any other restful extension.

post_interval
log_success
log_failure
max_backlog
stale
timeout
max_tries
retry_wait

m

Jan Valkenier

unread,
Oct 19, 2014, 3:28:56 PM10/19/14
to weewx...@googlegroups.com
Does it overrule the definition in twitter.py then?

Is it possible to get the timestamp in human readable format (UTC)?



Op zondag 19 oktober 2014 17:58:26 UTC+2 schreef mwall:

Steve

unread,
Oct 19, 2014, 7:22:19 PM10/19/14
to weewx...@googlegroups.com
I hadn't tried that Matthew.

I have now, and it works fine thanks (I only tried altering the post_interval the defaults for the other settings are good enough for me).

Steve.

Jan Valkenier

unread,
Oct 20, 2014, 5:43:24 AM10/20/14
to weewx...@googlegroups.com


Op zondag 19 oktober 2014 21:28:56 UTC+2 schreef Jan Valkenier:
Does it overrule the definition in twitter.py then?

Is it possible to get the timestamp in human readable format (UTC)?

I found out and used:

ts= time.strftime("%d/%m/%Y %H:%M", time.localtime(record['dateTime']))
s.append("%s" % ts)

It now yields time in a readable format!

Steve

unread,
Oct 20, 2014, 7:50:58 AM10/20/14
to weewx...@googlegroups.com
That worked.

You even saved me from having to swap %d/%m/ :)

Steve.

Kenneth Baker

unread,
Oct 21, 2014, 7:05:17 PM10/21/14
to weewx...@googlegroups.com

Hi mwall,

Could I request a small enhancement to the twitter poster? Could you provide a
configuration option to disable/enable posting of inside temperature / humidity?

-- Ken


mwall

unread,
Oct 21, 2014, 7:27:58 PM10/21/14
to weewx...@googlegroups.com, bak...@umich.edu

i'm trying to come up with a generic yet simple approach to specifying a tweet format.  i am close to publishing a new emoncms/xively/seg uploaders that let you specify per-observation label, format, and units.  but i think that is overkill for twitter.

i considered a simple format string.  for example, to tweet only your wind information and out temperature:

[Twitter]
    format = {station}: Ws: {windSpeed} Wd: {windDir} Wg: {windGust}; oT: {outTemp}

if an observation is None, you would see None:

my_station: Ws: 0; Wd: None; Wg: 10; oT: 18.2

if an observation does not exist, it would be blank:

my_station: Ws: 2; Wd: 90; Wg:; oT: 17.9

would that work?  do you have other ideas?

m

Kenneth Baker

unread,
Oct 21, 2014, 8:02:28 PM10/21/14
to weewx...@googlegroups.com

Hi mwall,

I had not been considering anything more than a parameter to remove the inside
temperature and humidity. However I think you get a lot more functionality with the
flexibility you propose below and it would certainly meet my needs.


The only addition I'd suggest to your proposal would be to provide the ability to
configure the time format.

I think I'd use it more like this:

format = {station} @ %H:%M: Ws: {windSpeed} mph; Wd: {windDir} deg; Wg: {windGust}
mph; oT {outTemp} F

would generate:

my_station @ 15:45: Ws: 0 mph; Wd: None deg; Wg: 10 mph; oT: 18.2 F


It might be nice if there was a configuration ability for what None and empty turned
into? I'd be inclined to make it a dash rather than none when I added the units
into the string.

Thanks!

-- Ken
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to

Pat

unread,
Oct 22, 2014, 11:46:38 AM10/22/14
to weewx...@googlegroups.com, bak...@umich.edu
I'm just getting into the twitter addon and would love the ability to control the tweet format. Just wanted to put my +1 in for this request!

Pat

unread,
Oct 22, 2014, 1:37:33 PM10/22/14
to weewx...@googlegroups.com
Question on the looping, I set in my weewx conf the following, but it's still tweeting at the archive interval. 

    [[Twitter]]
post_interval = 60

I don't *really* want to tweet every minute, but I did set it up just for testing purposes and found that it didn't work for me. 

Something I missed?

mwall

unread,
Oct 22, 2014, 2:18:48 PM10/22/14
to weewx...@googlegroups.com


On Wednesday, October 22, 2014 1:37:33 PM UTC-4, Pat wrote:
Question on the looping, I set in my weewx conf the following, but it's still tweeting at the archive interval. 

    [[Twitter]]
post_interval = 60


post_interval specifies the maximum rate at which a restful service will post data.

the LOOP frequency (determined by your hardware) and archive interval (determined by hardware and/or the weewx.conf setting) determine how often data will be available.

if you want LOOP frequency, using the binding=loop setting for twitter.  default is binding=archive.

so if your hardware spits out data once per second, and binding=loop, and post_interval=20, then you will get tweets about every 20 seconds.

if your hardware spits out data once per second and you specify binding=loop, you will get a tweet every second.

the default configuration should result in a tweet every 5 minutes using archive data.

m

mwall

unread,
Oct 22, 2014, 2:20:42 PM10/22/14
to weewx...@googlegroups.com, bak...@umich.edu
On Tuesday, October 21, 2014 8:02:28 PM UTC-4, Kenneth Baker wrote:

Hi mwall,

I had not been considering anything more than a parameter to remove the inside
temperature and humidity.  However I think you get a lot more functionality with the
flexibility you propose below and it would certainly meet my needs.

done in v0.5

here are instructions (from the twitter.py file itself):

You must first obtain app and oauth credentials in order to tweet.  See the    
twitter developer documentation to obtain these:                               
                                                                               
  https://dev.twitter.com/oauth/overview                                       
                                                                               
Specifically, you will need four things:  app_key, app_key_secret, oauth_token,
and oauth_token_secret.                                                        
                                                                               
[StdRESTful]                                                                   
    [[Twitter]]                                                                
        app_key = APP_KEY                                                      
        app_key_secret = APP_KEY_SECRET                                        
        oauth_token = OAUTH_TOKEN                                              
        oauth_token_secret = OAUTH_TOKEN_SECRET                                
                                                                               
Tweets look something like this:                                               
                                                                               
STATION_IDENTIFIER: Ws: 0.0; Wd: -; Wg: 1.1; oT: 7.00; oH: 97.00; P: 1025.307; \
R: 0.000                                                                       
                                                                               
The STATION_IDENTIFIER is the first part of the station 'location' defined in  
weewx.conf.  To specify a different identifier for tweets, use the 'station'   
parameter.  For example:                                                       
                                                                               
[StdRESTful]                                                                   
    [[Twitter]]                                                                
        station = hal                                                          
                                                                               
The 'format' parameter determines the tweet contents.  The default format is:  
                                                                               
format = {station:%.8s}: Ws: {windSpeed:%.1f}; Wd: {windDir:%03.0f}; Wg: {windGust:%.1f}; oT: {outTemp:%.1f}; oH: {outHumidity:%.2f}; P: {barometer:%.3f}; R: {rain:%.3f}                                                                    
                                                                               
To specify a different tweet message, use the format parameter.  For example,  
this would tweet only wind information:                                        
                                                                               
[StdRESTful]                                                                   
    [[Twitter]]                                                                
        format = {station}: Ws: {windSpeed}; Wd: {windDir}; Wg: {windGust}     
                                                                               
If there is no value for an observation, the hyphen (-) will display.  If      
the observation does not exist, the observation label will not be replaced.    
If no format is specified for an observation, the default is used.             
For example:                                                                   
                                                                               
    Ws: {windSpeed}             ->  Ws: 12.3452343                             
    Ws: {windSpeed:%.3f}        ->  Ws: 12.345                                 
                                                                               
The dateTime field is handled slightly differently.  For example:              
                                                                               
    ts: {dateTime}              ->  ts: 1413994070                             
    ts: {dateTime:%X}           ->  ts: 16:07:50 22 Oct 2014                   
    ts: {dateTime:%H:%M:%S}     ->  ts: 16:07:50                               
                                                                               
By default, the units are those specified by the unit system in the            
StdConvert section of weewx.conf.  To specify a different unit system,         
use the unit_system option:                                                    
                                                                               
[StdRESTful]                                                                   
    [[Twitter]]                                                                
        unit_system = METRICWX                                                 
                                                                               
Possible values include US, METRIC, or METRICWX.                               

Pat

unread,
Oct 22, 2014, 2:21:29 PM10/22/14
to weewx...@googlegroups.com
Thanks for the explanation. Makes perfect sense now!

Pat

unread,
Oct 22, 2014, 2:41:11 PM10/22/14
to weewx...@googlegroups.com, bak...@umich.edu
Just upgraded to 0.5, and the new ability to control format works great so far!

Kenneth Baker

unread,
Oct 22, 2014, 3:53:05 PM10/22/14
to mwall, weewx...@googlegroups.com

> The dateTime field is handled slightly differently. For
> example:
>
>
> ts: {dateTime} -> ts:
> 1413994070
> ts: {dateTime:%X} -> ts: 16:07:50 22 Oct
> 2014
> ts: {dateTime:%H:%M:%S} -> ts:
> 16:07:50


mwall,

Is there a chance for a datetime option in local time (instead or in addition to UTC)?

-- Ken


mwall

unread,
Oct 22, 2014, 4:50:59 PM10/22/14
to weewx...@googlegroups.com, mw...@users.sourceforge.net, bak...@umich.edu
On Wednesday, October 22, 2014 3:53:05 PM UTC-4, Kenneth Baker wrote:
mwall,

Is there a chance for a datetime option in local time (instead or in addition to UTC)?

-- Ken

i knew someone would ask for that.  try v0.6.  default is localtime.  if you want utc then:

[[Twitter]]
    format_utc = True

btw, if you want something other than - for None, use format_None:

[[Twitter]]
    format_None = N/A

m

Thomas Keffer

unread,
Oct 22, 2014, 5:14:12 PM10/22/14
to weewx-user

Why not use the dot codes for this? It's not hard to invoke cheetahgenerator in the same thread, much like wee_reports does.

-tk

Fat-fingered from my Android

--

Kenneth Baker

unread,
Oct 22, 2014, 5:56:22 PM10/22/14
to mwall, weewx...@googlegroups.com, mw...@users.sourceforge.net

> i knew someone would ask for that. try v0.6. default is localtime. if
> you want utc then:
>
> [[Twitter]]
> format_utc = True
>
> btw, if you want something other than - for None, use format_None:
>
> [[Twitter]]
> format_None = N/A

works like a charm...

-- Ken


Message has been deleted

Invisible Man

unread,
Nov 10, 2014, 4:44:31 AM11/10/14
to weewx...@googlegroups.com, mw...@users.sourceforge.net
Twitter 0.6 works great! Thanks!
Is it possible to have it tweet only like twice a day, and not as regularly as the other reports?

Regards
Axelle

Steve

unread,
Nov 10, 2014, 4:59:57 AM11/10/14
to weewx...@googlegroups.com, mw...@users.sourceforge.net
You can specify the post interval

[[Twitter]]
        post_interval = 3600

Means I get a tweet every hour.

Regards,

Steve.

Invisible Man

unread,
Nov 12, 2014, 2:54:12 PM11/12/14
to weewx...@googlegroups.com, mw...@users.sourceforge.net
Hi,

The post_interval option works fine.Thanks very much.

For your information, I slightly modified the code because I want to tweet around 7am, 14 and 18.
So, I set post_interval to 3600, and in the code modified process_record() to only actually tweet if the current time is what I want.

   ts = time.localtime()
       
if (ts.tm_hour != 7 and ts.tm_hour != 14 and ts.tm_hour != 18):
            logdbg
("This is not hour to tweet: %d" % ts.tm_hour)
           
return

Regards
Axelle

Steve

unread,
Nov 13, 2014, 5:53:55 AM11/13/14
to weewx...@googlegroups.com
That's a handy tip :)

Steve.

Jan Valkenier

unread,
Dec 4, 2014, 3:04:09 AM12/4/14
to weewx...@googlegroups.com
Does anyone now howto add the degree symbol in the format?

mwall

unread,
Dec 4, 2014, 1:31:08 PM12/4/14
to weewx...@googlegroups.com
On Thursday, December 4, 2014 3:04:09 AM UTC-5, Jan Valkenier wrote:
Does anyone now howto add the degree symbol in the format?

try this:

[StdRESTful]
    [[Twitter]]
        unit_system = METRICWX
        format = "temperature: {outTemp:%.1f}\xc2\xb0C"

the \xc2\xb0 is utf8 for the degree symbol.

m

Pat

unread,
Dec 9, 2014, 5:08:54 PM12/9/14
to weewx...@googlegroups.com
Hi there, I installed weewx 3.0.1 and the Twitter.py script doesn't seem to be working with it. Here's some errors I'm getting.

Thoughts?

Dec  9 16:57:25 pobwx weewx[3720]: restx: Twitter: service version is 0.5
Dec  9 16:57:25 pobwx weewx[3720]:     ****  Traceback (most recent call last):
Dec  9 16:57:25 pobwx weewx[3720]:     ****    File "/usr/share/weewx/weewx/engine.py", line 834, in main
Dec  9 16:57:25 pobwx weewx[3720]:     ****      engine = EngineClass(config_dict)
Dec  9 16:57:25 pobwx weewx[3720]:     ****    File "/usr/share/weewx/weewx/engine.py", line 74, in __init__
Dec  9 16:57:25 pobwx weewx[3720]:     ****      self.loadServices(config_dict)
Dec  9 16:57:25 pobwx weewx[3720]:     ****    File "/usr/share/weewx/weewx/engine.py", line 140, in loadServices
Dec  9 16:57:25 pobwx weewx[3720]:     ****      self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
Dec  9 16:57:25 pobwx weewx[3720]:     ****    File "/usr/share/weewx/user/twitter.py", line 135, in __init__
Dec  9 16:57:25 pobwx weewx[3720]:     ****      site_dict = weewx.restx.get_dict(config_dict, 'Twitter')
Dec  9 16:57:25 pobwx weewx[3720]:     ****  AttributeError: 'module' object has no attribute 'get_dict'

mwall

unread,
Dec 9, 2014, 5:46:48 PM12/9/14
to weewx...@googlegroups.com
On Tuesday, December 9, 2014 5:08:54 PM UTC-5, Pat wrote:
Hi there, I installed weewx 3.0.1 and the Twitter.py script doesn't seem to be working with it. Here's some errors I'm getting.

Thoughts?

try updating to twitter extension v0.7

all of the uploaders had to be updated to work with weewx 3.

m

Pat

unread,
Dec 9, 2014, 6:11:56 PM12/9/14
to weewx...@googlegroups.com
Ah, I missed the upgrade to 0.7 (and also lost the download link). I've found both and I'm back to normal. 

Thanks!

Jan Valkenier

unread,
Dec 12, 2014, 2:59:54 PM12/12/14
to weewx...@googlegroups.com
I tried, but it yields:

Temp:4.9\xc2\xb0C;

my full format:

format = "{dateTime:%H:%M}h; Baro:{barometer:%.1f} hPa; Temp:{outTemp:%.1f}\xc2\xb0C; Chill:{windchill:%.1f}\xc2\xb0C; Wind:{windSpeed:%.1f} m/s uit {windDir:%.0f} gr; Vlaag:{windGust:%.1f} m/s; Luchtvocht:{outHumidity:%.0f} %; Regen:{rainRate:%.1f} mm/h"

something tot do with " ?

Op donderdag 4 december 2014 19:31:08 UTC+1 schreef mwall:

Pat

unread,
Dec 12, 2014, 9:00:56 PM12/12/14
to weewx...@googlegroups.com
Another small item. I'm trying to put in a #RaspberryPi hashtag on my tweets and it's not working. Thoughts?

Thanks!

Pat

unread,
Dec 20, 2014, 11:02:14 PM12/20/14
to weewx...@googlegroups.com
Just wanted to check in to see if there were thoughts on how to include hashtags?

Thanks!

Topslakr Topslakr

unread,
Jan 7, 2015, 11:43:02 AM1/7/15
to weewx...@googlegroups.com, mw...@users.sourceforge.net
I too want to post at certain times, not just hourly. I appreciate at you posted your code snippet, but I'm not sure where to insert it. What should I look for/replace in the twitter.py file? I imagine I'll have to modify it each time I update the twitter extension?

Further, I was wondering if it might be possible/easier to just setup a cron job to run the process at certain times using the most current data already stored.

Robert

mwall

unread,
Jan 7, 2015, 12:38:28 PM1/7/15
to weewx...@googlegroups.com
On Friday, December 12, 2014 9:00:56 PM UTC-5, Pat wrote:
Another small item. I'm trying to put in a #RaspberryPi hashtag on my tweets and it's not working. Thoughts?

pat,

did you try something like this:

[StdRestful]
    [[Twitter]]
        format = "{station}: oT: {outTemp} #RaspberryPi"

if you put the format in quotes, the # should be parsed as part of the string instead of a comment character for the line.

m

mwall

unread,
Jan 7, 2015, 12:41:55 PM1/7/15
to weewx...@googlegroups.com, mw...@users.sourceforge.net
On Wednesday, January 7, 2015 11:43:02 AM UTC-5, Topslakr Topslakr wrote:
I too want to post at certain times, not just hourly. I appreciate at you posted your code snippet, but I'm not sure where to insert it. What should I look for/replace in the twitter.py file? I imagine I'll have to modify it each time I update the twitter extension?

Further, I was wondering if it might be possible/easier to just setup a cron job to run the process at certain times using the most current data already stored.


robert,

insert the code in the process_record method, just before the "#now do the posting" comment in twitter.py

if you use a cron job then get the data from the latest record in the sqlite or mysql database.

m

Topslakr Topslakr

unread,
Jan 7, 2015, 12:48:24 PM1/7/15
to weewx...@googlegroups.com, mw...@users.sourceforge.net
Awesome. Thank you! I've made the change and need only wait for it to come around :)

Robert

Pat

unread,
Jan 7, 2015, 1:05:42 PM1/7/15
to weewx...@googlegroups.com
I ended up wrapping it in single quotes, and it seemed to work. I disabled it for now while I tweak other settings. If the single ends up not working, I'll try the double. 

Steve

unread,
Jan 10, 2015, 9:42:29 AM1/10/15
to weewx...@googlegroups.com
Here's another way of adding a hashtag (I won't be using it, I was just playing around), If you're not tweeting a station name you can use the station name in double quotes too. Result attached.

    [[Twitter]]
        station = "#RPi"
...
...
...
        format = {station:%.8s}: outTemp:{outTemp:%.1f}c; .......

Steve.


Frank Johnson

unread,
Feb 2, 2015, 7:45:54 PM2/2/15
to weewx...@googlegroups.com, mw...@users.sourceforge.net
Axelle 
  where did you put this code to control hours of tweets?? 
in twitter.py if so where...
  thanks frank

Frank Johnson

unread,
Feb 2, 2015, 7:58:56 PM2/2/15
to weewx...@googlegroups.com, mw...@users.sourceforge.net
Disregard i see this was answered...
  frank

Jan Valkenier

unread,
Feb 5, 2015, 1:31:51 PM2/5/15
to weewx...@googlegroups.com
I still have two questions about the twitter extension:

1.) I did not manage to get the degree symbol in the twitter feed, could you shed some light on that once more?

2.)  I'm using the metricwx format, though I would like to twitter the windspeed in knots instead of m/s, because the weatherstation is placed on a sailing centre. The sailors are used to windspeed in knots. Is this possible?

Thanks a lot for your effort!
Message has been deleted

Jan Valkenier

unread,
Apr 14, 2015, 6:30:14 PM4/14/15
to weewx...@googlegroups.com
Allright,

I "borrowed" some code from the windfinder.py extension:

I inserted:

def _mps_to_knot(v):
    from_t = (v, 'meter_per_second', 'group_speed')
    return weewx.units.convert(from_t, 'knot')[0]

at the beginning of twitter.py and:

if 'windSpeed' in record and record['windSpeed'] is not None:
            record['windSpeed'] = _mps_to_knot(record['windSpeed'])
        if 'windGust' in record and record['windGust'] is not None:
            record['windGust'] = _mps_to_knot(record['windGust'])

under def process_record

Now it tweets in knots :)
I know its a bit of a hack, but it works for now.

Op donderdag 5 februari 2015 19:31:51 UTC+1 schreef Jan Valkenier:
Message has been deleted
Message has been deleted

Arnaud RAHIER

unread,
Mar 28, 2022, 4:00:45 PM3/28/22
to weewx-user
Hello, I installed the twitter extension 'weewx-twitter' on my install (Debian 11 + WeeWX 4.7.0 + weewx-twitter 0.15) and it works fine. I modified the 'twitter.py' file to post a tweet to my weather twitter account and I wish the extension sends a tweet at a fixed time (0:00, 6:00, 12:00, 18:00). But if WeeWX or the computer restarts, tweets are sent the minutes the software starts (Ex: If WeeWX restarts at 4:12, the tweet is sent at 6:12, then 12:12, 18:12).

Here is my part of the file:

```    ts = time.localtime()
        if (ts.tm_hour != 0 and ts.tm_hour != 6 and ts.tm_hour != 12 and ts.tm_hour != 18):
```

Jon B

unread,
Jan 6, 2023, 9:24:33 PM1/6/23
to weewx-user
I managed this by modifying Axelle's code above in process_record():

ts = time.localtime()
    if ts.tm_hour not in (0,6,12,18) or ts.tm_min != 0:

        logdbg("This is not hour to tweet: %d" % ts.tm_hour)
        return

That should tweet at 00:00, 06:00, 12:00 and 18:00. I'm not sure if this will necessarily work if the archive interval is longer than 1 minute though (my station is set to 1 minute)
Message has been deleted

Jon B

unread,
Jan 6, 2023, 9:33:15 PM1/6/23
to weewx-user
Is it possible to use this Twitter extension to post the daily archived values for a given day? Ideally I'd like to set it to automatically tweet once a day (say at 10am local time) giving the stats for the previous day, e.g.:

06/01/2023: Max temperature: 12.3C, Min temperature: 2.3C, Max wind gust: 35 mph, Total rainfall: 12.2 mm

I have it working so that it only tweets once a day at 10am, but giving instantaneous values is a bit pointless at that tweet frequency

Jon B

unread,
Jan 23, 2023, 2:08:14 PM1/23/23
to weewx-user
Does anyone have any ideas for this? I guess one way may be to read from the previous day's archive_day entries in the database e.g. archive_day_rain, although I'm not sure how easy/practical this would be

Glenn McKechnie

unread,
Jan 23, 2023, 6:03:58 PM1/23/23
to weewx...@googlegroups.com
There may be other ways, but use tags. This is the approach I've taken
with weewx-mastodon.

Using weewx tags ( https://weewx.com/docs/customizing.htm#Tags) in a
template will generate the desired text output.
You would however need to modify the twitter extension to post the
output from a weewx generated template. (see below)

eg:- template (snippet)...

#Weather summary for Yesterday ($yesterday.dateTime.format("%A
%d-%b-%Y")) at
$station.location, Australia: \n
Temp: (min: $yesterday.outTemp.min at $yesterday.outTemp.mintime)
(max: $yesterday.outTemp.max at $yesterday.outTemp.maxtime)

will generate the following text...

#Weather summary for Yesterday (Monday 23-Jan-2023) at
Messmate Farm, Broomfield, Victoria, Australia: \n
Temp: (min: 11.6C at 06:35:01) (max: 35.1C at 16:46:02)

https://github.com/glennmckechnie/weewx-mastodon

If you're familiar with python it should offer a few hints ho w to
post the template rather than the hardcoded format string, especially
as it's a fork of Mathews weewx-twitter extension.

I haven't incoporated the summary in weewx-mastodon - yet. It was on
the mental ToDo list, but it would only need a timing section and some
selection magic.
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to weewx-user+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/9fcf620c-45f2-499d-8d9f-d91d1861160bn%40googlegroups.com.
>


--


Cheers
Glenn

rorpi - read only raspberry pi & various weewx addons
https://github.com/glennmckechnie

Invisible Man

unread,
Aug 26, 2023, 3:14:18 PM8/26/23
to weewx-user
I used to use Weewx Twitter extension (https://github.com/matthewwall/weewx-twitter). 
Am I right to say it no longer works now with Twitter, unless you have a paid API subscription?

```
Aug 26 18:16:22 vegan weewx[20951] ERROR user.twitter: Failed attempt 3 of 3: Twitter API returned a 403 (Forbidden), You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product
```

I suppose the idea is to move to Mastodon with https://github.com/glennmckechnie/weewx-mastodon ?

-- Axelle

Greg Troxel

unread,
Aug 26, 2023, 3:23:26 PM8/26/23
to Invisible Man, weewx-user
Invisible Man <axelle....@gmail.com> writes:

> I used to use Weewx Twitter extension
> (https://github.com/matthewwall/weewx-twitter).
> Am I right to say it no longer works now with Twitter, unless you have a
> paid API subscription?
>
> ```
> Aug 26 18:16:22 vegan weewx[20951] ERROR user.twitter: Failed attempt 3 of
> 3: Twitter API returned a 403 (Forbidden), You currently have access to a
> subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media
> post, oauth) only. If you need access to this endpoint, you may need a
> different access level. You can learn more here:
> https://developer.twitter.com/en/portal/product
> ```

My impression from posts in other context is that bot posting requires a
paid subscription, and that paid API access cannot be had for a charge
that is reasonable for an individual. A number of bots that I am aware
of have either moved to mastodon or just stopped. So do not adjust your
television; the problem is elsewhere.

> I suppose the idea is to move to Mastodon
> with https://github.com/glennmckechnie/weewx-mastodon ?

Generally, yes, the path to righteousness is via federated open
protocols, and I see no reason that would be different in posting
weather. But seriously, that is what people are generally doing (in a
broader than weewx context).

Strictly, you don't need mastodon, but ActivityPub, but if the server
you want to use is mastodon you don't have to figure out that nuance.
Reply all
Reply to author
Forward
0 new messages