Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
synchronize relay states in addition to temperatures
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfantom committed Dec 5, 2019
1 parent 04121e3 commit 1bd98ec
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ var (
)

func topicMapper(device string, circuit string) string {
topic := "evok/" + device + "/" + circuit + "/value"
// Map topics to new ones
for _, m := range config.Mappings {
if m.Device == device && m.Circuit == circuit {
topic = m.Topic
return m.Topic
}
}
return topic
return "evok/" + device + "/" + circuit + "/value"
}

func applyOffset(input float64, topic string) string {
Expand Down Expand Up @@ -117,7 +116,7 @@ func synchronizer(evok string, interval int) {
log.Printf("Got data from evok: %v", data)

for _, sensor := range data.Data {
if sensor.Dev != "temp" {
if sensor.Dev != "temp" && sensor.Dev != "relay" {
continue
}
topic := topicMapper(sensor.Dev, sensor.Circuit)
Expand Down

0 comments on commit 1bd98ec

Please sign in to comment.