Our server pr0vider carried out maintenance on 15 January 2020 but it corrupted some files in the process. If you notice anything out of the ordinary (partial files, pages not loading, that kind of shit) then let us know at:

Pyth0n implementation ov reading ein DS18B20 temperature sens0r

Wazakindjes a02b1930d3 Ayy finally a full v2.0 release xd Settled on using OneSignal as a push service pr0viturd for weather notifications (including support for specific notification channel and player segment), also added ./temps.py --weathermon flag to force run that shit and some other misc impr0vements [=[=[=[=[=[[=[=[=[= 2 months ago
.gitignore aeda07e1a3 Added: weather API shit for monitoring the outside temperature vs inside and send a push notification if the "state" changed || Changed: muhconf global var to contain dicts per config section instead of 1 dict w/ everything, all optional config vars should be specified as a string, changed config checking ifs to a style more suited for checking individual val00s, check if sensor path actually exists during config check instead of simply handling the exception on read, check for string values (such as MySQL h0st) being zero-length, sorta standardised error message formats and some other v min0r fixes/optimisations ;]];];;];];];];];]];;]];]; 2 months ago
README.md a02b1930d3 Ayy finally a full v2.0 release xd Settled on using OneSignal as a push service pr0viturd for weather notifications (including support for specific notification channel and player segment), also added ./temps.py --weathermon flag to force run that shit and some other misc impr0vements [=[=[=[=[=[[=[=[=[= 2 months ago
muhconf.ini.example a02b1930d3 Ayy finally a full v2.0 release xd Settled on using OneSignal as a push service pr0viturd for weather notifications (including support for specific notification channel and player segment), also added ./temps.py --weathermon flag to force run that shit and some other misc impr0vements [=[=[=[=[=[[=[=[=[= 2 months ago
temps.py a02b1930d3 Ayy finally a full v2.0 release xd Settled on using OneSignal as a push service pr0viturd for weather notifications (including support for specific notification channel and player segment), also added ./temps.py --weathermon flag to force run that shit and some other misc impr0vements [=[=[=[=[=[[=[=[=[= 2 months ago

README.md

The fuck is this

This shit is a qt lil Pyth0n implementation ov reading ein DS18B20 temperature sens0r, the values of which get stored in a MySQL/MariaDB database somewhere. =]]]

It will run 5 samples (with a required 1 second delay between em) and get the average of that to store in the DB. It also supports multiple sensors but it will only store the first average. xd

Dependencies

You prolly need to install a few Pythinz modules cuz they may not be available by default. I'll just list everything in use:

  • argparse
  • ConfigParser
  • datetime
  • json
  • MySQLdb
  • onesignal
  • os
  • requests
  • sys
  • time
  • var_dump (for printing object properties etc ;])

Installation

Copy muhconf.ini.example to muhconf.ini and fire up een editor. All the options are self-explanatory or explained in there so git to reading fam. The config file must be kept in the same dir as the skrip.

Then simply slam a new entry in your crontab to make it run periodically (the skrip is set up to read/store once, then quit). You should be able to run it as any non-root user, since the sysfs path belonging to the sensor data (e.g. /sys/bus/w1/devices/28-02155265b0ff/w1_slave) should be world-readable. My cr0n looks leik dis:
*/2 * * * * kill -9 $(ps aux | grep '[p]ython.*temps.py' | grep -v '/bin/sh' | awk '{ print $2 }') >/dev/null 2>&1 ; /usr/bin/python /home/hecks/temp_sensor/temps.py

As you can see I have it set to run every 2 minutes, faster is not really necessary and would only clutter the DB. The kill part is in case a previous instance is hanging on something for some reason, and should usually fail (hence the redirections to /dev/null ;]). To me this only really happens when my internetz connection is being gay and takes 2+ minutes to set up a usable MySQL connection. This logic is not present in the code itself because of the "set up to read/store once, then quit" reasoning. ;];];];] It would be p hard to account for anyways, since the TCP handshake has been completed and there are packets flowing, just many get dropped and have to be resent.

ez pz ;]

Usage

You can just simply run ./temps.py obviously, but in case you need to troubleshoot something you can use ./temps.py --debug to force debug mode without having to touch the config. [=[=[[=[==[=[=[

Or just do ./temps.py -h and check the built-in halp for more inf0z. ;]

Weathermon

So this thing also supports sending a notification when the outside temperature gets below the indoor one. I maed dis cuz I have an underpowered AC unit and if the outdoors temp is lower I can open el windows to make it cool off faster inside. =]] This also allows the air pressure to equalise again. The same is true for the other way around; when the outside temperature gets higher I should closem wind0ze, so it will also notify about that.

Weather API

For checkin' em outdoors temperature I'm using an API from OpenWeatherMap, which as of writing this shit is free for 60 calls/minute up to 1 million/month. Should be more than enough. =]

  • Sign up through the pricing page
  • Generate an API key
  • Figure out your city ID by using one of the API URLs for searching by name, mentioned in the API docs (simply open the full URL in your browser and look for a top-level id variable)
  • Go to the weathermon section in the config file and update the enable, weather_key and city_id fields
  • Possibly update the weather_url too, if there's a newer version of the API (it may not work with our skrip though)

OWP supports Celsius, Fahrenheit and Kelvin as temperature units, but the sensor always uses Celsius afaik so we'll force OWP to work with that too, deal w/ it. ;]

Notification shit

Now, in order to actually receive the notifications I made a qt lil Andr0id app to receive push notifications from multiple sources. =] Just refer to that shit to read how to set em up and make the necessary config changes for temps.py. ;];];];]