Automatic weather tweets
Moderator: leecollings
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Automatic weather tweets
Your welcome.
You can take a look at some other scripts with Python instead of bash.
You can take a look at some other scripts with Python instead of bash.
Op zoek naar een Domoticz Start Set?
- elythomaslumber
- Posts: 56
- Joined: Friday 12 July 2013 13:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.1
- Location: Solingen; Germany
- Contact:
Re: Automatic weather tweets
Well, but finally I will end up on the same "locked" login-page I think...
Anyway this would be the only reason why I should use Twitter Therefore I was very fascinated by your idea!
Currently I'm working on a script which will:
1. send me a complete weather forecast from wunderground by email for the next 6h, 12h, 24h, 48h -> I tried to send to domoticz data-base but it chrashed and I will never it touch again
(/json.htm?type=command¶m=udevice&idx=10&nvalue=0&svalue=12.3;45;2")
2. and a little bit crazy...switch on a APPLamp (little lamp close to my TV) once a hour showing me temp, rain and wind forecast in the next 6 hours by different coloure and flash effects...
Anyway this would be the only reason why I should use Twitter Therefore I was very fascinated by your idea!
Currently I'm working on a script which will:
1. send me a complete weather forecast from wunderground by email for the next 6h, 12h, 24h, 48h -> I tried to send to domoticz data-base but it chrashed and I will never it touch again
(/json.htm?type=command¶m=udevice&idx=10&nvalue=0&svalue=12.3;45;2")
2. and a little bit crazy...switch on a APPLamp (little lamp close to my TV) once a hour showing me temp, rain and wind forecast in the next 6 hours by different coloure and flash effects...
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Automatic weather tweets
The python scripts using an other method. There was a script on the old forum. But that forum is not available anymore.
Op zoek naar een Domoticz Start Set?
- elythomaslumber
- Posts: 56
- Joined: Friday 12 July 2013 13:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.1
- Location: Solingen; Germany
- Contact:
Re: Automatic weather tweets
I'm still working on a solution and feel like Edison "I know 1000 ways how it will not work."
Currently I'm using the -v parameter in curl to show the complete handshake between Twitter and the script showing nothing negativ so far I can see. (By the way, meanwhile there is non more a CAPTCHA lock!)
Also I stored every variable in a text-file to see the data content.
Everything looks fine whis exception of the variable $update which contents:
The problem seems to be here: [display_coordinates].
Regards
Hardy
For those who read this forum the current status:
- using the bash scripts was finally not successful for me
- a PHP script is running very well
- the PHP script has to be started by a bash
- fully integration in a single script is under development
- current status can be seen here: https://twitter.com/SGforecast
Currently I'm using the -v parameter in curl to show the complete handshake between Twitter and the script showing nothing negativ so far I can see. (By the way, meanwhile there is non more a CAPTCHA lock!)
Also I stored every variable in a text-file to see the data content.
Everything looks fine whis exception of the variable $update which contents:
This code does the problem I think:Invalid request parameters
Code: Select all
update=$(curl -v -s -b "cookie.txt" -c "cookie.txt" -L --sslv3 -A "$uagent" -d "authenticity_token=$tweettoken&tweet[text]=$tweet&tweet[display_coordinates]=false" "https://mobile.twitter.com/")
Regards
Hardy
For those who read this forum the current status:
- using the bash scripts was finally not successful for me
- a PHP script is running very well
- the PHP script has to be started by a bash
- fully integration in a single script is under development
- current status can be seen here: https://twitter.com/SGforecast
-
- Posts: 8
- Joined: Monday 29 September 2014 21:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Weert (Netherlands)
- Contact:
Re: Automatic weather tweets
I had the last days continuously problems with tweeting with this script.
I did not receive any errors, but is didn't tweet anything.
I altered the script and i'm now using Twython to tweet. You only have to make an application account in twitter and with the api key's you are able to tweet on a easy way!
I did not receive any errors, but is didn't tweet anything.
I altered the script and i'm now using Twython to tweet. You only have to make an application account in twitter and with the api key's you are able to tweet on a easy way!
-
- Posts: 4
- Joined: Friday 05 December 2014 13:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Automatic weather tweets
Yesterday I posted a reply in this thread, just mentioning how I have achieved this using Python. I posted a link to my twitter-profile: http://twitter.com/hetweerinannen
After that my account and ip were banned. Can some mod explain me why ? I've read the forum-rules and I can't think of a rule I may have violated. Thanks.
Ps: the post on the old forum, referred to in this thread, was my contribution.
After that my account and ip were banned. Can some mod explain me why ? I've read the forum-rules and I can't think of a rule I may have violated. Thanks.
Ps: the post on the old forum, referred to in this thread, was my contribution.
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Automatic weather tweets
Sorry. Don't know why you have been banned. The comment is "cool down" don't know why?
Op zoek naar een Domoticz Start Set?
-
- Posts: 4
- Joined: Friday 05 December 2014 13:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Automatic weather tweets
"Cool down" ? Who modded that ?
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
-
- Posts: 4
- Joined: Friday 05 December 2014 13:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Automatic weather tweets
I did. No response.
-
- Posts: 1
- Joined: Monday 11 May 2015 14:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Automatic weather tweets
I've tried to have my domoticz installation send automatic weather tweets, but no luck so far.
To trouble shoot the problem i commented out the lines where the tweet variable is set, en changed is to:
when executing the script the posting to twitter seems to be ok:
But stil nothing is posted to my twitter account.
I've also looked at tweethon but i can't find any documentation to get this working.
Can someone help me further with this?
To trouble shoot the problem i commented out the lines where the tweet variable is set, en changed is to:
Code: Select all
tweet="hallo wereld"
Code: Select all
[+] Fetching twitter.com...
[+] Submitting the login form...
[+] Getting compose tweet page...
[+] Posting a new tweet: hallo wereld...
[+] Logging out...
I've also looked at tweethon but i can't find any documentation to get this working.
Can someone help me further with this?
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Automatic weather tweets
Twitter don't accept this type of login this script uses. It don't give any errors.
Op zoek naar een Domoticz Start Set?
- mvveelen
- Posts: 678
- Joined: Friday 31 October 2014 10:22
- Target OS: NAS (Synology & others)
- Domoticz version: Beta
- Location: Hoorn, The Netherlands
- Contact:
Re: Automatic weather tweets
Nice to see this And so close to where I love
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
- Siewert308SW
- Posts: 288
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: Automatic weather tweets
I know, old topic but wanted to share experience with this script.
Last night i wanted to be able to make my Raspi tweet our local weather, just for fun
Well seems twitter doesn't allow the method as describe here.
So i took a other approach which works flawless.
Maybe not the cleanest script but it works.
@1 i created a new app via https://apps.twitter.com/app/new
@2 i installed the following extra packages on my Rapsberry
sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install tweepy
@3 i create a new python script called weer.py
You need to fill the keys below as create @ https://apps.twitter.com/app/new
The weather-tweet.txt is a file where your future tweet is stored and this scripts needs it to tweet.
Also made this script executable.
@4 I created a bash script which is executable.
And made a cron for every hour. */60 * * * * sudo bash /home/pi/domoticz/scripts/bash/weer_tweet.sh
It scraps the data from my sensors in the garden but it will work with weatherunderground also.
Code below has the same idea as the script in this thread.
example: https://twitter.com/ZKWeerTweets
Last night i wanted to be able to make my Raspi tweet our local weather, just for fun
Well seems twitter doesn't allow the method as describe here.
So i took a other approach which works flawless.
Maybe not the cleanest script but it works.
@1 i created a new app via https://apps.twitter.com/app/new
@2 i installed the following extra packages on my Rapsberry
sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install tweepy
@3 i create a new python script called weer.py
You need to fill the keys below as create @ https://apps.twitter.com/app/new
The weather-tweet.txt is a file where your future tweet is stored and this scripts needs it to tweet.
Also made this script executable.
Code: Select all
#! /usr/bin/env python
import tweepy
from datetime import datetime
API_KEY = ' '
API_SECRET = ' '
ACCESS_TOKEN = ' '
ACCESS_TOKEN_SECRET = ' '
auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
tempfile = open("/mnt/usbstorage/tweets/weather-tweet.txt")
thetext = tempfile.read()
tempfile.close()
api.update_status(thetext)
And made a cron for every hour. */60 * * * * sudo bash /home/pi/domoticz/scripts/bash/weer_tweet.sh
It scraps the data from my sensors in the garden but it will work with weatherunderground also.
Code below has the same idea as the script in this thread.
Code: Select all
#!/bin/bash
thermo=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=37"`
echo $thermo > /mnt/usbstorage/tweets/weather-data.txt
temperature=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $17, $18}' | awk '{print $3}' | sed 's/\"//g'`
hygro=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=37"`
echo $hygro > /mnt/usbstorage/tweets/weather-data.txt
hygro=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $18, $19}' | awk '{print $3}' | sed 's/\"//g'`
rain=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=40"`
echo $rain > /mnt/usbstorage/tweets/weather-data.txt
rain=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $13, $14}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
wind=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=38"`
echo $wind > /mnt/usbstorage/tweets/weather-data.txt
dir=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $20, $21}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
speed=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $22, $23}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
chill=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $15, $16}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
baro=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=37"`
echo $baro > /mnt/usbstorage/tweets/weather-data.txt
baro=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $14, $15}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
zicht=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=41"`
echo $zicht > /mnt/usbstorage/tweets/weather-data.txt
zicht=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
uv=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=39"`
echo $uv > /mnt/usbstorage/tweets/weather-data.txt
uv=`cat /mnt/usbstorage/tweets/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/\"//g' | sed 's/,//g'`
echo -ne "#Zoutkamp\nTemp: $temperature C\nWindchill: $chill C\nLuchtvochtigheid: $hygro %\nNeerslag: $rain mm\nWind: $dir / $speed km/h\nBaro: $baro hPa\nZicht: $zicht km\nUV: $uv" > /mnt/usbstorage/tweets/weather-tweet.txt
sudo python /home/pi/domoticz/scripts/python/weer.py
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
Who is online
Users browsing this forum: No registered users and 0 guests