SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
Outsmarting your
Smart Meter
UtrechtJUG // October 27, 2017
Maarten Mulders
Maarten Mulders
@mthmulders
architect | lead software engineer | trainer | speaker
 
What's Up?
Background
Connecting the Smart Meter
Building a Dashboard
Questions
 
 
 
Connecting the Smart Meter
Pin # Signal name Description
1 +5 V Power supply
2 Request Input
3 Data GND Ground
4 not connected
5 Data Output
6 Power GND Power supply
Reading data
eBay shopping list
1. RJ11-to USB female
2. USB male-to-male
Total: $ 4.08 (€ 3.50) incl. shipping
Reading data
$ cu -l /dev/ttyUSB0 -s 115200 --parity=none
Connected.
/KFM5KAIFA-METER
1-3:0.2.8(42)
0-0:1.0.0(160416112854S)
...
...
!4016
~.
Disconnected.
Interpreting data
identi cation: vendor-speci c, not speci ed
data:
CRC16-checksum over / to !
/???5<identification>
<data> (repeated)
!<CRC>
OBIS-reference(value)
Parsing data
This is easily parsed with Scala's parser combinators
 
Input:
Parser:
000635.311
def number = """d*.?d*""".r ^^ { BigDecimal(_) }
Parsing data (ctd)
This is easily parsed with Scala's parser combinators
 
Input:
Parser:
1-0:1.8.1(000635.311*kWh)
def elecCons1 = "1-0:1.8.1(" ~>
"""d*.?d*""".r <~ "*kWh)" ^^ { BigDecimal(_) }
Parsing data (ctd)
This is easily parsed with Scala's parser combinators
def make = "/" ~> "[A-Za-z0-9]{3}".r ^^ { String(_) }
def identification = "5" ~> ".*".r ^^ { String(_) }
def header = make ~ identification ^^ {
case make ~ identification => P1Header(make, identification)
}
Parsing data (ctd)
This is easily parsed with Scala's parser combinators
private def telegram = header ~ metadata ~ data ~ checksum
private def parser: Parser[P1Telegram] = telegram ^^ {
case header ~ metadata ~ data ~ checksum =>
P1Telegram(header, metadata, data, checksum)
} | failure("Not all required lines are found")
Architecture
Smart Meter
Hyperion
     raw
     data
Database
     historical      
     records      
Client (web)
     live data &
      historical record
Hyperion (1)
 Collecting Actor          #append(...)
P1 Parser
    #parseTelegram()       
   Message Distributor    
      TelegramReceived
(telegram)
IO(Serial)
      Serial.Received
(bytes)
Hyperion (2)
   Client (Browser)   
 Http  
      HTTP & WebSockets
    RecentHistoryActor    
          GetRecentHistory               
RecentReadings   
     ActualValuesHandlerActor      
(Akka Streams)
   DailyHistoryActor    
        RetrieveMeterReading     
      RetrievedMeterReading
        StateTimeout
    Message Distributor    
      RegisterReceiver        
TelegramReceived    
(telegram)   
          RegisterReceiver     
   TelegramReceived
(telegram)
          RegisterReceiver     
TelegramReceived
(telegram)
Web Dashboard
Separate ui and data
Single page app
Small components (UI and logic)
ES6 classes
class CurrentReadingsService {
constructor() {
const hostname = config.apiLocation();
this.base_url = `wss://${hostname}/api/actual`;
}
connect(cb) {
this.ws = new WebSocket(this.base_url);
this.ws.onmessage = (message) => cb(JSON.parse(message.data));
}
disconnect() {
this.ws.close();
}
}
export default new CurrentReadingsService();
React Components (1)
class CurrentReadingsPage extends React.Component {
componentDidMount() {
currentReadingsService.connect((data) => {
this.setState({
currentReading: data,
});
});
}
componentWillUnmount() {
currentReadingsService.disconnect();
}
// continued...
}
React Components (2)
class CurrentReadingsPage extends React.Component {
// continued...
render() {
const makeRow = (label, value) => (<Row>
<Col lg={ 6 }><strong>{ label }</strong></Col>
<Col lg={ 6 }>{ value }</Col>
</Row>);
return (<Grid>
{ makeRow("Last updated",
formattingService.formatDateFull(ts)) }
{ makeRow("Electricity consumption",
formattingService.formatNumberPower(consumption)) }
{ makeRow("Electricity production",
formattingService.formatNumberPower(production)) }
{ gas ? makeRow("Gas meter",
formattingService.formatNumberGas(gas)) : null }
{ makeRow("Current tariff", tariff) }
</Grid>);
}
}
 
What's Going On? (1)
What's Going On? (1)
What's Going On? (2)
What's Going On? (2)
Questions?

Más contenido relacionado

Más de Maarten Mulders

React in 40 minutes (JCON)
React in 40 minutes (JCON) React in 40 minutes (JCON)
React in 40 minutes (JCON) Maarten Mulders
 
React in 50 minutes (Bucharest Software Craftsmanship Community)
React in 50 minutes (Bucharest Software Craftsmanship Community)React in 50 minutes (Bucharest Software Craftsmanship Community)
React in 50 minutes (Bucharest Software Craftsmanship Community)Maarten Mulders
 
React in 50 Minutes (JNation)
 React in 50 Minutes (JNation)  React in 50 Minutes (JNation)
React in 50 Minutes (JNation) Maarten Mulders
 
SSL/TLS for Mortals (JavaLand)
SSL/TLS for Mortals (JavaLand) SSL/TLS for Mortals (JavaLand)
SSL/TLS for Mortals (JavaLand) Maarten Mulders
 
Making Maven Marvellous (J-Fall)
Making Maven Marvellous (J-Fall)Making Maven Marvellous (J-Fall)
Making Maven Marvellous (J-Fall)Maarten Mulders
 
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)Maarten Mulders
 
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)Maarten Mulders
 
SSL/TLS for Mortals (UtrechtJUG)
SSL/TLS for Mortals (UtrechtJUG)SSL/TLS for Mortals (UtrechtJUG)
SSL/TLS for Mortals (UtrechtJUG)Maarten Mulders
 
Building a DSL with GraalVM (javaBin online)
Building a DSL with GraalVM (javaBin online)Building a DSL with GraalVM (javaBin online)
Building a DSL with GraalVM (javaBin online)Maarten Mulders
 
SSL/TLS for Mortals (Lockdown Lecture)
SSL/TLS for Mortals (Lockdown Lecture)SSL/TLS for Mortals (Lockdown Lecture)
SSL/TLS for Mortals (Lockdown Lecture)Maarten Mulders
 
React in 50 Minutes (OpenValue)
React in 50 Minutes (OpenValue) React in 50 Minutes (OpenValue)
React in 50 Minutes (OpenValue) Maarten Mulders
 
React in 50 Minutes (DevNexus)
React in 50 Minutes (DevNexus) React in 50 Minutes (DevNexus)
React in 50 Minutes (DevNexus) Maarten Mulders
 
React in 45 Minutes (Jfokus)
React in 45 Minutes (Jfokus)React in 45 Minutes (Jfokus)
React in 45 Minutes (Jfokus)Maarten Mulders
 
Building web applications with React (Jfokus)
Building web applications with React (Jfokus)Building web applications with React (Jfokus)
Building web applications with React (Jfokus)Maarten Mulders
 
SSL/TLS for Mortals (Devoxx)
 SSL/TLS for Mortals (Devoxx) SSL/TLS for Mortals (Devoxx)
SSL/TLS for Mortals (Devoxx)Maarten Mulders
 
Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Maarten Mulders
 
Building a DSL with GraalVM (Full Stack Antwerpen)
Building a DSL with GraalVM (Full Stack Antwerpen)Building a DSL with GraalVM (Full Stack Antwerpen)
Building a DSL with GraalVM (Full Stack Antwerpen)Maarten Mulders
 
Building a DSL with GraalVM (Devoxx PL)
Building a DSL with GraalVM (Devoxx PL) Building a DSL with GraalVM (Devoxx PL)
Building a DSL with GraalVM (Devoxx PL) Maarten Mulders
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Maarten Mulders
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Maarten Mulders
 

Más de Maarten Mulders (20)

React in 40 minutes (JCON)
React in 40 minutes (JCON) React in 40 minutes (JCON)
React in 40 minutes (JCON)
 
React in 50 minutes (Bucharest Software Craftsmanship Community)
React in 50 minutes (Bucharest Software Craftsmanship Community)React in 50 minutes (Bucharest Software Craftsmanship Community)
React in 50 minutes (Bucharest Software Craftsmanship Community)
 
React in 50 Minutes (JNation)
 React in 50 Minutes (JNation)  React in 50 Minutes (JNation)
React in 50 Minutes (JNation)
 
SSL/TLS for Mortals (JavaLand)
SSL/TLS for Mortals (JavaLand) SSL/TLS for Mortals (JavaLand)
SSL/TLS for Mortals (JavaLand)
 
Making Maven Marvellous (J-Fall)
Making Maven Marvellous (J-Fall)Making Maven Marvellous (J-Fall)
Making Maven Marvellous (J-Fall)
 
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)
 
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)
 
SSL/TLS for Mortals (UtrechtJUG)
SSL/TLS for Mortals (UtrechtJUG)SSL/TLS for Mortals (UtrechtJUG)
SSL/TLS for Mortals (UtrechtJUG)
 
Building a DSL with GraalVM (javaBin online)
Building a DSL with GraalVM (javaBin online)Building a DSL with GraalVM (javaBin online)
Building a DSL with GraalVM (javaBin online)
 
SSL/TLS for Mortals (Lockdown Lecture)
SSL/TLS for Mortals (Lockdown Lecture)SSL/TLS for Mortals (Lockdown Lecture)
SSL/TLS for Mortals (Lockdown Lecture)
 
React in 50 Minutes (OpenValue)
React in 50 Minutes (OpenValue) React in 50 Minutes (OpenValue)
React in 50 Minutes (OpenValue)
 
React in 50 Minutes (DevNexus)
React in 50 Minutes (DevNexus) React in 50 Minutes (DevNexus)
React in 50 Minutes (DevNexus)
 
React in 45 Minutes (Jfokus)
React in 45 Minutes (Jfokus)React in 45 Minutes (Jfokus)
React in 45 Minutes (Jfokus)
 
Building web applications with React (Jfokus)
Building web applications with React (Jfokus)Building web applications with React (Jfokus)
Building web applications with React (Jfokus)
 
SSL/TLS for Mortals (Devoxx)
 SSL/TLS for Mortals (Devoxx) SSL/TLS for Mortals (Devoxx)
SSL/TLS for Mortals (Devoxx)
 
Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)
 
Building a DSL with GraalVM (Full Stack Antwerpen)
Building a DSL with GraalVM (Full Stack Antwerpen)Building a DSL with GraalVM (Full Stack Antwerpen)
Building a DSL with GraalVM (Full Stack Antwerpen)
 
Building a DSL with GraalVM (Devoxx PL)
Building a DSL with GraalVM (Devoxx PL) Building a DSL with GraalVM (Devoxx PL)
Building a DSL with GraalVM (Devoxx PL)
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)
 

Último

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 

Último (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 

Outsmarting the smart meter (UtrechtJUG)

  • 1. Outsmarting your Smart Meter UtrechtJUG // October 27, 2017 Maarten Mulders
  • 2. Maarten Mulders @mthmulders architect | lead software engineer | trainer | speaker  
  • 3. What's Up? Background Connecting the Smart Meter Building a Dashboard Questions
  • 4.  
  • 5.  
  • 6.   Connecting the Smart Meter Pin # Signal name Description 1 +5 V Power supply 2 Request Input 3 Data GND Ground 4 not connected 5 Data Output 6 Power GND Power supply
  • 7. Reading data eBay shopping list 1. RJ11-to USB female 2. USB male-to-male Total: $ 4.08 (€ 3.50) incl. shipping
  • 8. Reading data $ cu -l /dev/ttyUSB0 -s 115200 --parity=none Connected. /KFM5KAIFA-METER 1-3:0.2.8(42) 0-0:1.0.0(160416112854S) ... ... !4016 ~. Disconnected.
  • 9. Interpreting data identi cation: vendor-speci c, not speci ed data: CRC16-checksum over / to ! /???5<identification> <data> (repeated) !<CRC> OBIS-reference(value)
  • 10. Parsing data This is easily parsed with Scala's parser combinators   Input: Parser: 000635.311 def number = """d*.?d*""".r ^^ { BigDecimal(_) }
  • 11. Parsing data (ctd) This is easily parsed with Scala's parser combinators   Input: Parser: 1-0:1.8.1(000635.311*kWh) def elecCons1 = "1-0:1.8.1(" ~> """d*.?d*""".r <~ "*kWh)" ^^ { BigDecimal(_) }
  • 12. Parsing data (ctd) This is easily parsed with Scala's parser combinators def make = "/" ~> "[A-Za-z0-9]{3}".r ^^ { String(_) } def identification = "5" ~> ".*".r ^^ { String(_) } def header = make ~ identification ^^ { case make ~ identification => P1Header(make, identification) }
  • 13. Parsing data (ctd) This is easily parsed with Scala's parser combinators private def telegram = header ~ metadata ~ data ~ checksum private def parser: Parser[P1Telegram] = telegram ^^ { case header ~ metadata ~ data ~ checksum => P1Telegram(header, metadata, data, checksum) } | failure("Not all required lines are found")
  • 15. Hyperion (1)  Collecting Actor          #append(...) P1 Parser     #parseTelegram()           Message Distributor           TelegramReceived (telegram) IO(Serial)       Serial.Received (bytes)
  • 16. Hyperion (2)    Client (Browser)     Http         HTTP & WebSockets     RecentHistoryActor               GetRecentHistory                RecentReadings         ActualValuesHandlerActor       (Akka Streams)    DailyHistoryActor             RetrieveMeterReading            RetrievedMeterReading         StateTimeout     Message Distributor           RegisterReceiver         TelegramReceived     (telegram)              RegisterReceiver         TelegramReceived (telegram)           RegisterReceiver      TelegramReceived (telegram)
  • 17. Web Dashboard Separate ui and data Single page app Small components (UI and logic)
  • 18. ES6 classes class CurrentReadingsService { constructor() { const hostname = config.apiLocation(); this.base_url = `wss://${hostname}/api/actual`; } connect(cb) { this.ws = new WebSocket(this.base_url); this.ws.onmessage = (message) => cb(JSON.parse(message.data)); } disconnect() { this.ws.close(); } } export default new CurrentReadingsService();
  • 19. React Components (1) class CurrentReadingsPage extends React.Component { componentDidMount() { currentReadingsService.connect((data) => { this.setState({ currentReading: data, }); }); } componentWillUnmount() { currentReadingsService.disconnect(); } // continued... }
  • 20. React Components (2) class CurrentReadingsPage extends React.Component { // continued... render() { const makeRow = (label, value) => (<Row> <Col lg={ 6 }><strong>{ label }</strong></Col> <Col lg={ 6 }>{ value }</Col> </Row>); return (<Grid> { makeRow("Last updated", formattingService.formatDateFull(ts)) } { makeRow("Electricity consumption", formattingService.formatNumberPower(consumption)) } { makeRow("Electricity production", formattingService.formatNumberPower(production)) } { gas ? makeRow("Gas meter", formattingService.formatNumberGas(gas)) : null } { makeRow("Current tariff", tariff) } </Grid>); } }
  • 21.