forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_blueprint.go
124 lines (93 loc) · 3.21 KB
/
_blueprint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package charger
// LICENSE
// Copyright (c) 2019-2022 andig
// This module is NOT covered by the MIT license. All rights reserved.
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import (
"time"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
)
// Blueprint charger implementation
type Blueprint struct {
*request.Helper
cache time.Duration
}
func init() {
// registry.Add("foo", NewBlueprintFromConfig)
}
// NewBlueprintFromConfig creates a blueprint charger from generic config
func NewBlueprintFromConfig(other map[string]interface{}) (api.Charger, error) {
var cc struct {
URI string
Cache time.Duration
}
if err := util.DecodeOther(other, &cc); err != nil {
return nil, err
}
return NewBlueprint(cc.URI, cc.Cache)
}
// NewBlueprint creates Blueprint charger
func NewBlueprint(uri string, cache time.Duration) (api.Charger, error) {
log := util.NewLogger("foo")
wb := &Blueprint{
Helper: request.NewHelper(log),
cache: cache,
}
return wb, nil
}
// Status implements the api.Charger interface
func (wb *Blueprint) Status() (api.ChargeStatus, error) {
return api.StatusNone, api.ErrNotAvailable
}
// Enabled implements the api.Charger interface
func (wb *Blueprint) Enabled() (bool, error) {
return false, api.ErrNotAvailable
}
// Enable implements the api.Charger interface
func (wb *Blueprint) Enable(enable bool) error {
return api.ErrNotAvailable
}
// MaxCurrent implements the api.Charger interface
func (wb *Blueprint) MaxCurrent(current int64) error {
return api.ErrNotAvailable
}
var _ api.Meter = (*Blueprint)(nil)
// CurrentPower implements the api.Meter interface
func (wb *Blueprint) CurrentPower() (float64, error) {
return 0, api.ErrNotAvailable
}
var _ api.ChargeRater = (*Blueprint)(nil)
// ChargedEnergy implements the api.ChargeRater interface
func (wb *Blueprint) ChargedEnergy() (float64, error) {
return 0, api.ErrNotAvailable
}
var _ api.MeterEnergy = (*Blueprint)(nil)
// TotalEnergy implements the api.MeterEnergy interface
func (wb *Blueprint) TotalEnergy() (float64, error) {
return 0, api.ErrNotAvailable
}
var _ api.PhaseCurrents = (*Blueprint)(nil)
// Currents implements the api.PhaseCurrents interface
func (wb *Blueprint) Currents() (float64, float64, float64, error) {
return 0, 0, 0, api.ErrNotAvailable
}
var _ api.Identifier = (*Blueprint)(nil)
// Identify implements the api.Identifier interface
func (wb *Blueprint) Identify() (string, error) {
return "", api.ErrNotAvailable
}
var _ api.PhaseSwitcher = (*Blueprint)(nil)
// Phases1p3p implements the api.PhaseSwitcher interface
func (wb *Blueprint) Phases1p3p(phases int) error {
return api.ErrNotAvailable
}