done hw14 part 1
This commit is contained in:
parent
dbbb30e30f
commit
93b766edc0
1 changed files with 258 additions and 1 deletions
|
@ -1943,4 +1943,261 @@ Good: 1, two out of 2-5.
|
||||||
|
|
||||||
Exceed: 1-5.
|
Exceed: 1-5.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1. As a user case scenario, I choose to require supporting the Amazon Alexa voice assistant to allow its users to alter smart device states by voice command. To achieve this functionality, I define new logical, process and deployment view to show how the Alexa API is integrated in the architecture.
|
||||||
|
|
||||||
|
## Logical View
|
||||||
|
|
||||||
|
```puml
|
||||||
|
@startuml
|
||||||
|
skinparam componentStyle rectangle
|
||||||
|
|
||||||
|
!include <tupadr3/font-awesome/database>
|
||||||
|
|
||||||
|
title Smarthut.sm Logical View
|
||||||
|
|
||||||
|
interface " " as DIF
|
||||||
|
interface " " as TF
|
||||||
|
interface " " as SCF
|
||||||
|
|
||||||
|
component "IoT Devices" as IOT {
|
||||||
|
interface " " as HDF
|
||||||
|
interface " " as HSF
|
||||||
|
interface " " as ZDF
|
||||||
|
interface " " as ZSF
|
||||||
|
|
||||||
|
[HomeKit smart device] as HD <<user provided>>
|
||||||
|
[HomeKit smart sensor] as HS <<user provided>>
|
||||||
|
[MQTT smart device] as ZD <<user provided>>
|
||||||
|
[MQTT smart sensor] as ZS <<user provided>>
|
||||||
|
|
||||||
|
HD--HDF
|
||||||
|
HS--HSF
|
||||||
|
ZD--ZDF
|
||||||
|
ZS--ZSF
|
||||||
|
}
|
||||||
|
|
||||||
|
component "Alexa" as ALEXA {
|
||||||
|
interface " " as ALF
|
||||||
|
|
||||||
|
[Alexa Skill Definition] as AS <<external>>
|
||||||
|
[Alexa Smart Home Skill API] as AL <<external>>
|
||||||
|
|
||||||
|
AS-(ALF
|
||||||
|
ALF-AL
|
||||||
|
}
|
||||||
|
|
||||||
|
component "User Interface" as UIC {
|
||||||
|
interface " " as WSCF
|
||||||
|
|
||||||
|
[User Interface] as UI
|
||||||
|
[WebSockets API (JavaScript)] <<external>> as WSC
|
||||||
|
|
||||||
|
WSCF)--UI
|
||||||
|
WSC--WSCF
|
||||||
|
}
|
||||||
|
|
||||||
|
component "Users and Devices" as DEV {
|
||||||
|
interface " " as DIDBF
|
||||||
|
interface " " as HAPF
|
||||||
|
interface " " as ZIGF
|
||||||
|
interface " " as WSSF
|
||||||
|
|
||||||
|
[HAP-java] as HAP <<external>>
|
||||||
|
[paho.mqtt.java] as ZIG <<external>>
|
||||||
|
[Device Engine] as DI
|
||||||
|
|
||||||
|
note left of DI: Already implemented using Spring Boot
|
||||||
|
|
||||||
|
[javax.websocket API] as WSS <<external>>
|
||||||
|
[User and Device DB <$database{scale=0.33}> (PostgreSQL)] <<external>> as DIDB
|
||||||
|
|
||||||
|
HDF )-- HAP
|
||||||
|
HSF )-- HAP
|
||||||
|
ZDF )-- ZIG
|
||||||
|
ZSF )-- ZIG
|
||||||
|
|
||||||
|
DI--(WSSF
|
||||||
|
WSSF--WSS
|
||||||
|
HAP--HAPF
|
||||||
|
ZIG--ZIGF
|
||||||
|
HAPF )-- DI
|
||||||
|
ZIGF )-- DI
|
||||||
|
DIDBF-DIDB
|
||||||
|
DI -( DIDBF
|
||||||
|
}
|
||||||
|
|
||||||
|
AL--(DIF
|
||||||
|
|
||||||
|
component "Triggers and Automations" as TRIG {
|
||||||
|
interface " " as TDBF
|
||||||
|
|
||||||
|
[Trigger and Automation Engine] as T
|
||||||
|
[Trigger and Automation DB <$database{scale=0.33}> (PostgreSQL)] <<external>> as TDB
|
||||||
|
|
||||||
|
TDBF-TDB
|
||||||
|
T -( TDBF
|
||||||
|
}
|
||||||
|
|
||||||
|
component "Scenes" as SCENE {
|
||||||
|
interface " " as SCDBF
|
||||||
|
|
||||||
|
[Scene Engine] as SC
|
||||||
|
[Scene DB <$database{scale=0.33}> (PostgreSQL)] <<external>> as SCDB
|
||||||
|
|
||||||
|
SCDBF-SCDB
|
||||||
|
SC -( SCDBF
|
||||||
|
}
|
||||||
|
|
||||||
|
DI--DIF
|
||||||
|
TF--T
|
||||||
|
SCF--SC
|
||||||
|
WSS <..> WSC: WebSocket protocol (RFC 6455)
|
||||||
|
DI --( TF
|
||||||
|
T --( SCF
|
||||||
|
DIF )-- SC
|
||||||
|
DIF )-- UI
|
||||||
|
UI --( SCF
|
||||||
|
UI --( TF
|
||||||
|
|
||||||
|
skinparam monochrome true
|
||||||
|
skinparam shadowing false
|
||||||
|
skinparam defaultFontName Courier
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Process View
|
||||||
|
|
||||||
|
Use case: a user alters manually the state of device 'D' via Alexa voice command,
|
||||||
|
and the device updates accordingly. Device 'D' is not part of any defined trigger.
|
||||||
|
|
||||||
|
```puml
|
||||||
|
@startuml
|
||||||
|
title Process View: UI updates state of device
|
||||||
|
|
||||||
|
box "IoT Devices"
|
||||||
|
participant "MQTT device 'D'" as ZD
|
||||||
|
end box
|
||||||
|
|
||||||
|
box "User Interface"
|
||||||
|
participant "UI" as UI
|
||||||
|
participant "WebSockets API (JS)" as WSC
|
||||||
|
end box
|
||||||
|
|
||||||
|
box "Alexa"
|
||||||
|
participant "Alexa Skill Definition" as AS
|
||||||
|
participant "Alexa Smart Home Skill API" as AL
|
||||||
|
end box
|
||||||
|
|
||||||
|
box "Users and Devices"
|
||||||
|
participant "javax.websocket" as WSS
|
||||||
|
participant "HAP-java" as HAP
|
||||||
|
participant "paho.mqtt.java" as ZIG
|
||||||
|
participant "Engine" as DI
|
||||||
|
participant "DB" as DIDB
|
||||||
|
end box
|
||||||
|
|
||||||
|
box "Triggers and Automations"
|
||||||
|
participant "Engine" as T
|
||||||
|
participant "DB" as TDB
|
||||||
|
end box
|
||||||
|
|
||||||
|
box "Scenes"
|
||||||
|
participant "Engine" as SC
|
||||||
|
participant "DB" as SCDB
|
||||||
|
end box
|
||||||
|
|
||||||
|
AS -> AL: interprets "Turn on device D" command
|
||||||
|
AL -> DI: HTTP 1.1 PUT /devices/{id}/state\n(update state)
|
||||||
|
DI -> ZIG: client.publish(\n TOPIC,\n new MqttMessage(...)\n);\n(request state update)
|
||||||
|
ZIG -> ZD: MQTT PUBLISH\n(state update request)
|
||||||
|
ZD -> ZIG: MQTT PUBLISH\n(new state)
|
||||||
|
ZIG -> DI: subscriber.subscribe(...) observer called \n(successful application)
|
||||||
|
DI -> DIDB: JDBC transaction (UPDATE)\n(store new state)
|
||||||
|
DI -> WSS: s.getBasicRemote().sendText(...)\n(send new device state)
|
||||||
|
WSS <--> WSC: WebSocket protocol
|
||||||
|
WSC -> UI: connection.onmessage called\n(new device state received, updates UI)
|
||||||
|
DI -> T: report latest device state
|
||||||
|
|
||||||
|
skinparam monochrome true
|
||||||
|
skinparam shadowing false
|
||||||
|
skinparam defaultFontName Courier
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Deployment View
|
||||||
|
|
||||||
|
```puml
|
||||||
|
@startuml
|
||||||
|
title SmartHut Deployment View
|
||||||
|
|
||||||
|
node "Users and Devices" {
|
||||||
|
[Engine] as UW
|
||||||
|
}
|
||||||
|
|
||||||
|
node "Triggers and Automations" {
|
||||||
|
[Engine] as TW
|
||||||
|
}
|
||||||
|
|
||||||
|
node "Scenes" {
|
||||||
|
[Engine] as SW
|
||||||
|
}
|
||||||
|
|
||||||
|
database "Users and Devices Database" {
|
||||||
|
[DB] as UDB
|
||||||
|
UW - UDB: JDBC
|
||||||
|
}
|
||||||
|
|
||||||
|
database "Triggers and Automations Database" {
|
||||||
|
[DB] as TDB
|
||||||
|
TW -- TDB: JDBC
|
||||||
|
}
|
||||||
|
|
||||||
|
database "Scenes Database" {
|
||||||
|
[DB] as SDB
|
||||||
|
SW - SDB: JDBC
|
||||||
|
}
|
||||||
|
|
||||||
|
UW -- TW: HTTPS
|
||||||
|
TW -- SW: HTTPS
|
||||||
|
UW -- SW: HTTPS
|
||||||
|
|
||||||
|
node "Device" {
|
||||||
|
[Web Based User Interface] as UI
|
||||||
|
}
|
||||||
|
|
||||||
|
cloud "User owned smart devices" {
|
||||||
|
[Homekit Smart Device] as HD
|
||||||
|
[Homekit Smart Sensor] as HS
|
||||||
|
[MQTT Smart Device] as MD
|
||||||
|
[MQTT Smart Sensor] as MS
|
||||||
|
}
|
||||||
|
|
||||||
|
cloud "User Interface CDN" {
|
||||||
|
[User Interface Web Server] as CDN
|
||||||
|
}
|
||||||
|
|
||||||
|
cloud "Alexa" {
|
||||||
|
[Alexa Skill Definition] as AS
|
||||||
|
[Alexa Smart Home Skill API] as AL
|
||||||
|
}
|
||||||
|
|
||||||
|
UW -- HD: Homekit protocol
|
||||||
|
UW -- HS: Homekit protocol
|
||||||
|
UW -- MD: MQTT
|
||||||
|
UW -- MS: MQTT
|
||||||
|
|
||||||
|
UI -- CDN: HTTPS
|
||||||
|
UI -- UW: HTTPS
|
||||||
|
UI -- TW: HTTPS
|
||||||
|
UI -- SW: HTTPS
|
||||||
|
|
||||||
|
AS -- AL: RPC (JavaScript)
|
||||||
|
AL -- UW: HTTPS
|
||||||
|
|
||||||
|
skinparam monochrome true
|
||||||
|
skinparam shadowing false
|
||||||
|
skinparam defaultFontName Courier
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
Reference in a new issue