Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermostat Schedule Retrieval Code #38

Merged
merged 26 commits into from
Jan 29, 2019
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f097057
added first version of thermostat schedule retrieval code
john-b-yang Jan 10, 2019
8b64617
added working draft of schedule retrieval code. Added rrule conversio…
john-b-yang Jan 11, 2019
e595d59
cleaned up JSON struct field and type naming
john-b-yang Jan 11, 2019
f925fc5
debugging unknown variable issue
john-b-yang Jan 11, 2019
05d009b
created polling parameters, code for retrieving thermostat schedule i…
john-b-yang Jan 11, 2019
bd32c96
cleaned up method, struct, and variable naming. Replace id with noden…
john-b-yang Jan 11, 2019
79e33ee
edited thermostat scheduler code by recommendations
john-b-yang Jan 13, 2019
a46e042
removed unnecessary conditional case
john-b-yang Jan 14, 2019
fa4c6df
replaced structs for retrieving thermostat IDs with free form interfa…
john-b-yang Jan 14, 2019
a7ff14d
removed all decoding structs, reimplemented JSON parsing with free fo…
john-b-yang Jan 14, 2019
1e9aebd
reverted free form interface JSON decoding to struct based approach. …
john-b-yang Jan 15, 2019
92149c3
added small modification to interface name
john-b-yang Jan 16, 2019
420aed1
added msgpack aliases to return JSONs
john-b-yang Jan 16, 2019
ec0a841
added descriptions to the thermostat schedule result structs
john-b-yang Jan 16, 2019
7c6e4cc
some refs failed to push, repushing
john-b-yang Jan 16, 2019
686d8e0
adding markdown description of schedule interface, file is interface.md
john-b-yang Jan 18, 2019
91504f9
added more in depth explanations regarding schedule struct in interfa…
john-b-yang Jan 19, 2019
2ae10cd
corrected struct definition errors, added explanation regarding how R…
john-b-yang Jan 21, 2019
7739169
added examples regarding what time conversion might look like
john-b-yang Jan 22, 2019
a242229
corrected grammatical + syntax errors in interface doc
john-b-yang Jan 23, 2019
3d9501a
small grammatical correction
john-b-yang Jan 23, 2019
e93ed19
cut out intermediate day schedule struct and made time parsing more c…
john-b-yang Jan 24, 2019
1643010
added new schedule go request field to Pelican, corrected occupancy s…
john-b-yang Jan 24, 2019
e20fda0
created 3 new fields for Pelican struct (id, cookie, sitename). Recon…
john-b-yang Jan 26, 2019
266e819
added 2 clarifying comments regarding setCookieAndID method
john-b-yang Jan 26, 2019
aad2654
cleaned up syntax + conditional cases. Added new cookie expiration fi…
john-b-yang Jan 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 42 additions & 16 deletions driver/pelican/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@ The following structs define the way users interact with the Scheduling interfac

##### Schedule Structs

// Struct mapping each day of the week to its daily schedule <br>
type ThermostatSchedule struct {<br>
&nbsp;&nbsp;&nbsp;DaySchedules map[string]ThermostatDaySchedule `msgpack:"day_schedules"`<br>
}<br>

// Struct containing a series of blocks that describes a one day schedule <br>
type ThermostatDaySchedule struct { <br>
&nbsp;&nbsp;&nbsp;Blocks []ThermostatBlockSchedule `msgpack:blocks` <br>
} <br>

// Struct containing data defining the settings of each schedule block <br>
type ThermostatBlockSchedule struct { <br>
&nbsp;&nbsp;&nbsp;CoolSetting float64 `msgpack:"cool_setting"` <br>
&nbsp;&nbsp;&nbsp;HeatSetting float64 `msgpack:"heat_setting"` <br>
&nbsp;&nbsp;&nbsp;System string `msgpack:"system"` <br>
&nbsp;&nbsp;&nbsp;Time string `msgpack:"time"` <br>
```
// Struct mapping each day of the week to its daily schedule
type ThermostatSchedule struct {
DaySchedules map[string]ThermostatDaySchedule `msgpack:"day_schedules"`
}

// Struct containing a series of blocks that describes a one day schedule
john-b-yang marked this conversation as resolved.
Show resolved Hide resolved
type ThermostatDaySchedule struct {
Blocks []ThermostatBlockSchedule `msgpack:blocks`
john-b-yang marked this conversation as resolved.
Show resolved Hide resolved
}

// Struct containing data defining the settings of each schedule block
type ThermostatBlockSchedule struct {
CoolSetting float64 `msgpack:"cool_setting"` // Cooling turns on when room temperature exceeds cool setting temp.
john-b-yang marked this conversation as resolved.
Show resolved Hide resolved
HeatSetting float64 `msgpack:"heat_setting"` // Heating turns on when room temperature drops below heat setting temp.
System string `msgpack:"system"` // Indicates if system is heating, cooling, off, or set to auto
Time string `msgpack:"time"` // Indicates the time of day which the above settings are enacted.
}
```

##### Schedule Structs Explanation

Each Pelican Thermostat has three potential schedule settings.
Expand All @@ -35,6 +37,30 @@ Next, it's wise if we attempt to define what a "daily schedule" actually looks l

Going one layer above, the ThermostatDaySchedule struct represents an array of blocks. The purpose of this struct is to represent the schedule of one day a.k.a a series of blocks. Last but not least, the outermost struct, "ThermostatSchedule", maps each day of the week (Sunday - Saturday) to their respective daily schedules (ThermostatDaySchedule struct). This is the struct that is delivered to the user for getting and setting purposes.

##### Thermostat Block Schedule Struct Fields Explanation

- CoolSetting: The cool setting refers to the temperature at which the system begins cooling. In other words, if the room temperature surpasses this threshold, the cooling system is activated. The unit of temperature is Fahrenheit.
- HeatSetting: The heat setting refers to the temperature at which the system begins heating. In other words, if the room temperature falls below this threshold, the heating system is activated. The unit of temperature is Fahrenheit.
- System: This indicates what the system is currently doing. There are four possible settings (heat/cool/off/auto) which are pretty self explanatory. Heat and cool mean the systems heating or cooling the room. Auto means that the system will automatically heat or cool according to the room temperature and cool/heat thresholds.
- Time: Time describes what time of day the particular block's settings are enacted (i.e. 6:00:AM). This time is in the RRule format (https://tools.ietf.org/html/rfc5545), and the rrule-go library is used to convert the given time into the designated format. The following section describes how time is formatted and defined in greater detail.
john-b-yang marked this conversation as resolved.
Show resolved Hide resolved
john-b-yang marked this conversation as resolved.
Show resolved Hide resolved

##### A Deeper Dive into Time Format (RRule)
john-b-yang marked this conversation as resolved.
Show resolved Hide resolved

Within "thermoSchedule.go", this particular block in the "convertTimeToRRule" function is responsible for creating the RRule format.

```
rruleSched, _ := rrule.NewRRule(rrule.ROption{
Freq: rrule.WEEKLY,
Wkst: weekRRule[dayOfWeek],
Dtstart: time.Date(0, 0, 0, hour, minute, 0, 0, timezone),
})
```

Three fields are configured.
- Frequency indicates the interval with which this event occurs.
- Wkst tells us which day of the week (Sunday - Saturday) this event occurs.
- Dtstart is a required field that indicates the "start date" of the particular event. In Go, the Dtstart field is a time.Date object, which is initialized with the following parameters: year, month, day, hour minute, second, millisecond, timezone. For our purposes, there is no real concept of a "start date", just the time, so the year, month, and day parameters are filled with dummy values of 0. Only hour, minute, and timezone (which can be determined from the Pelican settings + schedule) are filled in. As long as an individual knows the time is in RRule format, he or she will be able to determine each field.

##### XBOS Interface Configuration

The current version of XBOS uses YAML files to define the expectations for the output of different functionalities of the driver code from the bw2-contrib repository. There are a couple limitations regarding what the YAML files are able to represent. The incumbent version of XBOS features protobuf definitions for messages. When the next release of XBOS comes, both new and existing YAML files will be created and modified to reflect the outputs' types more accurately.