Compare commits
3 Commits
0.3.11
...
influxdb-m
| Author | SHA1 | Date | |
|---|---|---|---|
|
0f6590c720
|
|||
|
42ff8b51ed
|
|||
|
f63c22912a
|
@@ -2,15 +2,13 @@ package dt1t
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"time"
|
||||
"strconv"
|
||||
"udi/handlers/handler"
|
||||
"udi/database"
|
||||
"time"
|
||||
"udi/config"
|
||||
"udi/database"
|
||||
"udi/handlers/handler"
|
||||
)
|
||||
|
||||
|
||||
type Dt1tHandler struct {
|
||||
handler.CommonHandler
|
||||
ready bool
|
||||
@@ -18,12 +16,10 @@ type Dt1tHandler struct {
|
||||
dbh *database.DatabaseHandle
|
||||
application string
|
||||
device string
|
||||
|
||||
}
|
||||
|
||||
func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
t := &Dt1tHandler {
|
||||
}
|
||||
t := &Dt1tHandler{}
|
||||
|
||||
if config.Attributes["Application"] == "" {
|
||||
log.Println("Error: application not configured")
|
||||
@@ -69,7 +65,7 @@ func (self *Dt1tHandler) Handle(message handler.MessageT) {
|
||||
variable.Label = "Temperature"
|
||||
variable.Variable = ""
|
||||
variable.Unit = "°C"
|
||||
variable.Value = fmt.Sprintf("%f", temperatureF)
|
||||
variable.Value = temperatureF
|
||||
measurement.Values = make(map[string]database.VariableType)
|
||||
measurement.Values["Value"] = variable
|
||||
|
||||
@@ -77,5 +73,3 @@ func (self *Dt1tHandler) Handle(message handler.MessageT) {
|
||||
self.dbh.StoreMeasurement(&measurement)
|
||||
self.S()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package prepared
|
||||
|
||||
import (
|
||||
"time"
|
||||
"log"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"time"
|
||||
"udi/config"
|
||||
"udi/handlers/handler"
|
||||
"udi/database"
|
||||
"udi/handlers/handler"
|
||||
)
|
||||
|
||||
|
||||
type PreparedHandler struct {
|
||||
handler.CommonHandler
|
||||
dbh *database.DatabaseHandle
|
||||
@@ -18,7 +17,7 @@ type PreparedHandler struct {
|
||||
type endpoint_t struct {
|
||||
Label string `json:"label"`
|
||||
Variable string `json:"variable"`
|
||||
Value string `json:"value"`
|
||||
Value interface{} `json:"value"`
|
||||
Unit string `json:"unit"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
@@ -29,10 +28,8 @@ type observation_t struct {
|
||||
Variables map[string]endpoint_t `json:"variables"`
|
||||
}
|
||||
|
||||
|
||||
func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
t := &PreparedHandler {
|
||||
}
|
||||
t := &PreparedHandler{}
|
||||
t.Id = id
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler Prepared %d initialized", id)
|
||||
@@ -75,5 +72,3 @@ func (self *PreparedHandler) Handle(message handler.MessageT) {
|
||||
self.dbh.StoreMeasurement(&measurement)
|
||||
self.S()
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user