New gas reading logic
This commit is contained in:
@@ -47,9 +47,8 @@ class InSyncState < StatePattern::State
|
|||||||
end
|
end
|
||||||
|
|
||||||
def handle_frame(frame_lines)
|
def handle_frame(frame_lines)
|
||||||
# gas flag
|
gas_pattern = /^([0-1:24\.2\.1]+)\((\d{12}[SW])\)\((\d{5}\.\d{3})\*m3\)$/
|
||||||
next_is_gas = false
|
|
||||||
|
|
||||||
# prepare DB record
|
# prepare DB record
|
||||||
last_reading = Reading.last
|
last_reading = Reading.last
|
||||||
reading = Reading.new
|
reading = Reading.new
|
||||||
@@ -80,13 +79,10 @@ class InSyncState < StatePattern::State
|
|||||||
end
|
end
|
||||||
if line.match(/0-0:96.14.0/) # Hoog/laag tarief
|
if line.match(/0-0:96.14.0/) # Hoog/laag tarief
|
||||||
reading.high_tarif = line.split(/0-0:96.14.0\(|\)/).join.eql?("0002")
|
reading.high_tarif = line.split(/0-0:96.14.0\(|\)/).join.eql?("0002")
|
||||||
end
|
end
|
||||||
if next_is_gas && line.match(/\(/)
|
if match = line.match(/0-1:24.3.0/) # Gas verbruik (1x per uur een nieuwe stand)
|
||||||
next_is_gas = false
|
p "Gas reading: #{match[1]} (#{match[2]})"
|
||||||
reading.total_m3_gas_consumed = line.split(/\(|\)/).join.to_f
|
reading.total_m3_gas_consumed = match[3].to_f
|
||||||
end
|
|
||||||
if line.match(/0-1:24.3.0/) # Gas verbruik (1x per uur een nieuwe stand)
|
|
||||||
next_is_gas = true # the usage is on the next line
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user