Category Archives: raspberry pi

streaming from a raspberry-pi picamera to homeassistant

rpi

raspivid -rot 180 -t 0 -n --width 640 --height 480 -o - | cvlc stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264

home assistant

camera:
 - platform: ffmpeg
   input: http://192.168.0.145:8090

You will need to install vlc-nox in the rpi, in single cpu version it really slow, do it before you go to sleep.

ssh allow all users from lan, restrict users from wan

Raspberry pi used as ssh server at home.
DMZ enabled to it’s IP.


file: /etc/ssh/sshd_config

AllowUsers *@192.168.0.* johndoe

This directive will allow only johndoe to connect via ssh unless the connection attempt comes from the same network, in which case alice will be able to connect, too. If alice tries to connect from the DMZ, it won’t work.

Un petit script python qui m’envoie des mails quand le RER est malade

Un petit script tout moche python qui m’envoie des mails quand le RER est malade, lancé avec une crontab aux horaires qui m’intéressent, et voilà!

#!/usr/bin/python
# -*- coding: utf-8 -*-

import time
now = time.ctime()


# RATP API part
## c'est la partie magique, merci Pierre!
import requests
r = requests.get("http://api-ratp.pierre-grimaud.fr/data/trafic/rer")
data = r.text
print(data)

import json
parsed_json = json.loads(data)
if parsed_json["trafic"] == "perturbation":
  print(parsed_json["perturbations"])
  mailbody = parsed_json["perturbations"]

  ## mail part
  import subprocess
  import smtplib
  import email.utils
  from email.mime.text import MIMEText

  recipients = "qqn@mail.com,joe@example.net"
  # Create the message
  msg = MIMEText(str(mailbody))
  msg['To'] = recipients
  msg['From'] = "noreply-rapt@whateversnmpworkshere.fr"
  msg['Subject'] = "RERB status -- " + now

  server = smtplib.SMTP('smtp.example.net')
  log = server.set_debuglevel(True) # show communication with the server
  try:
      server.sendmail(msg["From"], msg["To"].split(","), msg.as_string())
  finally:
      server.quit()
  #print(log)

automating #Twitter with #raspberrypi

I’ve been tweeting pictures and re-tweeting twits automatically for a few years now using two python tools.

  1. Twython
  2. on github
    Here’s an example script for Twython

  3. TwitterFollowBot
  4. on github
    Here’s an example script for TwitterFollowBot

Both require to have an already created Twitter app (https://apps.twitter.com/) and a little bit of python.