Skip to content

Instantly share code, notes, and snippets.

@naotaco
Created March 25, 2015 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naotaco/7f50a04c896d1ff7d372 to your computer and use it in GitHub Desktop.
Save naotaco/7f50a04c896d1ff7d372 to your computer and use it in GitHub Desktop.
set target temperature to Redis
#!/usr/bin/python3
import redis
import sys
argvs = sys.argv
if (len(argvs) < 2):
print ("specify target temerature for first argument.")
sys.exit(1)
r = redis.Redis(host='127.0.0.1', port=6379, db=0)
# check argument
try:
tmp = float(argvs[1])
except ValueError:
print ("Invalid argument. specify float value.")
sys.exit(1)
if (r.set('cooker_target_temperature', argvs[1])):
print ("succeed.")
else:
print ("failed to set value")
print (b"current setpoint: " + r.get('cooker_target_temperature'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment