This api client does NOT follow the official smappee api documentation. This is due to the fact that their api is not that user friendly.
go get thomascrmbz.com/smappee
package main
import (
"fmt"
"log"
"time"
"thomascrmbz.com/smappee"
)
func main() {
s, err := smappee.NewSmappee(
"clientID", "clientSecret", "username", "password",
)
if err != nil {
log.Fatal(err)
}
c, _ := s.GetElectricityConsumption(60904, time.Now())
fmt.Println(c)
}
// Create Smappee client
s, err := smappee.NewSmappee(clientID, clientSecret, username, password)
// Get Service Locations
locations, err := s.GetServiceLocations()
// Get Electricity Consumption
consumption, err := s.GetElectricityConsumption(id)
// Get Active Consumptions
activeConsumptions, err := consumption.GetActiveConsumptions()
// Filter Active Consumptions by channel name
activeConsumptions, err := consumption.GetActiveConsumptions("channel1", "channel2")
// Service Locations
func (s *Smappee) GetServiceLocations() ([]ServiceLocation, error)
func (s *Smappee) GetServiceLocation(id int) (ServiceLocation, error)
func (s *Smappee) DeleteServiceLocation(id int) (error)
// Electricity Consumption
func (s *Smappee) GetElectricityConsumption(id int, timestamp ...time.Time) (ElectricityConsumption, error)
func (s *Smappee) GetElectricityConsumptions(id int, aggregation int, from time.Time, to ...time.Time) ([]ElectricityConsumption, error)
func (ec *ElectricityConsumption) GetActiveConsumptions(name ...string) ([]ActiveConsumption, error)
// Metering Configuration
func (s *Smappee) GetMeteringConfiguration(id int) (MeteringConfiguration, error)
func (sl *ServiceLocation) GetSensorConsumptions(id int, aggregation int, from time.Time, to ...time.Time) ([]SensorConsumption, error)
Read the reference docs for more information about how to use all the methods.
This project is a work in progress. Any feedback and requests are welcome. If you feel like something is missing, please open an issue on GitHub.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
See the LICENSE file for licensing information.