module

ShellyplugExporter::Gen::Helper::JsonHelper

Class methods

as_f?(value : JSON::Any | Nil) : Float64 | Nil

Shelly firmwares serialize whole numbers without a decimal point, which JSON::Any#as_f? rejects, so accept integers as well.

Source
compact(readings : NamedTuple) : Hash(Symbol, Float64 | Int64)

Drops the readings the plug did not report, so a failed or partial response yields no sample instead of a misleading zero.

Source