jpeletier / koolnova2mqtt

MIT License
5 stars 3 forks source link

Home Assistant Integration #3

Open sinseman44 opened 1 year ago

sinseman44 commented 1 year ago

Hi,

I would like to integrate koolnova2mqtt (v1.0.0) to my Home Assistant (2023.10.5) and I try to integrate your github repository in custom repositories of HACS. It fails with this error message : <integration jpeletier/koolnova2mqtt> Repository structure for v1.0.0 is not compliant

How to integrate your repo in Home Assistant ? Can you create a new version with HACS compliant structure ?

Thanks Vincent

julien-lebot commented 9 months ago

I created a custom addon to integrate it with Home Assistant. Here are my files:

config.json

{
    "name": "koolnova2mqtt",
    "version": "1.0.0",
    "slug": "koolnova2mqtt",
    "description": "Koolnova to mqtt bridge",
    "url": "https://github.com/jpeletier/koolnova2mqtt",
    "arch": ["aarch64"],
    "startup": "application",
    "panel_icon": "mdi:air-conditioner",
    "panel_admin": false,
    "boot": "auto",
    "legacy": true,
    "stage": "experimental",
    "init": false,
    "options": {
        "hassPrefix": "homeassistant",
        "modbusPort": "/dev/ttyUSB0",
        "modbusRate": 9600,
        "modbusDataBits": 8,
        "modbusParity": "E",
        "modbusSlaveIds": "49",
        "modbusSlaveNames": null,
        "modbusStopBits": 1,
        "mqttPassword": null,
        "mqttUser": null,
        "mqttPrefix": "koolnova2mqtt",
        "mqttServer": "tcp://core-mosquitto:1883"
    },
    "schema":  {
        "hassPrefix": "str?",
        "modbusPort": "device(subsystem=tty)?",
        "modbusRate": "int?",
        "modbusDataBits": "int?",
        "modbusParity": "list(N|E|O)?",
        "modbusSlaveIds": "str?",
        "modbusSlaveNames": "str?",
        "modbusStopBits": "int?",
        "mqttPassword": "password?",
        "mqttUser": "str?",
        "mqttPrefix": "str?",
        "mqttServer": "url?"
    },
    "map": ["config:rw"],
    "uart": true,
    "services": ["mqtt:need"]
}

Dockerfile

ARG BUILD_FROM
FROM $BUILD_FROM

RUN mkdir /app
RUN wget https://github.com/jpeletier/koolnova2mqtt/releases/download/v1.0.0/koolnova2mqtt_linux_arm -O /app/koolnova2mqtt
RUN chmod a+x /app/koolnova2mqtt
COPY run.sh /
RUN chmod a+x /run.sh

CMD [ "/run.sh" ]

run.sh

#!/usr/bin/with-contenv bashio

MODBUS_PARITY=$(bashio::config 'modbusParity')
/app/koolnova2mqtt --hassPrefix $(bashio::config 'hassPrefix') --modbusDataBits $(bashio::config 'modbusDataBits') --modbusParity $(eval echo $MODBUS_PARITY) --modbusPort $(bashio::config 'modbusPort') --modbusRate $(bashio::config 'modbusRate') --modbusSlaveIDs $(bashio::config 'modbusSlaveIds') --modbusSlaveNames $(bashio::config 'modbusSlaveNames') --modbusStopBits $(bashio::config 'modbusStopBits') --password $(bashio::config 'mqttPassword') --prefix $(bashio::config 'mqttPrefix') --server $(bashio::config 'mqttServer') --username $(bashio::config 'mqttUser')

Just create a folder under /addons and put those 3 files there. Home Assistant should detect the new local addon and you should be able to install it. Then you only need to configure it like any other addons.

julien-lebot commented 9 months ago

Note that the latest release 1.0.0 doesn't include the fix for the measurement unit, so you'll have a warning on Home Assistant startup but that doesn't affect the addons operation.