energomera_hass_mqtt.extra_sensors

Package to provide additional sensors on top of IecToHassSensor.

Classes

PseudoBinarySensor(value, *args, **kwargs)

Represents a binary pseudo-sensor.

PseudoSensor(value, *args, **kwargs)

Represents a pseudo-sensor, i.e. one doesn't exist on meter.

class energomera_hass_mqtt.extra_sensors.PseudoSensor(value, *args, **kwargs)

Bases: IecToHassSensor, Generic[T]

Represents a pseudo-sensor, i.e. one doesn’t exist on meter.

property state_last_will_payload: str | None

Stores the value of the last will payload for the item, i.e. sent by the MQTT broker if the client disconnects uncleanly.

Parameters:

value – Value for last will payload

hass_config_payload()

Returns HASS config payload for the item.

Return type:

Dict[str, str | Collection[str] | Dict[str, str]]

Returns:

HASS config payload

hass_gen_hass_sensor_props(idx)

Generates various properties for the HASS sensor (device and unique IDs, MQTT topic names etc.).

Return type:

None

hass_state_payload(value)

Returns HASS state payload for the item.

Return type:

Dict[str, str]

Returns:

HASS state payload

property iec_item: List[DataSet]

Provides IEC entity associated with the instance.

Returns:

IEC entity

iec_try_value_by_index()

Attempts to pick an item from multi-valued meter’s response (if response_idx is configured in the entry of parameters section being processed).

Return type:

None

async process(setup_only=False)

Processes the entry received from the meter and sends it to HASS over MQTT.

Parameters:

setup_only (bool) – Perform only setup steps for the entiry, such as determining MQTT topics etc., with no payloads sent to MQTT. Used to configure MQTT last will, since it has to be done prior to connecting to MQTT broker, thus no payloads could be sent yet

Return type:

None

class energomera_hass_mqtt.extra_sensors.PseudoBinarySensor(value, *args, **kwargs)

Bases: PseudoSensor[bool]

Represents a binary pseudo-sensor.

hass_config_payload()

Returns HASS config payload for the item.

Return type:

Dict[str, str | Collection[str] | Dict[str, str]]

Returns:

HASS config payload

hass_gen_hass_sensor_props(idx)

Generates various properties for the HASS sensor (device and unique IDs, MQTT topic names etc.).

Return type:

None

hass_state_payload(value)

Returns HASS state payload for the item.

Return type:

Dict[str, str]

Returns:

HASS state payload

property iec_item: List[DataSet]

Provides IEC entity associated with the instance.

Returns:

IEC entity

iec_try_value_by_index()

Attempts to pick an item from multi-valued meter’s response (if response_idx is configured in the entry of parameters section being processed).

Return type:

None

async process(setup_only=False)

Processes the entry received from the meter and sends it to HASS over MQTT.

Parameters:

setup_only (bool) – Perform only setup steps for the entiry, such as determining MQTT topics etc., with no payloads sent to MQTT. Used to configure MQTT last will, since it has to be done prior to connecting to MQTT broker, thus no payloads could be sent yet

Return type:

None

property state_last_will_payload: str | None

Stores the value of the last will payload for the item, i.e. sent by the MQTT broker if the client disconnects uncleanly.

Parameters:

value – Value for last will payload