Skip to content

Commit 7ad0bcc

Browse files
committed
Add Smappee Infinity
1 parent 1362318 commit 7ad0bcc

File tree

7 files changed

+547
-0
lines changed

7 files changed

+547
-0
lines changed

β€Ž.marketplace/devices/devices.ymlβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,3 +608,13 @@
608608
blueprint_options:
609609
- blueprint: gas_sensors/igd_toc_635
610610
verification_level: verified
611+
612+
- id: smappee_infinity
613+
display_name: Smappee Infinity
614+
description: All-in-one energy management system.
615+
icon: enapter-home
616+
vendor: igd
617+
category: power_meters
618+
blueprint_options:
619+
- blueprint: power_meters/smappee_infinity
620+
verification_level: verified
5.34 KB
Loading

β€Ž.marketplace/vendors/vendors.ymlβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,8 @@
197197
display_name: International Gas Detectors Ltd
198198
icon_url: https://raw.githubusercontent.com/Enapter/marketplace/main/.marketplace/vendors/icons/igd.png
199199
website: https://www.internationalgasdetectors.com
200+
201+
- id: smappee
202+
display_name: Smappee
203+
icon_url: https://raw.githubusercontent.com/Enapter/marketplace/main/.marketplace/vendors/icons/smappee.png
204+
website: https://www.smappee.com/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Smappee Infinity
2+
3+
This [Enapter Device Blueprint](https://go.enapter.com/marketplace-readme) integrates **Smappee Infinity** - Smart energy management solution for any energy need - via [HTTP API](https://go.enapter.com/developers-enapter-http) implemented on [Enapter Virtual UCM](https://go.enapter.com/handbook-vucm).
4+
5+
## Connect to Enapter
6+
7+
- Sign up to Enapter Cloud using [Web](https://cloud.enapter.com/) or mobile app ([iOS](https://apps.apple.com/app/id1388329910), [Android](https://play.google.com/store/apps/details?id=com.enapter&hl=en)).
8+
- Use [Enapter Gateway](https://go.enapter.com/handbook-gateway-setup) to run Virtual UCM.
9+
- Create [Enapter Virtual UCM](https://go.enapter.com/handbook-vucm).
10+
- [Upload](https://go.enapter.com/developers-upload-blueprint) this blueprint to Enapter Virtual UCM.
11+
- Use the `Set Up Connection` command in the Enapter mobile or Web app to set up the Enel JuiceBox 32 communication parameters:
12+
- [Your Client ID](https://go.enapter.com/smappee-devapi-docs);
13+
- [Your Client secret](https://go.enapter.com/smappee-devapi-docs).
14+
- [Your Smappee username](https://go.enapter.com/smappee-devapi-docs).
15+
- [Your Smappee password](https://go.enapter.com/smappee-devapi-docs).
16+
17+
## References
18+
19+
- [Smappee Infinity product page](https://go.enapter.com/smappee-infinity-product)
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
blueprint_spec: device/1.0
2+
display_name: Smappee Infinity
3+
description: Smart energy monitoring system
4+
icon: enapter-home
5+
vendor: smappee
6+
license: MIT
7+
author: enapter
8+
contributors:
9+
- anataty
10+
support:
11+
url: https://go.enapter.com/enapter-blueprint-support
12+
13+
verification_level: verified
14+
15+
communication_module:
16+
product: ENP-VIRTUAL
17+
lua:
18+
dir: smappee_lua
19+
amalg_mode: nodebug
20+
dependencies:
21+
- enapter-ucm
22+
23+
properties:
24+
vendor:
25+
type: string
26+
display_name: Vendor
27+
model:
28+
type: string
29+
display_name: Model
30+
31+
telemetry:
32+
status:
33+
type: string
34+
display_name: State
35+
enum:
36+
- ok
37+
- warning
38+
consumption_power:
39+
type: float
40+
unit: Wh
41+
display_name: Consumption
42+
voltage1:
43+
type: float
44+
unit: V
45+
display_name: Voltage Line 1
46+
voltage2:
47+
type: float
48+
unit: V
49+
display_name: Voltage Line 2
50+
voltage3:
51+
type: float
52+
unit: V
53+
display_name: Voltage Line 3
54+
current1_PHASEA:
55+
type: float
56+
unit: A
57+
display_name: Main Load Current phase A
58+
current1_PHASEB:
59+
type: float
60+
unit: A
61+
display_name: Main Load Current phase B
62+
current1_PHASEC:
63+
type: float
64+
unit: A
65+
display_name: Main Load Current phase C
66+
active1_PHASEA:
67+
type: float
68+
unit: W
69+
display_name: Main Load active power phase A
70+
active1_PHASEB:
71+
type: float
72+
unit: W
73+
display_name: Main Load active power phase B
74+
active1_PHASEC:
75+
type: float
76+
unit: W
77+
display_name: Main Load active power phase C
78+
current2_PHASEA:
79+
type: float
80+
unit: A
81+
display_name: Zone Carport/Cafe Current phase A
82+
current2_PHASEB:
83+
type: float
84+
unit: A
85+
display_name: Zone Carport/Cafe Current phase B
86+
current2_PHASEC:
87+
type: float
88+
unit: A
89+
display_name: Zone Carport/Cafe Current phase C
90+
active2_PHASEA:
91+
type: float
92+
unit: W
93+
display_name: Zone Carport/Cafe active power phase A
94+
active2_PHASEB:
95+
type: float
96+
unit: W
97+
display_name: Zone Carport/Cafe active power phase B
98+
active2_PHASEC:
99+
type: float
100+
unit: W
101+
display_name: Zone Carport/Cafe active power phase C
102+
current3_PHASEA:
103+
type: float
104+
unit: A
105+
display_name: Zone Hotel / Office Current phase A
106+
current3_PHASEB:
107+
type: float
108+
unit: A
109+
display_name: Zone Hotel / Office Current phase B
110+
current3_PHASEC:
111+
type: float
112+
unit: A
113+
display_name: Zone Hotel / Office Current phase C
114+
active3_PHASEA:
115+
type: float
116+
unit: W
117+
display_name: Zone Hotel / Office active power phase A
118+
active3_PHASEB:
119+
type: float
120+
unit: W
121+
display_name: Zone Hotel / Office active power phase B
122+
active3_PHASEC:
123+
type: float
124+
unit: W
125+
display_name: Zone Hotel / Office active power phase C
126+
127+
alerts:
128+
no_data:
129+
severity: warning
130+
display_name: No data from device
131+
description: >
132+
Can't read data from Smappee Infinity.
133+
Please check connection parameters.
134+
connection_error:
135+
severity: warning
136+
display_name: Connection Error
137+
description: >
138+
Please use "Set Up Connection" command to set up your
139+
Smappee account configuration.
140+
no_service_location_name:
141+
severity: warning
142+
display_name: No service location name
143+
description: >
144+
Please use "Set Up Connection" command to set up your
145+
Smappee service location name.
146+
invalid_service_location_id:
147+
severity: warning
148+
display_name: Incorrect service location name
149+
description: >
150+
Please double check Smappee service location name.
151+
152+
command_groups:
153+
connection:
154+
display_name: Connection
155+
156+
commands:
157+
# TODO: mark commands containing secrets
158+
write_configuration:
159+
display_name: Set Up Connection
160+
description: Set your Smappee account parameters
161+
group: connection
162+
populate_values_command: read_configuration
163+
ui:
164+
icon: file-document-edit-outline
165+
arguments:
166+
username:
167+
display_name: Smappee username
168+
type: string
169+
required: true
170+
password:
171+
display_name: Smappee password
172+
type: string
173+
required: true
174+
client_id:
175+
display_name: Smappee Client ID
176+
type: string
177+
required: true
178+
client_secret:
179+
display_name: Smappee Client Secret
180+
type: string
181+
required: true
182+
service_location_name:
183+
display_name: Smappee Service Location name
184+
type: string
185+
required: false
186+
read_configuration:
187+
display_name: Read Connection Parameters
188+
group: connection
189+
ui:
190+
icon: file-check-outline
191+
192+
.cloud:
193+
mobile_main_chart: consumption_power
194+
mobile_charts:
195+
- consumption_power
196+
- active_power
197+
- current
198+
- voltage1
199+
- voltage2
200+
- voltage3
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
local config = require('enapter.ucm.config')
2+
local smappee = require('smappee')
3+
4+
-- Configuration variables must be also defined
5+
-- in `write_configuration` command arguments in manifest.yml
6+
USERNAME = 'username'
7+
PASSWORD = 'password'
8+
CLIENT_SECRET = 'client_secret'
9+
CLIENT_ID = 'client_id'
10+
SERVICE_LOCATION_NAME = 'service_location_name'
11+
12+
-- Initiate device firmware. Called at the end of the file.
13+
function main()
14+
scheduler.add(30000, send_properties)
15+
scheduler.add(2000, send_telemetry)
16+
17+
config.init({
18+
[USERNAME] = { type = 'string', required = true },
19+
[PASSWORD] = { type = 'string', required = true },
20+
[CLIENT_SECRET] = { type = 'string', required = true },
21+
[CLIENT_ID] = { type = 'string', required = true },
22+
[SERVICE_LOCATION_NAME] = { type = 'string', required = false },
23+
})
24+
end
25+
26+
function send_properties()
27+
enapter.send_properties({
28+
vendor = 'Smappee',
29+
model = 'Infinity',
30+
})
31+
end
32+
33+
function send_telemetry()
34+
local conn, err = connect_smappee()
35+
if err then
36+
enapter.log("Can't connect to Smappee: " .. err)
37+
enapter.send_telemetry({
38+
status = 'warning',
39+
alerts = { 'connection_error' },
40+
})
41+
return
42+
else
43+
local location_name = config.read(SERVICE_LOCATION_NAME)
44+
if tostring(location_name) ~= '' then
45+
conn:set_service_location_id(location_name, conn:get_service_locations())
46+
47+
local telemetry = conn:get_electricity_consumption((os.time() - 600) * 1000, os.time() * 1000)
48+
if next(telemetry) then
49+
if telemetry['consumption_power'] then
50+
telemetry['status'] = 'ok'
51+
telemetry['alerts'] = {}
52+
enapter.send_telemetry(telemetry)
53+
else
54+
telemetry['status'] = 'warning'
55+
enapter.send_telemetry(telemetry)
56+
end
57+
else
58+
enapter.send_telemetry({ status = 'warning', alerts = { 'no_data' } })
59+
end
60+
else
61+
enapter.send_telemetry({ status = 'warning', alerts = { 'no_service_location_name' } })
62+
end
63+
end
64+
end
65+
66+
-- holds global Smappee connection
67+
local conn
68+
69+
function connect_smappee()
70+
if conn and conn.expires ~= nil then
71+
if conn.expires <= os.time() then
72+
conn.access_token, conn.new_token, conn.expires = conn:refresh_token()
73+
end
74+
75+
return conn, nil
76+
end
77+
78+
local values, err = config.read_all()
79+
if err then
80+
enapter.log('cannot read config: ' .. tostring(err), 'error')
81+
return nil, 'cannot_read_config'
82+
else
83+
local client_secret, client_id = values[CLIENT_SECRET], values[CLIENT_ID]
84+
local username, password = values[USERNAME], values[PASSWORD]
85+
86+
if not client_secret or not client_id or not username or not password then
87+
return nil, 'not_configured'
88+
else
89+
conn = smappee.new(username, password, client_secret, client_id)
90+
if conn ~= nil then
91+
return conn, nil
92+
else
93+
return nil, 'no_connection'
94+
end
95+
end
96+
end
97+
end
98+
99+
main()

0 commit comments

Comments
Β (0)