-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (23 loc) · 839 Bytes
/
main.py
File metadata and controls
31 lines (23 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from OctopusAgile import Agile
from phue import Bridge
import settings
def main():
bridge = Bridge(settings.bridge_ip_address)
bridge.connect()
bridge.get_api()
# https://en.wikipedia.org/wiki/Distribution_network_operator
agile = Agile(settings.region_code)
current_rate = agile.get_current_rate()
print(current_rate)
# Below threshold
if current_rate < settings.price_threshold_pence:
bridge.set_light(settings.threshold_price_hue_plug_name, "on", True)
else:
bridge.set_light(settings.threshold_price_hue_plug_name, "on", False)
# Plunge pricing
if current_rate < 0:
bridge.set_light(settings.plunge_price_hue_plug_name, "on", True)
else:
bridge.set_light(settings.plunge_price_hue_plug_name, "on", False)
if __name__ == "__main__":
main()