haco/search/search_index.json

1 line
9.8 KiB
JSON
Raw Normal View History

2026-05-08 09:49:50 +01:00
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"],"fields":{"title":{"boost":1000.0},"text":{"boost":1.0},"tags":{"boost":1000000.0}}},"docs":[{"location":"","title":"Home","text":"<p>How Do I Get Started?</p> <p>See the Quick Start section.</p>"},{"location":"#haco-home-assistant-control-objects","title":"<code>haco</code> Home Assistant Control Objects","text":"<p><code>haco</code> is a to greatly simplify the process of exposing Home Assistant controls (e.g. Pull-down Lists, Number Sliders, Sensors, etc.) from a device - and handling the communication between both sides.</p> <p>While the current implementation is in Python, the capability definitions for controls are designed to be shared across different languages. Support for additional languages (namely native support for Tasmota Berry) is planned.</p>"},{"location":"#why-mqtt","title":"Why MQTT?","text":"<p>You might wonder why we use MQTT instead of directly using Home Assistant's APIs. The reason is flexibility: using MQTT allows <code>haco</code> to target any device or environment that has an MQTT client, not just those that can easily make HTTP requests or run a full HA integration. This makes it ideal for lightweight embedded systems and cross-platform utility.</p>"},{"location":"#why-would-i-want-such-a-thing","title":"Why Would I Want Such a Thing?","text":"<p>Integrating custom hardware or scripts with Home Assistant often involves a lot of boilerplate: defining MQTT topics, crafting JSON payloads for discovery, and managing state updates. <code>haco</code> handles the heavy lifting, letting you define your device and its controls in clean, declarative Python.</p> <p>If you're building a custom IoT device, a script to monitor your system, or just want a simpler way to bridge your code to Home Assistant, then you might find <code>haco</code> useful.</p>"},{"location":"#how-it-works","title":"How it Works","text":"<p><code>haco</code> uses MQTT to communicate with Home Assistant. It automatically generates the discovery configurations required for Home Assistant to \"see\" your device and its entities. All you need to do is define a <code>Device</code> with some <code>Controls</code> and start the <code>ClientHaco</code>.</p>"},{"location":"#documentation","title":"Documentation","text":"<p>See Documentation</p>"},{"location":"controls/","title":"Controls","text":"<p><code>haco</code> provides several control types that correspond to Home Assistant platforms. Each control typically has a <code>state</code> and a <code>command</code> method that you can override to handle communication.</p>"},{"location":"controls/#supported-controls","title":"Supported Controls","text":""},{"location":"controls/#button","title":"Button","text":"<p>A button in Home Assistant that can be pressed to trigger an action in your script.</p> <ul> <li>Platform: <code>button</code></li> <li>Overridable Methods:<ul> <li><code>command(self, value)</code>: Called when the button is pressed in Home Assistant.</li> </ul> </li> </ul> <pre><code>from haco import Button\n\nclass MyButton(Button):\n def command(self, value):\n print(\"Button was pressed!\")\n</code></pre>"},{"location":"controls/#switch","title":"Switch","text":"<p>A toggle switch that can be turned on or off.</p> <ul> <li>Platform: <code>switch</code></li> <li>Overridable Methods:<ul> <li><code>state(self, value)</code>: Should return the current state of the switch (<code>True</code> for on, <code>False</code> for off).</li> <li><code>command(self, value)</code>: Called when the switch is toggled in Home Assistant.</li> </ul> </li> </ul> <pre><code>from haco import Switch\n\nclass MySwitch(Switch):\n def __init__(self, **kwargs):\n super().__init__(**kwargs)\n self._on = False\n\n def state(self, value):\n return self._on\n\n def command(self, value):\n self._on = value\n print(f\"Switch is now {'ON' if self._on else 'OFF'}\")\n</code></pre>"},{"location":"controls/#sensor","title":"Sensor","text":"<p>A read-only sensor that displays a value