The base Mongoose-OS library for making Home Assistant compatible devices.
It is not necessary to include this base library into your Mongoose-OS project. Include instead one of the followings:
- hass-mqtt - The Mongoose-OS library for making Home Assistant compatible MQTT devices
- hass-mqtt-discovery - The Mongoose-OS library for making MQTT devices dicoverable in Home Assistant
The following configuration section is added to the conf0.json
file in your Mongoose-OS project.
"hass": {
"publish": {
"on_connect": true,
"interval": 0
},
"toggle_state": {
"on": "ON",
"off": "OFF"
}
}
typedef struct ha_entity_handle {
char *object_id;
char *device_id;
const char *entity_type;
} ha_entity_handle_t;
typedef ha_entity_handle_t* HA_ENTITY_HANDLE;
The entity HANDLE that can be used as parameter in many other API.
Field | |
---|---|
object_id | The object ID of the entity configured in Home Assistant. |
device_id | The device ID. It may be the device.id config value in the mos.yml file. |
entity_type | The entity type. It could be 'binary_sensor' , 'sensor' or 'switch' . |
typedef struct ha_entity_cfg {
const char *object_id;
const char *device_id;
} ha_entity_cfg_t;
Configuration parameters for creating an entity (e.g. a binary sensor, a switch, etc).
Field | |
---|---|
object_id | The object ID of the entity configured in Home Assistant. For exemple, For example, kitchen_temp in case of entity sensor.kitchen_temp . |
device_id | (Optional) The device ID. If NULL , the device.id config in the mos.yml file is used. |
Macro for initializing an empty ha_entity_cfg_t
struct.
/* Example: use the macro to initialize the struct */
ha_entity_cfg_t entity_cfg = HA_NULL_ENTITY_CFG();
Macro for initializing a ha_entity_cfg_t
struct with a given object ID.
/* Example: use the macro to initialize the struct */
ha_entity_cfg_t entity_cfg = HA_ENTITY_CFG("kitchen_temp");
Macro for initializing a ha_entity_cfg_t
struct with a given object ID and device ID.
/* Example: use the macro to initialize the struct */
ha_entity_cfg_t entity_cfg = HA_DEVICE_ENTITY_CFG("kitchen_temp", "MYDEVICE_O1");