Automatic weather tweets

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

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

Post by mbliek »

Your welcome.
You can take a look at some other scripts with Python instead of bash.
User avatar
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

Post by elythomaslumber »

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 :D 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 :evil:
(/json.htm?type=command&param=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...
User avatar
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

Post by mbliek »

The python scripts using an other method. There was a script on the old forum. But that forum is not available anymore.
User avatar
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

Post by elythomaslumber »

I'm still working on a solution and feel like Edison "I know 1000 ways how it will not work." :lol:

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:
Invalid request parameters
This code does the problem I think:

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/")
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
schmm
Posts: 8
Joined: Monday 29 September 2014 21:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Weert (Netherlands)
Contact:

Re: Automatic weather tweets

Post by schmm »

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!
WpeterW
Posts: 4
Joined: Friday 05 December 2014 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Automatic weather tweets

Post by WpeterW »

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.
User avatar
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

Post by mbliek »

Sorry. Don't know why you have been banned. The comment is "cool down" don't know why?
WpeterW
Posts: 4
Joined: Friday 05 December 2014 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Automatic weather tweets

Post by WpeterW »

"Cool down" ? Who modded that ?
User avatar
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

Post by mbliek »

gizmocuz. You should ask him.
WpeterW
Posts: 4
Joined: Friday 05 December 2014 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Automatic weather tweets

Post by WpeterW »

I did. No response.
ironleg
Posts: 1
Joined: Monday 11 May 2015 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Automatic weather tweets

Post by ironleg »

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:

Code: Select all

tweet="hallo wereld"
when executing the script the posting to twitter seems to be ok:

Code: Select all

[+] Fetching twitter.com...
[+] Submitting the login form...
[+] Getting compose tweet page...
[+] Posting a new tweet: hallo wereld...
[+] Logging out...
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?
User avatar
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

Post by mbliek »

Twitter don't accept this type of login this script uses. It don't give any errors.
User avatar
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

Post by mvveelen »

Nice to see this :) And so close to where I love :mrgreen:
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
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

Post by Siewert308SW »

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.

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)

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

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
example: https://twitter.com/ZKWeerTweets
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
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests