forked from davewinwood/octolux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoctolux.rb
executable file
·30 lines (22 loc) · 1019 Bytes
/
octolux.rb
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
#! /usr/bin/env ruby
# frozen_string_literal: true
require_relative 'boot'
octopus = Octopus.new(product_code: CONFIG['octopus']['product_code'],
tariff_code: CONFIG['octopus']['tariff_code'])
# if we have less than 6 hours of future $octopus tariff data, update it
octopus.update if octopus.stale?
unless octopus.price
LOGGER.fatal 'No current Octopus price, aborting'
exit 255
end
# rubocop:disable Lint/UselessAssignment
# FIXME: duplicated in mq.rb, could move to boot.rb?
lc = LuxController.new(host: CONFIG['lxp']['host'],
port: CONFIG['lxp']['port'],
serial: CONFIG['lxp']['serial'],
datalog: CONFIG['lxp']['datalog'])
ls = LuxStatus.new(host: CONFIG['server']['connect_host'] || CONFIG['server']['host'],
port: CONFIG['server']['port'])
# rubocop:enable Lint/UselessAssignment
raise('rules.rb not found!') unless File.readable?('rules.rb')
instance_eval(File.read('rules.rb'), 'rules.rb')