Classes

pydantic settings modbus2mqtt.DeviceConfig.DeviceConfig

The base class for the device configuration. All devices must be derived from this class.

Show JSON schema
{
   "title": "DeviceConfig",
   "description": "The base class for the device configuration. All devices must be derived from this class.",
   "type": "object",
   "properties": {
      "kind": {
         "description": "The device kind, used to load plugins",
         "title": "Kind",
         "type": "string"
      },
      "slave": {
         "description": "The Modbus slave address",
         "title": "Slave",
         "type": "integer"
      },
      "manufacturer": {
         "default": "",
         "description": "The manufacturer of the device",
         "title": "Manufacturer",
         "type": "string"
      },
      "model": {
         "default": "",
         "description": "The model of the device",
         "title": "Model",
         "type": "string"
      },
      "allow_discovery": {
         "default": true,
         "description": "Allow MQTT discovery for the device. Useful for debugging, so Eva will not publish and overwrite discovery",
         "title": "Allow Discovery",
         "type": "boolean"
      }
   },
   "additionalProperties": true,
   "required": [
      "kind",
      "slave"
   ]
}

Config:
  • extra: str = allow

Fields:
field allow_discovery : --is-rst--:py:class:`bool` = True

Allow MQTT discovery for the device. Useful for debugging, so Eva will not publish and overwrite discovery

field kind : --is-rst--:py:class:`str` [Required]

The device kind, used to load plugins

field manufacturer : --is-rst--:py:class:`str` = ''

The manufacturer of the device

field model : --is-rst--:py:class:`str` = ''

The model of the device

field slave : --is-rst--:py:class:`int` [Required]

The Modbus slave address

class Config
build_discovery(item_type, payload=None, slug=None)

Build a discovery message for the entity exposed by the device :type item_type: :param item_type: the component type of the item (e.g. sensor, switch etc. MQTT Discovery)

Parameters:
payload=None

slug=None

The slug of the entity (e.g. switch1, humidity, temperature). If None, the entity will be published to the base topic

Return type:

Dict[str, Any]

Returns:

The discovery configuration : broker, payload and topic

initialize()
model_post_init(_ModelMetaclass__context: Any) None

We need to both initialize private attributes and call the user-defined model_post_init method.

Return type:

None

property action_map : dict[str, Any]

Builds action map for EvaICS

Returns:

Dict[str, Any]

property discovery : dict[str, Any]

Provides the discovery configuration for the device

property eva_id : str

The EVA ID of the device :return:

property input_config : dict[str, Any]

Builds input configuration for EvaICS :return:

property mqtt : MqttConfig

returns the MQTT object for the device

Returns:

MqttConfig

property output_config : list[dict[str, Any]]

Builds basic output configuration for EvaICS Refer to PubSub config

Returns:

A list of dictionaries representing the output configuration

property puller_config : list[dict[str, Any]]

Builds puller configuration for EvaICS

Refer to Modbus master

Must be implemented in the derived class