Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from lcd_display import lcd
- from time import sleep
- import RPi_I2C_driver
- from time import *
- mylcd = RPi_I2C_driver.lcd()
- import subprocess
- import os
- import time
- import unicodedata
- import urllib, json
- import datetime
- # Configuration
- cfgDomoticzHost = "192.168.0.116:8080"
- cfgSpeed = 3
- TotalScreens = 2
- def get_domoticz_sensor(idx):
- url = "http://"+str(cfgDomoticzHost)+"/json.htm?type=devices&rid="+str(idx)
- response = urllib.urlopen(url);
- data = json.loads(response.read())
- if data["status"] == "OK":
- return data["result"][0]
- def get_domoticz_info(result):
- url = "http://"+str(cfgDomoticzHost)+"/json.htm?type=command¶m=checkforupdate&forced=true"
- response = urllib.urlopen(url);
- data = json.loads(response.read())
- if data["status"] == "OK":
- return data[result]
- ch = unichr(0xFF)
- deg = " C"
- # Create screens
- def screen_home():
- now = datetime.datetime.now()
- lcd.clear
- lcd.display_string(str(now.strftime("%d-%m-%Y")),1)
- lcd.display_string(str(now.strftime("%H:%M")),2)
- #i=0
- #bar=''
- #for i in range(0,20):
- # bar=bar+unichr(255)
- # lcd.display_string_l(bar,2)
- # i += 1
- #
- # geo = get_domoticz_sensor(65)["Status"]
- # if geo == "On":
- # status = "home"
- # else:
- # status = "away"
- #
- # lcd.display_string("Mike is " + status,3)
- def screen_system():
- lcd.clear
- lcd.display_string_l("Akwarium Pokoj", 1)
- lcd.display_string_l(get_domoticz_sensor(1)["Data"] + " " + get_domoticz_sensor(2)["Data"],2)
- #lcd.display_string_l("Memory : " + get_domoticz_sensor(1)["Data"],3)
- #lcd.display_string_l("Temp : " + get_domoticz_sensor(4)["Data"],4)
- def screen_energy():
- lcd.clear
- lcd.display_string_l(" Na zewnatrz ", 1)
- lcd.display_string_l(" " + get_domoticz_sensor(11)["Data"],2)
- #lcd.display_string_l("Today : " + get_domoticz_sensor(9)["CounterToday"],3)
- #lcd.display_string_l("" ,4)
- def screen_weather():
- lcd.clear
- lcd.display_string_l(unichr(255)+" Weather "+(ch*10), 1)
- lcd.display_string_l("Temp : " + str(get_domoticz_sensor(1)["Temp"]) + deg,2)
- lcd.display_string_l("Humid : " + str(get_domoticz_sensor(119)["Humidity"]) + " %", 3)
- lcd.display_string_l("Baro : " + str(get_domoticz_sensor(119)["Barometer"]) + " mb",4)
- def screen_temps():
- lcd.clear
- lcd.display_string_l(unichr(255)+" Temps "+(ch*12), 1)
- lcd.display_string_l("Lounge : " + str(get_domoticz_sensor(53)["Temp"]) + deg,2)
- lcd.display_string_l("Hive : " + str(get_domoticz_sensor(30)["Temp"]) + deg,3)
- lcd.display_string_l("Target : " + str(get_domoticz_sensor(31)["Temp"]) + deg,4)
- def screen_lights():
- lcd.clear
- lcd.display_string_l(unichr(255)+" Lights "+(ch*11), 1)
- lcd.display_string_l("Inside : " + str(get_domoticz_sensor(15)["Status"]),2)
- lcd.display_string_l("Outside : " + str(get_domoticz_sensor(13)["Status"]),3)
- lcd.display_string_l("",4)
- # Determine order of the screens
- screens = {
- 0 : screen_home,
- 1 : screen_system,
- 2 : screen_energy,
- 3 : screen_weather,
- 4 : screen_temps,
- 5 : screen_lights,
- }
- # Start LCD
- lcd = lcd()
- # Display screens
- i=0
- while 1:
- try:
- screens[i]()
- except:
- pass
- sleep(cfgSpeed)
- i += 1
- if i == TotalScreens+1:
- i=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement