Documentation
This is currently under development. Additional documentation is being added so please check back again for updates.
ossdk.project_form.setValues()
Set a value for specific fields of a project.
<Button
variant="outlined"
disabled={!loaded || !projectKey}
onClick={async () => {
await ossdk.project_form.setValues({ zip: String(90000 + Math.round(1000 * Math.random())) })
alert('Zip code set to random value')
console.log('setValues complete')
}}
>
Set Field
</Button>
Accepted fields
is_residential: boolean
title: string
identifier: string
business_name: string | null
address: string | null
zip: string | null
state: string | null
locality: string | null
county: string | null
country_iso2: string | null
lat: number
lon: number
lead_source: string
business_identifier: string
number_of_storeys: number | null
number_of_phases: number | null
number_of_wires: number | null
roof_type_name: string
site_notes: string
notes: string
roof_type: string
custom_project_info_1: string
custom_project_info_2: string
custom_project_info_3: string
custom_project_info_4: string
custom_project_info_5: string
roof_type_id: number | null
ossdk.project_form.getDesignData()
Returns the project's design data.
const doGetDesignData = async (ossdk) => {
ossdk.project_form.getDesignData().then((designData) => {
setModalTitle('Design Data')
setDataModalContent(JSON.stringify(designData, null, 2))
setShowDataModal(true)
})
}
ossdk.project_form.save
Save the project.
ossdk.project_form.save()
ossdk.project_form.saveState
The current state of saving the project. Can be one of the following states:
- 'none'
- 'new'
- 'unsaved'
- 'saving'
- 'saved'
type SaveState = 'none' | 'new' | 'unsaved' | 'saving' | 'saved'
const projectSaveState: SaveState = ossdk.project_form.saveState
ossdk.project_form.dirty_fields
This array contains all the fields that have changed but have not been saved - i.e. the field is 'dirty'. If this array contains the value 'design' then this indicates that the design data for this project is 'dirty.'
// fields can contain 'design'
const fields: any[] = ossdk.project_form.dirty_fields
ossdk.studio.view.animateToLonLat()
Set the longitude and latitude of the design page, with a scrolling animation.
Arguments
lonLat: [number, number]
. Coordinates to be used by the design.duration?: number
. Time in milliseconds, that would take the animation to finish.
export const setLonLat = async (ossdk) => {
var selectedView = await ossdk.studio.selectedView();
var lonLat = [selectedView.mapData.center[0] + 0.0001, selectedView.mapData.center[1]];
await ossdk.studio.view.animateToLonLat(lonLat, 1000);
};
ossdk.studio.setComponents()
Set hardware explicitly for the current system. "Panel" sets the panel-type but panels must be placed manually.
Arguments
components: { code: string, quantity?: number }[]
. Components and quantities to add.keepExistingComponents?: Boolean (optional, default: false)
. By default this will clear all components of the current system before adding the specified components.systemUuid?: string
. Optionally update a specific system. If omitted it will update the currently selected system. Can be retrieved fromossdk.project_form.values.systems
.
<Button
variant={'outlined'}
disabled={!loaded || !projectKey}
onClick={async () => {
await ossdk.studio.setComponents([
{ code: 'Solaria PowerXT-400R-PM' },
{ code: 'Fronius Primo 5.0-1 208-240 [240V]' },
{ code: 'EVOLVE LFP 5kW/14kWh' },
])
alert(
'US Bundle 1\nComponents added to the system\nModule: Solaria PowerXT-400R-PM\nInverter: Fronius Primo 5.0-1 208-240 [240V]\nBattery: EVOLVE LFP 5kW/14kWh'
)
}}
>
US Bundle 1
</Button>
ossdk.studio.view.setShadingVisibility()
Adds an orange overlay on the design that highlights shaded areas.
Arguments
value?: boolean
. optional, if provided this will set the shading visibility.
<Button
variant="outlined"
disabled={!loaded || !projectKey}
onClick={() => ossdk.studio.view.setShadingVisibility()}
>
Toggle Shade
</Button>
ossdk.studio.getSystemImageUrl()
Get the system image for a specific project.
Arguments
systemUuid: string
. The UUID for the system to be generated. Can be retrieved fromossdk.project_form.values.systems
.width?: number
. The width of the image in px.heigth?: number
. The height of the image in px.
<Button
variant="outlined"
disabled={!loaded || !projectKey}
onClick={() => {
ossdk.studio.getSystemImageUrl(system.uuid).then((systemImageUrl) => {
window.open(systemImageUrl)
})
}}
>
System Image
</Button>
ossdk.flows.generateDocument()
Generate a project document
Arguments
projectId?: number
. optionalorgId?: number
. optionaldocumentType: string
. Possible values (proposal, contract, owners_manual, installation_instructions, energy_yield_report, shade_report, structural_report_mcs, pv_site_plan)systemUuid: string
. Can be retrieved fromossdk.project_form.values.systems
.paymentOptionId?: number
. optional. See Getting a list of Payment Options.
<Button
variant="outlined"
disabled={!loaded || !projectKey}
onClick={() => {
let systemUuid = system.uuid
if (!systemUuid) {
showAlertMessage('No selected system to generate share report. Create or load a system.', 'error')
return
}
ossdk.flows.generateDocument({ systemUuid, documentType: 'shade_report' }).then((data) => {
console.log('Document created', data)
showAlertMessage(`Document created: ${data.title}`, 'success')
window.open(data.url)
})
}}
>
Generate Document
</Button>
ossdk.signals.queueProcessed
This signal is dispatched as various processing events occur within the SDK. When the idle
attribute is true
, then the system is not currently performing calculations and is not busy updating the project.
interface UpdateInfo {
idle: boolean // indicates no calculations or changes are being made to the project
}
ossdk.studio.queueProcessed.add((updateInfo: UpdateInfo) => {
const { idle } = updateInfo
setIdle(idle)
})