mirror of
https://github.com/MickMake/GoSungrow.git
synced 2025-03-26 09:31:43 +01:00
29 lines
442 B
Go
29 lines
442 B
Go
package cmdHassio
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/MickMake/GoUnify/Only"
|
|
)
|
|
|
|
|
|
type MqttState struct {
|
|
LastReset string `json:"last_reset,omitempty"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
func (mq *MqttState) Json() string {
|
|
var ret string
|
|
for range Only.Once {
|
|
j, err := json.Marshal(*mq)
|
|
if err != nil {
|
|
ret = fmt.Sprintf("{ \"error\": \"%s\"", err)
|
|
break
|
|
}
|
|
ret = string(j)
|
|
}
|
|
return ret
|
|
}
|
|
|
|
type SensorState string
|