/
46_TeslaPowerwall2AC.pm
230 lines (208 loc) · 6.78 KB
/
46_TeslaPowerwall2AC.pm
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
###############################################################################
#
# Developed with Kate
#
# (c) 2017-2021 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
# All rights reserved
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# $Id$
#
###############################################################################
##
##
## Das JSON Modul immer in einem eval aufrufen
# $data = eval{decode_json($data)};
#
# if($@){
# Log3($SELF, 2, "$TYPE ($SELF) - error while request: $@");
#
# readingsSingleUpdate($hash, "state", "error", 1);
#
# return;
# }
#
#######
#######
# URLs zum Abrufen diverser Daten
# https://<ip-Powerwall>/api/system_status/soe
# https://<ip-Powerwall>/api/meters/aggregates
# https://<ip-Powerwall>/api/site_info
# https://<ip-Powerwall>/api/sitemaster
# https://<ip-Powerwall>/api/powerwalls
# https://<ip-Powerwall>/api/networks
# https://<ip-Powerwall>/api/system/networks
# https://<ip-Powerwall>/api/operation
#
##
##
package FHEM::TeslaPowerwall2AC;
use strict;
use warnings;
use FHEM::Meta;
use GPUtils qw(GP_Export);
require FHEM::Devices::Tesla::Powerwall;
#-- Run before package compilation
BEGIN {
#-- Export to main context with different name
GP_Export(
qw(
Initialize
)
);
}
sub Initialize {
my $hash = shift;
$hash->{GetFn} = \&FHEM::Devices::Tesla::Powerwall::Get;
$hash->{SetFn} = \&FHEM::Devices::Tesla::Powerwall::Set;
$hash->{DefFn} = \&FHEM::Devices::Tesla::Powerwall::Define;
$hash->{UndefFn} = \&FHEM::Devices::Tesla::Powerwall::Undef;
$hash->{NotifyFn} = \&FHEM::Devices::Tesla::Powerwall::Notify;
$hash->{RenameFn} = \&FHEM::Devices::Tesla::Powerwall::Rename;
$hash->{AttrFn} = \&FHEM::Devices::Tesla::Powerwall::Attr;
$hash->{AttrList} =
'interval '
. 'disable:1 '
. 'devel:1 '
. 'emailaddr '
. $::readingFnAttributes;
$hash->{parseParams} = 1;
return FHEM::Meta::InitMod( __FILE__, $hash );
}
1;
=pod
=item device
=item summary Modul to retrieves data from a Tesla Powerwall 2AC
=item summary_DE
=begin html
<a name="TeslaPowerwall2AC"></a>
<h3>Tesla Powerwall 2 AC</h3>
<ul>
<u><b>TeslaPowerwall2AC - Retrieves data from a Tesla Powerwall 2AC System</b></u>
<br>
With this module it is possible to read the data from a Tesla Powerwall 2AC and to set it as reading.
<br><br>
<a name="TeslaPowerwall2ACdefine"></a>
<b>Define</b>
<ul><br>
<code>define <name> TeslaPowerwall2AC <HOST></code>
<br><br>
Example:
<ul><br>
<code>define myPowerWall TeslaPowerwall2AC 192.168.1.34</code><br>
</ul>
<br>
This statement creates a Device with the name myPowerWall and the Host IP 192.168.1.34.<br>
After the device has been created, the current data of Powerwall is automatically read from the device.
</ul>
<br><br>
<a name="TeslaPowerwall2ACreadings"></a>
<b>Readings</b>
<ul>
<li>actionQueue - information about the entries in the action queue</li>
<li>aggregates-* - readings of the /api/meters/aggregates response</li>
<li>batteryLevel - battery level in percent</li>
<li>batteryPower - battery capacity in kWh</li>
<li>powerwalls-* - readings of the /api/powerwalls response</li>
<li>registration-* - readings of the /api/customer/registration response</li>
<li>siteinfo-* - readings of the /api/site_info response</li>
<li>sitemaster-* - readings of the /api/sitemaster response</li>
<li>state - information about internel modul processes</li>
<li>status-* - readings of the /api/status response</li>
<li>statussoe-* - readings of the /api/system_status/soe response</li>
<li>setPassword - write password encrypted to password file</li>
<li>removePassword - remove password from password file</li>
</ul>
<a name="TeslaPowerwall2ACget"></a>
<b>get</b>
<ul>
<li>aggregates - fetch data from url path /api/meters/aggregates</li>
<li>powerwalls - fetch data from url path /api/powerwalls</li>
<li>registration - fetch data from url path /api/customer/registration</li>
<li>siteinfo - fetch data from url path /api/site_info</li>
<li>sitemaster - fetch data from url path /api/sitemaster</li>
<li>status - fetch data from url path /api/status</li>
<li>statussoe - fetch data from url path /api/system_status/soe</li>
</ul>
<br><br>
<a name="TeslaPowerwall2ACset"></a>
<b>set</b>
<ul>
<li>removePassword - remove password from password file</li>
<li>setPassword - save password in passswordfile ATTANTION!!! text must begin with pass= (Example: pass=meinpassword)</li>
</ul>
<br><br>
<a name="TeslaPowerwall2ACattribute"></a>
<b>Attribute</b>
<ul>
<li>interval - interval in seconds for automatically fetch data (default 300)</li>
<li>emailaddr - emailadress to get cookie token</li>
</ul>
</ul>
=end html
=begin html_DE
<a name="TeslaPowerwall2AC"></a>
<h3>Tesla Powerwall 2 AC</h3>
=end html_DE
=for :application/json;q=META.json 46_TeslaPowerwall2AC.pm
{
"abstract": "Modul to retrieves data from a Tesla Powerwall 2AC",
"x_lang": {
"de": {
"abstract": ""
}
},
"keywords": [
"fhem-mod-device",
"fhem-core",
"Power",
"Tesla",
"AC",
"Powerwall",
"Control"
],
"release_status": "stable",
"license": "GPL_2",
"version": "v2.0.0",
"author": [
"Marko Oldenburg <leongaultier@gmail.com>"
],
"x_fhem_maintainer": [
"CoolTux"
],
"x_fhem_maintainer_github": [
"LeonGaultier"
],
"prereqs": {
"runtime": {
"requires": {
"FHEM": 5.00918799,
"perl": 5.016,
"Meta": 0,
"JSON": 0,
"Date::Parse": 0
},
"recommends": {
},
"suggests": {
}
}
}
}
=end :application/json;q=META.json
=cut