Meter Class¶
The Meter class is the base class for V3Meter and V4Meter. It is never called directly. It encapsulates the next data to send, the last data read, and all of the possible serial commands.
-
class
ekmmeters.Meter(meter_address='000000000000')¶ Abstract base class. Encapuslates serial operations and buffers.
-
initParamLists()¶ Initialize all short in-object send buffers to zero.
-
getReadBuffer()¶ Required override to fetch the read serial block.
Returns: Every supported field (A or A+B, includes all fields) Return type: SerialBlock
-
request(send_terminator=False)¶ Required override, issue A or A+B reads and square up buffers.
Parameters: send_terminator (bool) – Send termination string at end of read. Returns: True on successful read. Return type: bool
-
serialPostEnd()¶ Required override, issue termination string to port.
-
setMaxDemandPeriod(period, password='00000000')¶ Serial call to set max demand period.
Parameters: - period (int) – : as int.
- password (str) – Optional password.
Returns: True on completion with ACK.
Return type: bool
-
setMaxDemandResetInterval(interval, password='00000000')¶ Serial call to set max demand interval.
Parameters: - interval (int) –
MaxDemandResetIntervalas int. - password (str) – Optional password.
Returns: True on completion with ACK.
Return type: bool
- interval (int) –
-
setMeterPassword(new_pwd, pwd='00000000')¶ Serial Call to set meter password. USE WITH CAUTION.
Parameters: - new_pwd (str) – 8 digit numeric password to set
- pwd (str) – Old 8 digit numeric password.
Returns: True on completion with ACK.
Return type: bool
-
jsonRender(def_buf)¶ Translate the passed serial block into string only JSON.
Parameters: def_buf (SerialBlock) – Any SerialBlockobject.Returns: JSON rendering of meter record. Return type: str
-
splitEkmDate(dateint)¶ Break out a date from Omnimeter read.
Note a corrupt date will raise an exception when you convert it to int to hand to this method.
Parameters: dateint (int) – Omnimeter datetime as int. Returns: Named tuple which breaks out as followws: yy Last 2 digits of year mm Month 1-12 dd Day 1-31 weekday Zero based weekday hh Hour 0-23 minutes Minutes 0-59 ss Seconds 0-59 Return type: tuple
-
getMeterAddress()¶ Getter for meter object 12 character address.
Returns: 12 character address on front of meter Return type: str
-
registerObserver(observer)¶ Place an observer in the meter update() chain.
Parameters: observer (MeterObserver) – Subclassed MeterObserver.
-
unregisterObserver(observer)¶ Remove an observer from the meter update() chain.
Parameters: observer (MeterObserver) – Subclassed MeterObserver.
-
getSchedulesBuffer(period_group)¶ Return the requested tariff schedule
SerialBlockfor meter.Parameters: period_group (int) – A ReadSchedulesvalue.Returns: The requested tariff schedules for meter. Return type: SerialBlock
-
getHolidayDatesBuffer()¶ Get the meter
SerialBlockfor holiday dates.
-
getMonthsBuffer(direction)¶ Get the months tariff SerialBlock for meter.
Parameters: direction (int) – A ReadMonthsvalue.Returns: Requested months tariffs buffer. Return type: SerialBlock
-
setMaxDemandResetNow(password='00000000')¶ Serial call zero max demand (Dash Now button)
Parameters: password (str) – Optional password Returns: True on completion with ACK. Return type: bool
-
setTime(yy, mm, dd, hh, minutes, ss, password='00000000')¶ Serial set time with day of week calculation.
Parameters: - yy (int) – Last two digits of year.
- mm (int) – Month 1-12.
- dd (int) – Day 1-31
- hh (int) – Hour 0 to 23.
- minutes (int) – Minutes 0 to 59.
- ss (int) – Seconds 0 to 59.
- password (str) – Optional password.
Returns: True on completion and ACK.
Return type: bool
-
setCTRatio(new_ct, password='00000000')¶ Serial call to set CT ratio for attached inductive pickup.
Parameters: - new_ct (int) – A
CTRatiovalue, a legal amperage setting. - password (str) – Optional password.
Returns: True on completion with ACK.
Return type: bool
- new_ct (int) – A
-
assignScheduleTariff(schedule, tariff, hour, minute, rate)¶ Assign one schedule tariff period to meter bufffer.
Parameters: Returns: True on completed assignment.
Return type: bool
-
setScheduleTariffs(cmd_dict=None, password='00000000')¶ Serial call to set tariff periodds for a schedule.
Parameters: - cmd_dict (dict) – Optional passed command dictionary.
- password (str) – Optional password.
Returns: True on completion and ACK.
Return type: bool
-
assignSeasonSchedule(season, month, day, schedule)¶ Define a single season and assign a schedule
Parameters: Returns: True on completion and ACK.
Return type: bool
-
setSeasonSchedules(cmd_dict=None, password='00000000')¶ Serial command to set seasons table.
If no dictionary is passed, the meter object buffer is used.
Parameters: - cmd_dict (dict) – Optional dictionary of season schedules.
- password (str) – Optional password
Returns: True on completion and ACK.
Return type: bool
-
assignHolidayDate(holiday, month, day)¶ Set a singe holiday day and month in object buffer.
There is no class style enum for holidays.
Parameters: - holiday (int) – 0-19 or range(Extents.Holidays).
- month (int) – Month 1-12.
- day (int) – Day 1-31
Returns: True on completion.
Return type: bool
-
setHolidayDates(cmd_dict=None, password='00000000')¶ Serial call to set holiday list.
If a buffer dictionary is not supplied, the method will use the class object buffer populated with assignHolidayDate.
Parameters: - cmd_dict (dict) – Optional dictionary of holidays.
- password (str) – Optional password.
Returns: True on completion.
Return type: bool
-
setWeekendHolidaySchedules(new_wknd, new_hldy, password='00000000')¶ Serial call to set weekend and holiday
Schedules.Parameters: Returns: True on completion and ACK.
Return type: bool
-
readScheduleTariffs(tableset)¶ Serial call to read schedule tariffs buffer
Parameters: tableset (int) – ReadSchedulesbuffer to return.Returns: True on completion and ACK. Return type: bool
-
extractScheduleTariff(schedule, tariff)¶ Read a single schedule tariff from meter object buffer.
Parameters: Returns: True on completion.
Return type: bool
-
readMonthTariffs(months_type)¶ Serial call to read month tariffs block into meter object buffer.
Parameters: months_type (int) – A ReadMonthsvalue.Returns: True on completion. Return type: bool
-
extractMonthTariff(month)¶ Extract the tariff for a single month from the meter object buffer.
Parameters: month (int) – A Monthsvalue or range(Extents.Months).Returns: The eight tariff period totals for month. The return tuple breaks out as follows: kWh_Tariff_1 kWh for tariff period 1 over month. kWh_Tariff_2 kWh for tariff period 2 over month kWh_Tariff_3 kWh for tariff period 3 over month kWh_Tariff_4 kWh for tariff period 4 over month kWh_Tot Total kWh over requested month Rev_kWh_Tariff_1 Rev kWh for tariff period 1 over month Rev_kWh_Tariff_3 Rev kWh for tariff period 2 over month Rev_kWh_Tariff_3 Rev kWh for tariff period 3 over month Rev_kWh_Tariff_4 Rev kWh for tariff period 4 over month Rev_kWh_Tot Total Rev kWh over requested month Return type: tuple
-
readHolidayDates()¶ Serial call to read holiday dates into meter object buffer.
Returns: True on completion. Return type: bool
-
extractHolidayDate(setting_holiday)¶ Read a single holiday date from meter buffer.
Parameters: setting_holiday (int) – Holiday from 0-19 or in range(Extents.Holidays) Returns: Holiday tuple, elements are strings. Holiday Holiday 0-19 as string Day Day 1-31 as string Month Monty 1-12 as string Return type: tuple
-
extractHolidayWeekendSchedules()¶ extract holiday and weekend
Schedulefrom meter object buffer.Returns: Holiday and weekend Schedulevalues, as strings.Holiday Scheduleas stringWeekend Scheduleas stringReturn type: tuple
-
readSettings()¶ Recommended call to read all meter settings at once.
Returns: True if all subsequent serial calls completed with ACK. Return type: bool
-
readCmdMsg()¶ Getter for message set by last command.
Returns: Last set message, if exists. Return type: str
-
clearCmdMsg()¶ Zero out the command message result hint string
-
SerialBlock Class¶
Serial block is a simple subclass of OrderedDictionary. The subclassing is primarily cautionary.
-
class
ekmmeters.SerialBlock¶ Simple subclass of collections.OrderedDict.
Key is a
Fieldand value isMeterDataindexed array.The
MeterDatapoints to one of the following:SizeValue Integer. Equivalent to struct char[SizeValue] TypeValue A FieldTypevalue.ScaleValue A ScaleTypevalue.StringValue Printable, scaled and formatted content. NativeValue Converted, scaled value of field native type. CalculatedFlag If True, not part of serial read, calculated. EventFlag If True, state value