Re: [weewx-user] Weewx to Mastodon/ActivityPub?

2023-05-07 Thread Glenn McKechnie
On 07/05/2023, Jarmo Seppänen  wrote:
> Thank you Glen for the hints.
> I got it working.
> When I added unit_system = METRICWX to StdReport the error disappeared.
> Perhaps the best place for it would be in
> [StdRESTful]
> [[Mastodon]]
> ...
> unit_system = US, METRIC, METRICWX
> if that is possible as that way one could configure it for Mastodon only.

Yep. Sounds like a good fallback solution.
I'll still keep the original as it should be there in a standard
install , and it still exists in that location with Weewx v5;  but I
will set that location as a 'report specific' option - which it
probably should have anyway.

[...]

> Oh, one thing I discovered when trying to report the UV readings.
> I got an error:
> weewx[30835] CRITICAL weewx.restx: Mastodon: Thread terminating. Reason:
> can only concatenate str (not "NoneType") to str
> After digging around I noticed that in file
> /home/weewx/bin/user/wxtoot.py in line 481
> 'uv_index': 'None', was causing the issue.
> I changed it to:
> 'uv_index': '',

You are correct. There is no unit for UV so '"" covers it.

> As I'm a lousy developer I don't know if this breaks something else but at
> least "it works for me" :)

It is the fix, and consider yourself a value adding bug reporter. :)
That feedback is always appreciated.

> Perhaps you can take a look at that too for the coming releases.

Indeed I will.

-- 


Cheers
 Glenn

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

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAAraAzgv-sZ-AD4h2EjXvDiHAhhjP6eCMVwbsKAFPKH2SjHR%3DQ%40mail.gmail.com.


Re: [weewx-user] Weewx to Mastodon/ActivityPub?

2023-05-07 Thread Jarmo Seppänen
Thank you Glen for the hints.
I got it working.
When I added unit_system = METRICWX to StdReport the error disappeared.
Perhaps the best place for it would be in 
[StdRESTful] 
[[Mastodon]]
...
unit_system = US, METRIC, METRICWX
if that is possible as that way one could configure it for Mastodon only.

The server part was actually the mastodon server URL that I signed in to 
i.e. 'mas.to' in my case. The confusion I had was because I thought I can 
find the server info from the same place where key_access_token can be 
retrieved and I thought it's something funny like dev.mastodon.com or 
similar where the API would reside.

Oh, one thing I discovered when trying to report the UV readings.
I got an error:
weewx[30835] CRITICAL weewx.restx: Mastodon: Thread terminating. Reason: 
can only concatenate str (not "NoneType") to str
After digging around I noticed that in file
/home/weewx/bin/user/wxtoot.py in line 481
'uv_index': 'None', was causing the issue.
I changed it to:
'uv_index': '',
As I'm a lousy developer I don't know if this breaks something else but at 
least "it works for me" :)
Perhaps you can take a look at that too for the coming releases.

But thanks again for instructions you provided and creating this addon. 
It's an excellent replacement for Twitter.

jaMO
perjantai 5. toukokuuta 2023 klo 12.37.39 UTC+3 Glenn McKechnie kirjoitti:

> On 05/05/2023, Jarmo Seppänen  wrote:
> > After installation I'm getting the following error to logs:
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: Caught
> > unrecoverable exception:
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: 
> > 'unit_system'
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  Traceback
> > (most recent call last):
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  File
> > "/home/weewx/bin/weewxd", line 148, in main
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: 
> > engine = weewx.engine.StdEngine(config_dict)
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  File
> > "/home/weewx/bin/weewx/engine.py", line 93, in __init__
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: 
> > self.loadServices(config_dict)
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  File
> > "/home/weewx/bin/weewx/engine.py", line 161, in loadServices
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  obj =
> > weeutil.weeutil.get_object(svc)(self, config_dict)
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  File
> > "/home/weewx/bin/user/wxtoot.py", line 290, in __init__
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  usn =
> >
> > config_dict['StdReport']['Defaults']['unit_system']
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  File
> > "/usr/lib/python3/dist-packages/configobj.py", line 554, in __getitem__
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  val =
> > dict.__getitem__(self, key)
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  KeyError:
> > 'unit_system'
> > May 5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  Exiting.
> > Any hints?
>
> It's looking for the unit_system section in your weewx.conf file.
> In the default weewx.conf for Weewx 4.10.2 it appears as follows...
> [StdReport]
> [...]
> [[Defaults]]
> [...]
> unit_system = us
>
> Do you have an entry for unit_system in your weewx.conf file?
> If it's missing, then put one in and see if that fixes that hiccup
> (and I'll rethink if that's the best place to discover the
> unit_system, or what to do if it goes missing)
>
> Which leads to...
> What version of weewx are you running,
> What's the version of wxtoot.py (at line 177)
> Have you edited the weewx.conf file and removed that entry?
>
> > Also the parameter: server_url_mastodon = 'replace_me' confuses me. What 
> is
> > this exactly?
>
> See the README, but to recap, it is as follows.
>
> You are going to post to a Mastodon server. It lives somewhere and has
> an address.
> So, which one? What is its address? URL, IP?
>
> That information replaces the place-holder 'replace_me' within your
> weewx.conf file, as follows.
>
> [StdRESTful]
> [...]
> [Mastodon]
> [...]
> server_url_mastodon = 'replace_me'
>
> You will also need a 'key_access_token' which you can only get by
> following the instructions on that server. It's available from your
> account there.
>
> Review the README.md , in particular the last section, after 'Options'
>
> https://github.com/glennmckechnie/weewx-mastodon
>
> If you are still having problems then attach the log and a sanitised
> (password free) copy of weewx.conf to your next post, or send it
> directly to me.
>
> -- 
>
> Cheers
> Glenn
>
> rorpi - read only raspberry pi & various weewx addons
> https://github.com/glennmckechnie
>

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

Re: [weewx-user] Weewx to Mastodon/ActivityPub?

2023-05-05 Thread Glenn McKechnie
On 05/05/2023, Jarmo Seppänen  wrote:
> After installation I'm getting the following error to logs:
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: Caught
> unrecoverable exception:
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: 
>  'unit_system'
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   Traceback
> (most recent call last):
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File
> "/home/weewx/bin/weewxd", line 148, in main
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: 
>  engine = weewx.engine.StdEngine(config_dict)
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File
> "/home/weewx/bin/weewx/engine.py", line 93, in __init__
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: 
>  self.loadServices(config_dict)
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File
> "/home/weewx/bin/weewx/engine.py", line 161, in loadServices
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   obj =
> weeutil.weeutil.get_object(svc)(self, config_dict)
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File
> "/home/weewx/bin/user/wxtoot.py", line 290, in __init__
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   usn =
>
> config_dict['StdReport']['Defaults']['unit_system']
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File
> "/usr/lib/python3/dist-packages/configobj.py", line 554, in __getitem__
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   val =
> dict.__getitem__(self, key)
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   KeyError:
> 'unit_system'
> May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   Exiting.
> Any hints?

It's looking for the unit_system section in your weewx.conf file.
In the default weewx.conf for Weewx 4.10.2 it appears as follows...
[StdReport]
[...]
[[Defaults]]
[...]
unit_system = us

Do you have an entry for unit_system in your weewx.conf file?
If it's missing, then put one in and see if that fixes that hiccup
(and I'll rethink if that's the best place to discover the
unit_system, or what to do if it goes missing)

Which leads to...
 What version of weewx are you running,
 What's the version of wxtoot.py (at line 177)
 Have you edited the weewx.conf file and removed that entry?

> Also the parameter: server_url_mastodon = 'replace_me' confuses me. What is
> this exactly?

See the README, but to recap, it is as follows.

You are going to post to a Mastodon server. It lives somewhere and has
an address.
So, which one? What is its address? URL, IP?

That information replaces the place-holder  'replace_me' within your
weewx.conf file, as follows.

[StdRESTful]
[...]
[Mastodon]
[...]
server_url_mastodon = 'replace_me'

You will also need a 'key_access_token' which you can only get by
following the instructions on that server. It's available from your
account there.

Review the README.md , in particular the last section, after 'Options'

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

If you are still having problems then attach the log and a sanitised
(password free) copy of weewx.conf to your next post, or send it
directly to me.

-- 

Cheers
 Glenn

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

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAAraAzjY8OqF9hUqxvPN%3DjO8dvedTi9hhGum7fLjNcTi2YPCiA%40mail.gmail.com.


Re: [weewx-user] Weewx to Mastodon/ActivityPub?

2023-05-05 Thread Jarmo Seppänen
After installation I'm getting the following error to logs:
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: Caught 
unrecoverable exception:
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  
 'unit_system'
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   Traceback 
(most recent call last):
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File 
"/home/weewx/bin/weewxd", line 148, in main
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  
 engine = weewx.engine.StdEngine(config_dict)
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File 
"/home/weewx/bin/weewx/engine.py", line 93, in __init__
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:  
 self.loadServices(config_dict)
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File 
"/home/weewx/bin/weewx/engine.py", line 161, in loadServices
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   obj = 
weeutil.weeutil.get_object(svc)(self, config_dict)
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File 
"/home/weewx/bin/user/wxtoot.py", line 290, in __init__
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   usn = 
config_dict['StdReport']['Defaults']['unit_system']
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__: File 
"/usr/lib/python3/dist-packages/configobj.py", line 554, in __getitem__
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   val = 
dict.__getitem__(self, key)
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   KeyError: 
'unit_system'
May  5 10:57:35 raspi3b weewx[19058] CRITICAL __main__:   Exiting.

Any hints?

Also the parameter: server_url_mastodon = 'replace_me' confuses me. What is 
this exactly?

tiistai 27. joulukuuta 2022 klo 14.48.51 UTC+2 Glenn McKechnie kirjoitti:

> Okay,
>
> https://github.com/glennmckechnie/weewx-mastodon
>
> The rough edges have been filed smooth. You shouldn't need to wear
> gloves anymore!
>
> To see it in action...
> https://mastodon.au/@BroomfieldWeatherBot
>
>
>
> On 22/12/2022, Chris Alemany  wrote:
> > Oh! Elegant solution.
> >
> > My “bot” is at @alberniw...@mstdn.ca
> > http://mstdn.ca/@alberniweatherBot
> > Note, the instance has been extremely busy lately so don’t be surprised 
> if
> > the connection times out.
> >
> > Cheers
> > Chris
> >
> >> On Dec 21, 2022, at 06:16, Mark Fraser  wrote:
> >>
> >> On 21/12/2022 07:45, Glenn McKechnie wrote:
> >>> Hi Chris,
> >>> Nothing like finding a day where you can plunge, guilt free, into the
> >>> ToDo list. I didn't have a Snow day, but I borrowed yours!
> >>> I started re-purposing Matthew Walls twitter extension (which runs
> >>> uses RestX - [StdRESTful] ) and have had good success with it in the
> >>> half day or so that it's been runnng. Still some work to do on it
> >>> (phttt) but the text part works well enough.
> >>> Your use of the template is interesting - that gives it a bit of
> >>> flexibility.
> >>> I'll mull that one over while I continue down the media (image) path.
> >>> Alpha is at ...
> >>> https://github.com/glennmckechnie/weewx-mastodon
> >>> On 21/12/2022, Chris Alemany  wrote:
>  The snowy weather here on Vancouver Island has given me some 
> unexpected
>  time to work on this. I now have a working template file and python
>  script
> 
>  that will produce and post weewx data to a Mastodon account.
>  Just setup an account on your favourite Mastodon server,
>  mark it as a bot,
>  create an API/Client Key (under development in your account's
>  preferences)
>  install the template file to one of your skins (I just added it to the
>  Standard skin.
>  put the python file somewhere it can be run with cron
>  run the python file with a command like this:
> 
>  sudo python3 weewx_to_mastodon.py --server https://mstdn.ca --wxdata
>  https://mywebpage.com/mastodon.json --api_key biglongstring234fssdf
> 
>  I've attached my working files if anyone is itching to have it, excuse
>  the
>  messy code but it should be fairly self explanatory. You should only
>  really
> 
>  need to modify the values in the json.tmpl file.
> 
>  On Sunday, December 18, 2022 at 3:40:31 PM UTC-8 Chris Alemany wrote:
> 
> > Here is the promised link to the fellow who created a Python script
> > from
> > cumulus on Mac to Mastodon/ActivityPub:
> > 
> https://github.com/buffaloseven/CumulusMX-Customizations/tree/main/integrations
> >
> > Sent from my iPhone
> >
> > On Dec 15, 2022, at 6:24 AM, Chris Alemany  
> wrote:
> >
> > Hi all,
> >
> >
> >
> > Has anyone had a go at having weewx post to Mastodon/Fediverse, 
> either
> > to
> >
> > an existing @user@server or as an independent instance?
> >
> > There is at least one fellow who has written 

Re: [weewx-user] Weewx to Mastodon/ActivityPub?

2022-12-27 Thread Chris Alemany
Nice work!

> On Dec 27, 2022, at 04:48, Glenn McKechnie  wrote:
> 
> Okay,
> 
> https://github.com/glennmckechnie/weewx-mastodon
> 
> The rough edges have been filed smooth. You shouldn't need to wear
> gloves anymore!
> 
> To see it in action...
> https://mastodon.au/@BroomfieldWeatherBot
> 
> 
> 
> On 22/12/2022, Chris Alemany  wrote:
>> Oh! Elegant solution.
>> 
>> My “bot” is at @alberniweather...@mstdn.ca
>> http://mstdn.ca/@alberniweatherBot
>> Note, the instance has been extremely busy lately so don’t be surprised if
>> the connection times out.
>> 
>> Cheers
>> Chris
>> 
>>> On Dec 21, 2022, at 06:16, Mark Fraser  wrote:
>>> 
>>> On 21/12/2022 07:45, Glenn McKechnie wrote:
 Hi Chris,
 Nothing like finding a day where you can plunge, guilt free, into the
 ToDo list.  I didn't have a Snow day, but I borrowed yours!
 I started re-purposing Matthew Walls twitter extension (which runs
 uses RestX - [StdRESTful] ) and have had good success with it in the
 half day or so that it's been runnng. Still some work to do on it
 (phttt) but the text part works well enough.
 Your use of the template is interesting - that gives it a bit of
 flexibility.
 I'll mull that one over while I continue down the media (image) path.
 Alpha is at ...
 https://github.com/glennmckechnie/weewx-mastodon
 On 21/12/2022, Chris Alemany  wrote:
> The snowy weather here on Vancouver Island has given me some unexpected
> time to work on this.  I now have a working template file and python
> script
> 
> that will produce and post weewx data to a Mastodon account.
> Just setup an account on your favourite Mastodon server,
> mark it as a bot,
> create an API/Client Key (under development in your account's
> preferences)
> install the template file to one of your skins (I just added it to the
> Standard skin.
> put the python file somewhere it can be run with cron
> run the python file with a command like this:
> 
> sudo python3  weewx_to_mastodon.py --server https://mstdn.ca --wxdata
> https://mywebpage.com/mastodon.json --api_key biglongstring234fssdf
> 
> I've attached my working files if anyone is itching to have it, excuse
> the
> messy code but it should be fairly self explanatory. You should only
> really
> 
> need to modify the values in the json.tmpl file.
> 
> On Sunday, December 18, 2022 at 3:40:31 PM UTC-8 Chris Alemany wrote:
> 
>> Here is the promised link to the fellow who created a Python script
>> from
>> cumulus on Mac to Mastodon/ActivityPub:
>> https://github.com/buffaloseven/CumulusMX-Customizations/tree/main/integrations
>> 
>> Sent from my iPhone
>> 
>> On Dec 15, 2022, at 6:24 AM, Chris Alemany  wrote:
>> 
>> Hi all,
>> 
>> 
>> 
>> Has anyone had a go at having weewx post to Mastodon/Fediverse, either
>> to
>> 
>> an existing @user@server or as an independent instance?
>> 
>> There is at least one fellow who has written some Python to do it from
>> his
>> 
>> cumulus based system. I will share his GitHub project if someone
>> thinks
>> they can do it.
>> 
>> Cheers
>> Chris
>> 
>> Sent from my iPhone
>>> 
>>> I've been posting to Mastodon for a while now and I've done it a bit
>>> differently.
>>> 
>>> In skin.conf of what ever skin you are using (Seasons for me) I added:
>>>   [[MastodonHourly]]
>>>   encoding = strict_ascii
>>>   template = mastodon.out.tmpl
>>> 
>>> mastodon.out.tmpl contains:
>>> Temp: $current.outTemp Humidity: $current.outHumidity\nPressure:
>>> $current.barometer\nWind: $current.windDir.ordinal_compass,
>>> $current.windSpeed (ave), $current.windGust (gust)\nRain Rate:
>>> $current.rainRate Rain Total: $day.rain.sum\nSolar Radiation:
>>> $current.radiation UV: $current.UV\nSoil Moisture: $current.soilMoist1
>>> 
>>> Lastly I have this python script run hourly from a Crontab using
>>> Mastodon.py and I can upload an image from my webcam at the same time:
>>> 
>>> #!/usr/bin/env python3
>>> from mastodon import Mastodon
>>> from datetime import datetime
>>> 
>>> #   Set up Mastodon
>>> mastodon = Mastodon(
>>>   access_token = '',
>>>   api_base_url = ''
>>> )
>>> 
>>> photo_path = '/var/www/html/webcam.jpg'
>>> now = datetime.now()
>>> spoiler = 'Live weather for #Yeovil at ' + now.strftime('%d/%m/%y %H.00')
>>> 
>>> f = open('/var/www/html/weewx/mastodon.out','r')
>>> media = mastodon.media_post(photo_path)
>>> content = f.read()
>>> tweet = content.replace("\\n","\n")
>>> mastodon.status_post(tweet, media_ids=media, spoiler_text=spoiler)
>>> f.close()
>>> 
>>> --
>>> 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+unsubscr...@googlegroups.com
>>> 

Re: [weewx-user] Weewx to Mastodon/ActivityPub?

2022-12-27 Thread Glenn McKechnie
Okay,

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

The rough edges have been filed smooth. You shouldn't need to wear
gloves anymore!

To see it in action...
https://mastodon.au/@BroomfieldWeatherBot



On 22/12/2022, Chris Alemany  wrote:
> Oh! Elegant solution.
>
> My “bot” is at @alberniweather...@mstdn.ca
> http://mstdn.ca/@alberniweatherBot
> Note, the instance has been extremely busy lately so don’t be surprised if
> the connection times out.
>
> Cheers
> Chris
>
>> On Dec 21, 2022, at 06:16, Mark Fraser  wrote:
>>
>> On 21/12/2022 07:45, Glenn McKechnie wrote:
>>> Hi Chris,
>>> Nothing like finding a day where you can plunge, guilt free, into the
>>> ToDo list.  I didn't have a Snow day, but I borrowed yours!
>>> I started re-purposing Matthew Walls twitter extension (which runs
>>> uses RestX - [StdRESTful] ) and have had good success with it in the
>>> half day or so that it's been runnng. Still some work to do on it
>>> (phttt) but the text part works well enough.
>>> Your use of the template is interesting - that gives it a bit of
>>> flexibility.
>>> I'll mull that one over while I continue down the media (image) path.
>>> Alpha is at ...
>>> https://github.com/glennmckechnie/weewx-mastodon
>>> On 21/12/2022, Chris Alemany  wrote:
 The snowy weather here on Vancouver Island has given me some unexpected
 time to work on this.  I now have a working template file and python
 script

 that will produce and post weewx data to a Mastodon account.
 Just setup an account on your favourite Mastodon server,
 mark it as a bot,
 create an API/Client Key (under development in your account's
 preferences)
 install the template file to one of your skins (I just added it to the
 Standard skin.
 put the python file somewhere it can be run with cron
 run the python file with a command like this:

 sudo python3  weewx_to_mastodon.py --server https://mstdn.ca --wxdata
 https://mywebpage.com/mastodon.json --api_key biglongstring234fssdf

 I've attached my working files if anyone is itching to have it, excuse
 the
 messy code but it should be fairly self explanatory. You should only
 really

 need to modify the values in the json.tmpl file.

 On Sunday, December 18, 2022 at 3:40:31 PM UTC-8 Chris Alemany wrote:

> Here is the promised link to the fellow who created a Python script
> from
> cumulus on Mac to Mastodon/ActivityPub:
> https://github.com/buffaloseven/CumulusMX-Customizations/tree/main/integrations
>
> Sent from my iPhone
>
> On Dec 15, 2022, at 6:24 AM, Chris Alemany  wrote:
>
> Hi all,
>
>
>
> Has anyone had a go at having weewx post to Mastodon/Fediverse, either
> to
>
> an existing @user@server or as an independent instance?
>
> There is at least one fellow who has written some Python to do it from
> his
>
> cumulus based system. I will share his GitHub project if someone
> thinks
> they can do it.
>
> Cheers
> Chris
>
> Sent from my iPhone
>>
>> I've been posting to Mastodon for a while now and I've done it a bit
>> differently.
>>
>> In skin.conf of what ever skin you are using (Seasons for me) I added:
>>[[MastodonHourly]]
>>encoding = strict_ascii
>>template = mastodon.out.tmpl
>>
>> mastodon.out.tmpl contains:
>> Temp: $current.outTemp Humidity: $current.outHumidity\nPressure:
>> $current.barometer\nWind: $current.windDir.ordinal_compass,
>> $current.windSpeed (ave), $current.windGust (gust)\nRain Rate:
>> $current.rainRate Rain Total: $day.rain.sum\nSolar Radiation:
>> $current.radiation UV: $current.UV\nSoil Moisture: $current.soilMoist1
>>
>> Lastly I have this python script run hourly from a Crontab using
>> Mastodon.py and I can upload an image from my webcam at the same time:
>>
>> #!/usr/bin/env python3
>> from mastodon import Mastodon
>> from datetime import datetime
>>
>> #   Set up Mastodon
>> mastodon = Mastodon(
>>access_token = '',
>>api_base_url = ''
>> )
>>
>> photo_path = '/var/www/html/webcam.jpg'
>> now = datetime.now()
>> spoiler = 'Live weather for #Yeovil at ' + now.strftime('%d/%m/%y %H.00')
>>
>> f = open('/var/www/html/weewx/mastodon.out','r')
>> media = mastodon.media_post(photo_path)
>> content = f.read()
>> tweet = content.replace("\\n","\n")
>> mastodon.status_post(tweet, media_ids=media, spoiler_text=spoiler)
>> f.close()
>>
>> --
>> 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+unsubscr...@googlegroups.com
>> .
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/weewx-user/f10a6d44-4c5a-dcd7-0104-46db15126088%40gmail.com.
>
> --
> You received this message because you are subscribe

Re: [weewx-user] Weewx to Mastodon/ActivityPub?

2022-12-21 Thread Chris Alemany
Oh! Elegant solution.

My “bot” is at @alberniweather...@mstdn.ca
http://mstdn.ca/@alberniweatherBot
Note, the instance has been extremely busy lately so don’t be surprised if the 
connection times out.

Cheers
Chris

> On Dec 21, 2022, at 06:16, Mark Fraser  wrote:
> 
> On 21/12/2022 07:45, Glenn McKechnie wrote:
>> Hi Chris,
>> Nothing like finding a day where you can plunge, guilt free, into the
>> ToDo list.  I didn't have a Snow day, but I borrowed yours!
>> I started re-purposing Matthew Walls twitter extension (which runs
>> uses RestX - [StdRESTful] ) and have had good success with it in the
>> half day or so that it's been runnng. Still some work to do on it
>> (phttt) but the text part works well enough.
>> Your use of the template is interesting - that gives it a bit of flexibility.
>> I'll mull that one over while I continue down the media (image) path.
>> Alpha is at ...
>> https://github.com/glennmckechnie/weewx-mastodon
>> On 21/12/2022, Chris Alemany  wrote:
>>> The snowy weather here on Vancouver Island has given me some unexpected
>>> time to work on this.  I now have a working template file and python script
>>> 
>>> that will produce and post weewx data to a Mastodon account.
>>> Just setup an account on your favourite Mastodon server,
>>> mark it as a bot,
>>> create an API/Client Key (under development in your account's preferences)
>>> install the template file to one of your skins (I just added it to the
>>> Standard skin.
>>> put the python file somewhere it can be run with cron
>>> run the python file with a command like this:
>>> 
>>> sudo python3  weewx_to_mastodon.py --server https://mstdn.ca --wxdata
>>> https://mywebpage.com/mastodon.json --api_key biglongstring234fssdf
>>> 
>>> I've attached my working files if anyone is itching to have it, excuse the
>>> messy code but it should be fairly self explanatory. You should only really
>>> 
>>> need to modify the values in the json.tmpl file.
>>> 
>>> On Sunday, December 18, 2022 at 3:40:31 PM UTC-8 Chris Alemany wrote:
>>> 
 Here is the promised link to the fellow who created a Python script from
 cumulus on Mac to Mastodon/ActivityPub:
 https://github.com/buffaloseven/CumulusMX-Customizations/tree/main/integrations
 
 Sent from my iPhone
 
 On Dec 15, 2022, at 6:24 AM, Chris Alemany  wrote:
 
 Hi all,
 
 
 
 Has anyone had a go at having weewx post to Mastodon/Fediverse, either to
 
 an existing @user@server or as an independent instance?
 
 There is at least one fellow who has written some Python to do it from his
 
 cumulus based system. I will share his GitHub project if someone thinks
 they can do it.
 
 Cheers
 Chris
 
 Sent from my iPhone
> 
> I've been posting to Mastodon for a while now and I've done it a bit 
> differently.
> 
> In skin.conf of what ever skin you are using (Seasons for me) I added:
>[[MastodonHourly]]
>encoding = strict_ascii
>template = mastodon.out.tmpl
> 
> mastodon.out.tmpl contains:
> Temp: $current.outTemp Humidity: $current.outHumidity\nPressure: 
> $current.barometer\nWind: $current.windDir.ordinal_compass, 
> $current.windSpeed (ave), $current.windGust (gust)\nRain Rate: 
> $current.rainRate Rain Total: $day.rain.sum\nSolar Radiation: 
> $current.radiation UV: $current.UV\nSoil Moisture: $current.soilMoist1
> 
> Lastly I have this python script run hourly from a Crontab using Mastodon.py 
> and I can upload an image from my webcam at the same time:
> 
> #!/usr/bin/env python3
> from mastodon import Mastodon
> from datetime import datetime
> 
> #   Set up Mastodon
> mastodon = Mastodon(
>access_token = '',
>api_base_url = ''
> )
> 
> photo_path = '/var/www/html/webcam.jpg'
> now = datetime.now()
> spoiler = 'Live weather for #Yeovil at ' + now.strftime('%d/%m/%y %H.00')
> 
> f = open('/var/www/html/weewx/mastodon.out','r')
> media = mastodon.media_post(photo_path)
> content = f.read()
> tweet = content.replace("\\n","\n")
> mastodon.status_post(tweet, media_ids=media, spoiler_text=spoiler)
> f.close()
> 
> -- 
> 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+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/weewx-user/f10a6d44-4c5a-dcd7-0104-46db15126088%40gmail.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/1A47A3FC-A12C-4094-8955-79215048B871%40gmail.com.