Skip to content
This repository was archived by the owner on Mar 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2e3dbe9
added return statements to errors
Pake-TU Jan 24, 2025
5aea0b9
Added testfile
Pake-TU Jan 24, 2025
c45cedf
added some tests
Pake-TU Jan 24, 2025
81fa3ec
removed comfortstat from zigbee branch
Pake-TU Jan 27, 2025
9ea6be5
Fixed test for newResource, now working
Pake-TU Jan 27, 2025
d6de189
added systemconfig template because it's needed for the tests
Pake-TU Jan 27, 2025
9996348
test
Pake-TU Jan 27, 2025
50d30ec
test2
Pake-TU Jan 27, 2025
4a1a5d7
Makefile back to normal
Pake-TU Jan 27, 2025
ba91d61
Fixed workflow (git tests)
Pake-TU Jan 27, 2025
665be03
Added new tests, work in progress
Pake-TU Jan 28, 2025
39a4dc4
Added new tests etc
Pake-TU Jan 28, 2025
99dc342
Tested pretty much all the code possible in things.go, moving on to Z…
Pake-TU Jan 29, 2025
e54fbd5
changed tests, and added new tests
Pake-TU Feb 3, 2025
af798aa
More tests, and fixed some problems with earlier tests
Pake-TU Feb 3, 2025
a7aed2c
Fixed some merge comments
Pake-TU Feb 4, 2025
7b0c41d
Fixes spelling error on signal's unit
lmas Feb 4, 2025
914ced5
changed a few comments
Pake-TU Feb 6, 2025
5d605be
Merge branch 'ZigBeeValve' of github.com:lmas/d0020e_code into ZigBee…
Pake-TU Feb 6, 2025
245145e
Added functions and other goodies
Pake-TU Feb 10, 2025
f5b76cf
Added test for getConnectedUnits()
Pake-TU Feb 11, 2025
9a9cbae
Fixed some PR comments
Pake-TU Feb 12, 2025
8f869d2
Added code for a WebsocketClient, needs to be tested on Raspberry Pi
Pake-TU Feb 13, 2025
75522b0
Forgot to add go.mod & go.sum files
Pake-TU Feb 13, 2025
ebbb495
Forgot to add a link to useful info, and a line of code to properly c…
Pake-TU Feb 13, 2025
5162103
Added an error message to pass linter in example code for listening t…
Pake-TU Feb 14, 2025
0c05591
Merge remote-tracking branch 'origin/dev' into ZigBeeValve
lmas Feb 14, 2025
9ff159b
Removes uninteresting log line
lmas Feb 14, 2025
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
32 changes: 20 additions & 12 deletions ZigBeeValve/ZigBeeValve.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func main() {
defer cancel() // make sure all paths cancel the context to avoid context leak

// instantiate the System
sys := components.NewSystem("ZigBee", ctx)
sys := components.NewSystem("ZigBeeHandler", ctx)

// Instatiate the Capusle
sys.Husk = &components.Husk{
Description: " is a controller for smart thermostats connected with a RaspBee II",
Description: " is a controller for smart devices connected with a RaspBee II",
Certificate: "ABCD",
Details: map[string][]string{"Developer": {"Arrowhead"}},
ProtoPort: map[string]int{"https": 0, "http": 8870, "coap": 0},
Expand All @@ -37,6 +37,12 @@ func main() {
assetName := assetTemplate.GetName()
sys.UAssets[assetName] = &assetTemplate

// Find zigbee gateway and store it in a global variable for reuse
err := findGateway()
if err != nil {
log.Fatal("Error getting gateway, shutting down: ", err)
}

// Configure the system
rawResources, servsTemp, err := usecases.Configure(&sys)
if err != nil {
Expand All @@ -48,8 +54,8 @@ func main() {
if err := json.Unmarshal(raw, &uac); err != nil {
log.Fatalf("Resource configuration error: %+v\n", err)
}
ua, cleanup := newResource(uac, &sys, servsTemp)
defer cleanup()
ua, startup := newResource(uac, &sys, servsTemp)
startup()
sys.UAssets[ua.GetName()] = &ua
}

Expand All @@ -75,7 +81,7 @@ func (t *UnitAsset) Serving(w http.ResponseWriter, r *http.Request, servicePath
case "setpoint":
t.setpt(w, r)
default:
http.Error(w, "Invalid service request [Do not modify the services subpath in the configurration file]", http.StatusBadRequest)
http.Error(w, "Invalid service request [Do not modify the services subpath in the configuration file]", http.StatusBadRequest)
}
}

Expand All @@ -87,16 +93,18 @@ func (rsc *UnitAsset) setpt(w http.ResponseWriter, r *http.Request) {
case "PUT":
sig, err := usecases.HTTPProcessSetRequest(w, r)
if err != nil {
log.Println("Error with the setting desired temp ", err)
http.Error(w, "Request incorrectly formated", http.StatusBadRequest)
return
}
log.Println("sig:", sig)
log.Println("URL:", r.URL)
log.Println("Model:", rsc.Model)

rsc.setSetPoint(sig)
if rsc.Model == "SmartThermostat" {
rsc.sendSetPoint()
if rsc.Model == "ZHAThermostat" {
err = rsc.sendSetPoint()
if err != nil {
http.Error(w, "Couldn't send setpoint.", http.StatusInternalServerError)
return
}
}

default:
http.Error(w, "Method is not supported.", http.StatusNotFound)
}
Expand Down
Loading