Skip to main content

MoaT-KV-HA

% start synopsis % start main

This module is a link between Home Assistant and Moat-KV.

The core of this module is concerned with assembling appropriate configuration for MQTT.

Message transport and translation is performed by a MoaT-Link Gate instance.

% end synopsis

Features

  • set up standard config for Home Assistant in MoaT-KV
  • command-line support to register (or not) devices

% end main

Principle of Operation

Home Assistant talks via MQTT. MoaT-KV has a quite versatile MQTT adapter. Thus we can store Home Assistant's entitiy configuration, plus their state, plus the commands Home Assisant issues to get things to change their state, in MoaT-KV.

MQTT can only transmit binary data. DistHASS thus creates a few codecs that support binary data (translating them to on/off), integers/floats, and JSON.

Thus, bottom to top:

  • Mosquitto on port 51883

    • basic installation, does not need persistence or retained messages
  • MoaT-KV, using Mosquitto as a backbone

    • a special user with conversion rules for JSON etc.
  • DistMQTT

    • retained messages are stored in MoaT-KV
    • transparent channels to forward MQTT messages unmodified, if required
    • anything else is broadcast as a MoaT-KV message
    • uses port 1883
  • Home Assistant, or anything else MQTTish for that matter

    • must use MQTT 3.11

If you have devices that only can use MQTT 3.1, you can teach them to talk directly to Mosquitto, via a transparent range.

Setup

  • Run moat kv ha init -i

  • Add a MoaT-KV user for Home Assistant and set its conv parameter to hassco:

    moat kv auth user param NAME conv hassco
    
  • Start Moat-MQTT with something like this configuration:

    kv:
        server:
            host: '127.0.0.1'
            port: 27586
            auth: "password name=NAME password=PASSWORD"
        topic: [mqtt, msg]
        transparent:
        - [home,ass,event]
        - [home,ass,state]
        retain: [home, ass]
    listeners:
        default:
            max-connections: 500
            type: tcp
        local-tcp:
            bind: 127.0.0.1:1883
        remote-tcp:
            bind: 10.107.3.18:1883
    timeout-disconnect-delay: 2
    plugins: ['auth_anonymous']
    auth:
        allow-anonymous: true
    

    If you have devices that use MQTT directly, modify the transparent list to include your current MQTT prefixes.

  • Modify Home Assistant's MQTT integration to do autodiscovery. If you've set it up via the GUI, the file you need is .storage/core.config_entries. Find the entry with "domain": "mqtt" and modify its data entry to read:

    "data": {
        "broker": "127.0.0.1",
        "discovery": true,
        "discovery_prefix": "home/ass/dyn",
        "port": 1883,
    },
    
  • Run moat kv ha conv.

    This teaches MoaT-KV to auto-convert the Home Assistant data so that everything in MoaT-KV sees binary states as booleans, temperatures are floats, the configuration's JSON is a real data structure, and so on.

    Without this conversion, it's all strings. We don't want that.

  • Restart Home Assistant.

  • Run moat kv ha add light foo bar.

    A new light should show up in the Home Assistant GUI.

    You can try to turn it on, but it will go off by itself a second or two later because there's no device yet.

  • Run moat kv ha state light foo bar True.

    This command changes the state manually.

    In Home Assistant, the light's indicator turns on.

  • Adding an actual device that monitors the light's MoaT-KV command entry / its [MoaT-KV-]MQTT command topic, actually affects the hardware, and changes the state, is your job.

Metadata

Release files for moat-kv-ha 0.5.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moat-kv-ha 0.5.14
File Size Uploaded
moat_kv_ha-0.5.14.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moat-kv-ha 0.5.14
File Interpreter ABI Platform
moat_kv_ha-0.5.14-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / moat_kv_ha-0.5.14.tar.gz

Download URL moat_kv_ha-0.5.14.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d658d4dcd447510e6712954bda5d823c1cd257d7626367c425c1d75de10b9962
BLAKE2b-256 checksum
How to use checksums
467e0d464d804360c1409e74f86256b385d63ee6b885329ca506c7a1186fa585
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / moat_kv_ha-0.5.14-py3-none-any.whl

Download URL moat_kv_ha-0.5.14-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15f00f9e0899e5f707a41ae50a76670152c59c42ddfbe4228cee8632201e122f
BLAKE2b-256 checksum
How to use checksums
7612c9199fc34eb89fdf9a00030185f68b018e7d292765d414de69f4120ad81e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.5.14 This release

2 release files

0.5.12

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page