misense

package module
v0.0.0-...-ec4e6fa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 7 Imported by: 0

README

misense

Sensor library for LYWSD03MMC

Documentation

Index

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

func (tds *MiTDSensor) Comfortable() (float64, float64, int, int, error)

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) MAC

func (tds *MiTDSensor) MAC() string

MAC returns the sensor MAC address

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

func NewTHReading(t, h, volt float64, macaddr string) *THReading

NewTHReading returns a new THReading

func (*THReading) Battery

func (r *THReading) Battery() int

Battery returns the current battery level based on voltage

func (*THReading) MAC

func (r *THReading) MAC() string

MAC returns the sensor MAC address

func (*THReading) String

func (r *THReading) String() string

String returns a string representation of a THReading

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL