@@ -49,9 +49,10 @@ function send_properties()
4949
5050 local properties = {}
5151 properties .model = parse_model (conn :read_u32_enum (30053 ))
52- properties .serial_num = conn :read_u32_fix0 (30057 )
53- properties .fw_ver = parse_firmware_version (conn :read_u32_fix0 (30059 ))
54- properties .rated_power_va = conn :read_u32_fix0 (40185 )
52+ properties .vendor = ' SMA'
53+ properties .serial_number = tostring (conn :read_u32_fix0 (30057 ))
54+ properties .firmware_version = parse_firmware_version (conn :read_u32_fix0 (30059 ))
55+ properties .inverter_nameplate_capacity = conn :read_u32_fix0 (40185 )
5556 properties .country_code = parse_country_code (conn :read_u32_fix0 (40109 ))
5657 if conn_cfg then
5758 properties .address = conn_cfg .address
@@ -72,14 +73,17 @@ function send_realtime_telemetry()
7273 end
7374
7475 local started = os.clock ()
76+ local operating_status = parse_operating_status (conn :read_u32_enum (40029 ))
7577 local telemetry = {
7678 alerts = parse_alerts (conn :read_u32_enum (30213 ), conn :read_u32_enum (30247 )),
77- status = parse_status (conn :read_u32_enum (30201 )),
78- operation_status = parse_operation_status (conn :read_u32_enum (40029 )),
79+ health = parse_health_status (conn :read_u32_enum (30201 )),
80+ operating_status = operating_status ,
81+ status = convert_operating_status_to_status (operating_status ),
7982
8083 dc_voltage = conn :read_s32_fix2 (30771 ),
8184 dc_power = conn :read_s32_fix0 (30773 ),
8285 ac_power = conn :read_s32_fix0 (30775 ),
86+ ac_total_power = conn :read_s32_fix0 (30777 ),
8387 ac_frequency = conn :read_u32_fix2 (30803 ),
8488 }
8589 telemetry .read_time = math.ceil ((os.clock () - started ) * 1000 ) / 1000 -- round
@@ -273,15 +277,15 @@ function parse_model(value)
273277 end
274278end
275279
276- function parse_status (value )
280+ function parse_health_status (value )
277281 if not value then
278282 return
279283 end
280284
281285 if value == 35 then
282286 return ' fault'
283287 elseif value == 303 then
284- return ' off '
288+ return nil
285289 elseif value == 307 then
286290 return ' ok'
287291 elseif value == 455 then
@@ -324,7 +328,7 @@ function parse_grid_relay_closed(value)
324328 end
325329end
326330
327- function parse_operation_status (value )
331+ function parse_operating_status (value )
328332 if not value then
329333 return
330334 end
@@ -336,9 +340,9 @@ function parse_operation_status(value)
336340 elseif value == 1393 then
337341 return ' waiting_pv_voltage'
338342 elseif value == 1467 then
339- return ' start '
343+ return ' starting '
340344 elseif value == 1469 then
341- return ' shutdown '
345+ return ' shutting_down '
342346 elseif value == 1480 then
343347 return ' waiting_utilities'
344348 elseif value == 1795 then
@@ -356,13 +360,33 @@ function parse_operation_status(value)
356360 elseif value == 443 then
357361 return ' const_voltage'
358362 elseif value == 569 then
359- return ' run '
363+ return ' operating '
360364 else
361- enapter .log (' Cannot decode operation status: ' .. tostring (value ), ' error' )
365+ enapter .log (' Cannot decode operating status: ' .. tostring (value ), ' error' )
362366 return tostring (value )
363367 end
364368end
365369
370+ function convert_operating_status_to_status (value )
371+ if not value then
372+ return
373+ end
374+
375+ if value == ' off' or value == ' stop' then
376+ return ' off'
377+ elseif value == ' standby' or value == ' waiting_pv_voltage' or value == ' waiting_utilities' or value == ' bolted' then
378+ return ' standby'
379+ elseif value == ' start' then
380+ return ' starting'
381+ elseif value == ' derating' or value == ' mpp' or value == ' run' then
382+ return ' operating'
383+ elseif value == ' shutdown' then
384+ return ' shutting_down'
385+ elseif value == ' fault' then
386+ return ' fault'
387+ end
388+ end
389+
366390function parse_alerts (presence , message )
367391 if not presence and not message then
368392 return
0 commit comments