module ShellyplugExporter::Gen::Helper::JsonHelper

Defined in:

shellyplug_exporter/gen/helper/json_helper.cr

Class Method Summary

Class Method Detail

def self.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.


def self.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.