This commit is contained in:
Aart van Halteren
2022-01-09 18:59:35 +01:00
4 changed files with 8 additions and 5 deletions

View File

@@ -97,7 +97,7 @@ class InSyncState < StatePattern::State
# Write to EmonHub # Write to EmonHub
begin begin
TCPSocket.open("10.0.0.154",5050){|s| TCPSocket.open("printserver.home.local",5050){|s|
s.write(sprintf("8 %d %d\r\n", reading.current_kw_consumed*1000, reading.current_kw_produced*1000)) s.write(sprintf("8 %d %d\r\n", reading.current_kw_consumed*1000, reading.current_kw_produced*1000))
} }
rescue rescue

View File

@@ -1,7 +1,8 @@
#require 'rubygems' #require 'rubygems'
require 'daemons' require 'daemons'
pwd = Dir.pwd #pwd = Dir.pwd
pwd = '/home/pcog/smartmeter'
Daemons.run_proc('smartmeter', {:dir_mode => :normal, :dir => pwd+"/pids"}) do Daemons.run_proc('smartmeter', {:dir_mode => :normal, :dir => pwd+"/pids"}) do
Dir.chdir(pwd) Dir.chdir(pwd)
exec "ruby smartmeter.rb" exec "ruby smartmeter.rb"

View File

@@ -3,7 +3,9 @@ services:
db: db:
container_name: smartmeter_db container_name: smartmeter_db
restart: unless-stopped restart: unless-stopped
image: mysql image: mysql
volumes:
- /home/pcog/smartmeter/data:/var/lib/mysql
environment: environment:
MYSQL_ROOT_PASSWORD: rootme MYSQL_ROOT_PASSWORD: rootme
MYSQL_DATABASE: smartmeter MYSQL_DATABASE: smartmeter
@@ -13,7 +15,7 @@ services:
build: . build: .
command: 'ruby ./smartmeter.rb' command: 'ruby ./smartmeter.rb'
devices: devices:
- "/dev/ttyUSB0:/dev/ttyUSB0" - "/dev/ttyUSB1:/dev/ttyUSB0"
volumes: volumes:
- .:/usr/src/app - .:/usr/src/app
depends_on: depends_on:

View File

@@ -17,7 +17,7 @@ ActiveRecord::Base.establish_connection(connection_details)
if __FILE__ == $0 if __FILE__ == $0
#params for serial port #params for serial port
port_str = "/dev/ttyUSB0" #may be different for you port_str = "/dev/ttyUSB1" #may be different for you
baud_rate = 9600 baud_rate = 9600
data_bits = 7 data_bits = 7
stop_bits = 1 stop_bits = 1