Help building app

Hi all,

I have a android built in wall display with led lights, gpo ports, 2relais and temperature and humidity sensor.

I do have the API documents, but don’t know how to build an app for it.

It’s also possible to connect via MQTT.

Is there someone who could help me?

You can request an app here:

Do you have any knowledge about MQTT?

Thanks, i will repost it there. I am complete new to mqtt. Did read a lot but never really did something with that.

What’s the product name?

Can you share these?

cid=client_id

prefix=homeassistant

base=client_id

static void init_topics(const char* base)

{

// 灯光

snprintf(light_state_topic, sizeof(light_state_topic), "%s/light/status", base);

snprintf(light_command_topic, sizeof(light_command_topic), "%s/light/switch", base);

snprintf(brightness_state_topic, sizeof(brightness_state_topic), "%s/brightness/status", base);

snprintf(brightness_command_topic, sizeof(brightness_command_topic), "%s/brightness/set", base);

snprintf(rgb_state_topic, sizeof(rgb_state_topic), "%s/rgb/status", base);

snprintf(rgb_command_topic, sizeof(rgb_command_topic), "%s/rgb/set", base);

// 传感器

snprintf(temp_state_topic, sizeof(temp_state_topic), "%s/sensors/temperature", base);

snprintf(hum_state_topic, sizeof(hum_state_topic), "%s/sensors/humidity", base);

// 开关

snprintf(switch1_state_topic, sizeof(switch1_state_topic), "%s/switch1/status", base);

snprintf(switch1_command_topic, sizeof(switch1_command_topic), "%s/switch1/set", base);

snprintf(switch2_state_topic, sizeof(switch2_state_topic), "%s/switch2/status", base);

snprintf(switch2_command_topic, sizeof(switch2_command_topic), "%s/switch2/set", base);

}

// ========= ③ 统一发布 5 个实体的 Discovery =========

static void publish_ha_discovery(const char* cid, const char* prefix /*通常为"homeassistant"*/) {

char topic\[256\];

char payload\[1024\];

char dev\[256\];

make_device_json(dev, sizeof(dev), cid);

printf(“------%s------\n”,prefix);

// ------- light (支持 开关/亮度/RGB) -------

snprintf(topic, sizeof(topic), "%s/light/%s_rgb1/config", prefix, cid);

snprintf(payload, sizeof(payload),

    "{"

      "\\"name\\":\\"%s RGB\\","

      "\\"unique_id\\":\\"%s_rgb1\\","

      "\\"command_topic\\":\\"%s\\","

      "\\"state_topic\\":\\"%s\\","

      "\\"state_value_template\\":\\"{{ value_json.state }}\\","

      "\\"brightness_command_topic\\":\\"%s\\","

      "\\"brightness_state_topic\\":\\"%s\\","

      "\\"brightness_value_template\\":\\"{{ value_json.brightness }}\\","

      "\\"rgb_command_topic\\":\\"%s\\","

      "\\"rgb_state_topic\\":\\"%s\\","

      "\\"rgb_value_template\\":\\"{{ value_json.rgb\[0\] }},{{ value_json.rgb\[1\] }},{{ value_json.rgb\[2\] }}\\","

      "\\"payload_on\\":\\"ON\\","

      "\\"payload_off\\":\\"OFF\\","

      "%s"

    "}",

    cid, cid,

    light_command_topic, light_state_topic,

    brightness_command_topic, brightness_state_topic,

    rgb_command_topic, rgb_state_topic,

    dev

);

publish_config_retained(topic, payload);

// ------- switch1 -------

snprintf(topic, sizeof(topic), "%s/switch/%s_switch1/config", prefix, cid);

snprintf(payload, sizeof(payload),

    "{"

      "\\"name\\":\\"%s Switch1\\","

      "\\"unique_id\\":\\"%s_switch1\\","

      "\\"command_topic\\":\\"%s\\","

      "\\"state_topic\\":\\"%s\\","

      "\\"value_template\\":\\"{{ value_json.state }}\\","

      "\\"payload_on\\":\\"ON\\","

      "\\"payload_off\\":\\"OFF\\","

      "%s"

    "}",

    cid, cid,

    switch1_command_topic, switch1_state_topic,

    dev

);

publish_config_retained(topic, payload);

// ------- switch2 -------

snprintf(topic, sizeof(topic), "%s/switch/%s_switch2/config", prefix, cid);

snprintf(payload, sizeof(payload),

    "{"

      "\\"name\\":\\"%s Switch2\\","

      "\\"unique_id\\":\\"%s_switch2\\","

      "\\"command_topic\\":\\"%s\\","

      "\\"state_topic\\":\\"%s\\","

      "\\"value_template\\":\\"{{ value_json.state }}\\","

      "\\"payload_on\\":\\"ON\\","

      "\\"payload_off\\":\\"OFF\\","

      "%s"

    "}",

    cid, cid,

    switch2_command_topic, switch2_state_topic,

    dev

);

publish_config_retained(topic, payload);

// ------- temperature sensor -------

snprintf(topic, sizeof(topic), "%s/sensor/%s_temperature/config", prefix, cid);

snprintf(payload, sizeof(payload),

    "{"

      "\\"name\\":\\"%s Temperature\\","

      "\\"unique_id\\":\\"%s_temperature\\","

      "\\"state_topic\\":\\"%s\\","

      "\\"value_template\\":\\"{{ value_json.temperature }}\\","

      "\\"unit_of_measurement\\":\\"°C\\","

      "\\"device_class\\":\\"temperature\\","

      "\\"state_class\\":\\"measurement\\","

      "%s"

    "}",

    cid, cid,

    temp_state_topic,

    dev

);

publish_config_retained(topic, payload);

// ------- humidity sensor -------

snprintf(topic, sizeof(topic), "%s/sensor/%s_humidity/config", prefix, cid);

snprintf(payload, sizeof(payload),

    "{"

      "\\"name\\":\\"%s Humidity\\","

      "\\"unique_id\\":\\"%s_humidity\\","

      "\\"state_topic\\":\\"%s\\","

      "\\"value_template\\":\\"{{ value_json.humidity }}\\","

      "\\"unit_of_measurement\\":\\"%%\\","

      "\\"device_class\\":\\"humidity\\","

      "\\"state_class\\":\\"measurement\\","

      "%s"

    "}",

    cid, cid,

    hum_state_topic,

    dev

);

publish_config_retained(topic, payload);

}

The model is rk3576_u also named as smt101

This is al the info i have, hopes that’s enough?

What’s the MQTT broker domain? Maybe it’s in the environment variables? You didn’t mention the domain/base URL of this MQTT broker.

And how do you authenticate? Is the MQTT username the email address of your account there?

Also, what’s the name of the mobile/web app that you control it with?

Can we private message each other here? Maybe thats more easy

1 Like