Documentation
¶
Index ¶
- type MiTDSensor
- func (tds *MiTDSensor) Comfortable() (float64, float64, int, int, error)
- func (tds *MiTDSensor) Connect(timeout time.Duration) error
- func (tds *MiTDSensor) Disconnect() error
- func (tds *MiTDSensor) EnableNotify() error
- func (tds *MiTDSensor) MAC() string
- func (tds *MiTDSensor) SavePower() error
- func (tds *MiTDSensor) SetComfortable(maxT, minT float64, maxH, minH int) error
- func (tds *MiTDSensor) SetTime(t time.Time) error
- func (tds *MiTDSensor) Subscribe(handler func(r *THReading)) error
- func (tds *MiTDSensor) Time() (time.Time, error)
- func (tds *MiTDSensor) Version() string
- type THReading
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MiTDSensor ¶
type MiTDSensor struct {
// contains filtered or unexported fields
}
MiTDSensor is a sensor from Mijia2
func NewMiTDSensor ¶
func NewMiTDSensor(host *linux.Device, macaddr string) *MiTDSensor
NewMiTDSensor creates a new Mi temperature and humidity sensor interface
func (*MiTDSensor) Comfortable ¶
Comfortable reports the comfortable temperature and humidity ranges
func (*MiTDSensor) Connect ¶
func (tds *MiTDSensor) Connect(timeout time.Duration) error
Connect will connect the host to the sensor
func (*MiTDSensor) Disconnect ¶
func (tds *MiTDSensor) Disconnect() error
Disconnect will disconnect host from the sensor
func (*MiTDSensor) EnableNotify ¶
func (tds *MiTDSensor) EnableNotify() error
EnableNotify makes the sensor send sensor data notifications
func (*MiTDSensor) SavePower ¶
func (tds *MiTDSensor) SavePower() error
SavePower reduces sensor power consumption by reducing report interval. See https://github.com/JsBergbau/MiTemperature2/issues/18#issuecomment-590986874
func (*MiTDSensor) SetComfortable ¶
func (tds *MiTDSensor) SetComfortable(maxT, minT float64, maxH, minH int) error
SetComfortable sets the comfortable temperature and humidity ranges. Emoji on sensor will change according to actual value within range (adapted from manufacturer manual): ``` |-----------|--------|-----------|-------| | Humidity | < minT | minT~maxT | >maxT | |-----------|--------|-----------|-------| | <minH | (-^-) | (-^-) | (-^-) | | minH~maxH | (-^-) | (^_^) | (-^-) | | >maxH | (-^-) | (-^-) | (-^-) | ```
func (*MiTDSensor) SetTime ¶
func (tds *MiTDSensor) SetTime(t time.Time) error
SetTime sets the sensor RTC time
func (*MiTDSensor) Subscribe ¶
func (tds *MiTDSensor) Subscribe(handler func(r *THReading)) error
Subscribe adds a hook to the notification API
func (*MiTDSensor) Time ¶
func (tds *MiTDSensor) Time() (time.Time, error)
Time returns the sensor RTC time
func (*MiTDSensor) Version ¶
func (tds *MiTDSensor) Version() string
Version reports the supported sensor version
type THReading ¶
type THReading struct {
Temperature float64
Humidity float64
Voltage float64
// contains filtered or unexported fields
}
THReading represents a temperature and humidity sensor reading. Works with LYWSD03MMC.
func NewTHReading ¶
NewTHReading returns a new THReading