-func (nsi SpaceInfo) UpdateSensorData(what, where, value string) {
- if nsi["sensors"] == nil {
- sensorlist := make([]SpaceInfo, 1)
- sensorlist[0] = SpaceInfo{what: SpaceInfo{where: value}}
- nsi["sensors"] = sensorlist
+type SpaceTempSensor struct {
+ value string
+ unit string
+ location string
+ name string
+ description string
+}
+
+type SpaceLightSensor struct {
+ value string
+ //~ unit string
+ location string
+ name string
+ description string
+}
+
+type SpacePowerConsumptionSensor struct {
+ value string
+ unit string
+ location string
+ name string
+ description string
+}
+
+type SpaceNetworkConnectionsSensor struct {
+ value string
+ nettype string
+ machines string
+ location string
+ name string
+ description string
+}
+
+type SpaceMemberCountSensor struct {
+ value string
+ location string
+ name string
+ description string
+}
+
+type SpaceDoorLockSensor struct {
+ value bool
+ location string
+ name string
+ description string
+}
+
+type SpaceDoorAjarSensor struct {
+ value bool
+ location string
+ name string
+ description string
+}
+
+func (nsi SpaceTempSensor) MakeTempSensor(what, name, where, value, unit string) {
+
+}
+
+func (nsi SpaceInfo) MergeInSensorData(sensortype interface{}) {
+ //todo check if what equals either "temperature", "door_locked", "barometer", "humidity", "beverage_supply", "power_consumption", "wind", "network_connections", "account_balance", "total_member_count", "people_now_present" or starts with "ext_". Else prepend "ext_"
+ var what string
+ switch sensortype := sensortype.(type) {
+ case SpaceTempSensor:
+ what = "temperature"
+ case SpaceLightSensor:
+ what = "ext_illumination"
+ case SpacePowerConsumptionSensor:
+ what = "power_consumption"
+ case SpaceNetworkConnectionsSensor:
+ what = "network_connections"
+ case SpaceMemberCountSensor:
+ what = "total_member_count"
+ case SpaceDoorLockSensor:
+ what = "door_locked"
+ case SpaceDoorAjarSensor:
+ what = "ext_door_ajar"
+ default:
+ panic("Unknown Sensor Type")
+ }
+
+ if nsi["sensors"] == nil {
+ listofwhats := make([]SpaceInfo, 1)
+ listofwhats[0] = sensortype.(SpaceInfo)
+ sensorobj := SpaceInfo{what: listofwhats}
+ nsi["sensors"] = sensorobj