mirror of
https://github.com/jomjol/AI-on-the-edge-device-docs.git
synced 2025-12-08 12:36:54 +03:00
Deployed 5e61cd1 with MkDocs version: 1.4.2
This commit is contained in:
@@ -1,388 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><link rel="canonical" href="https://jomjol.github.io/AI-on-the-edge-device-docs/Integration-Home-Assistant/" />
|
||||
<link rel="shortcut icon" href="../img/favicon.ico" />
|
||||
<title>Integration into Home Assistant - AI on the Edge Device</title>
|
||||
<link rel="stylesheet" href="../css/theme.css" />
|
||||
<link rel="stylesheet" href="../css/theme_extra.css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
|
||||
|
||||
<script>
|
||||
// Current page data
|
||||
var mkdocs_page_name = "Integration into Home Assistant";
|
||||
var mkdocs_page_input_path = "Integration-Home-Assistant.md";
|
||||
var mkdocs_page_url = "/AI-on-the-edge-device-docs/Integration-Home-Assistant/";
|
||||
</script>
|
||||
|
||||
<script src="../js/jquery-3.6.0.min.js" defer></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="../js/html5shiv.min.js"></script>
|
||||
<![endif]-->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
|
||||
<script>hljs.initHighlightingOnLoad();</script>
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
<a href=".." class="icon icon-home"> AI on the Edge Device
|
||||
</a><div role="search">
|
||||
<form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Home/">Welcome to the AI-on-the-edge-device!</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption"><span class="caption-text">Links</span></p>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="" href="https://jomjol.github.io/AI-on-the-edge-device/index.html">Web Installer/Console</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/issues">Place an Issues</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/discussions">Join a Discussions</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption"><span class="caption-text">Asorted Pages</span></p>
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="../AI-on-the-edge/">Welcome to the AI-on-the-edge-device wiki!</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Addditional-Information/">Addditional Information</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Best-Practice/">Best Practice</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Build-Instructions/">New</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Choosing-the-Model/">Which model should I use?</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Configuration-Parameter-Details/">Configuration Parameter Details</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Configuration/">Configuration</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Correction%20Algorithm/">Correction Algorithm</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Demo-Mode/">Demo Mode</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Error-Codes/">Error Codes</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Error-Debugging/">Error Debugging</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../External-LED/">External LED</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../FAQs/">Frequently Asked Questions</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Frequent%20Reboots/">Frequent reboots</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Gasmeter-Log-Downloader/">Gasmeter Log Downloader</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Graphical-configuration/">Graphical configuration</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Hardware-Compatibility/">Hardware Compatibility</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Install-a-rolling-%28unstable%29-release/">:bangbang: Living on the edge :bangbang:</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Installation/">Installation</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Integrated%20Functions/">Integrated Functions</a>
|
||||
</li>
|
||||
<li class="toctree-l1 current"><a class="reference internal current" href="./">Integration into Home Assistant</a>
|
||||
<ul class="current">
|
||||
<li class="toctree-l2"><a class="reference internal" href="#using-mqtt-automatically-setup-entities-using-homeassistant-mqtt-discovery">Using MQTT (Automatically Setup Entities using Homeassistant MQTT Discovery)</a>
|
||||
<ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#using-mqtt-manually-setup-entities">Using MQTT (Manually Setup Entities)</a>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#examples">Examples</a>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#statistics-graph">Statistics Graph</a>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#influxdb-graphs">InfluxDb Graphs</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#using-rest">Using REST</a>
|
||||
<ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#photo">Photo</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Learn-models-with-your-own-images/">Learn models with your own images</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../MQTT-API/">General Information</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Migrate-Old-Config-To-New-Config/">Migration from water-meter „old“ to water-meter “AI-on-the-edge-device”</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Neural-Network-Types/">Neural Network Types</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../OTA---Update-Firmware-and-Web-Interface/">Over-The-Air (OTA) Update</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../REST-API/">REST API</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../ROI-Configuration/">ROI (Region of Interest) Configuration</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Release-creation/">Release creation</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Testing/">Testing</a>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../Watermeter-specific-analog---digital-transition/">Understanding the problem</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="..">AI on the Edge Device</a>
|
||||
|
||||
</nav>
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href=".." class="icon icon-home" alt="Docs"></a> »</li>
|
||||
<li>Asorted Pages »</li>
|
||||
<li>Integration into Home Assistant</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs/edit/main/doc/Integration-Home-Assistant.md" class="icon icon-github"> Edit on GitHub</a>
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div class="section" itemprop="articleBody">
|
||||
|
||||
<h1 id="integration-into-home-assistant">Integration into Home Assistant</h1>
|
||||
<p>There are 3 ways to get the data into your Home Assistant:
|
||||
1. Using MQTT (Automatically Setup Entities using Homeassistant MQTT Discovery)
|
||||
1. Using MQTT (Manually Setup Entities)
|
||||
2. Using REST calls</p>
|
||||
<p>The first one is the easier way if you already have MQTT in use.</p>
|
||||
<h2 id="using-mqtt-automatically-setup-entities-using-homeassistant-mqtt-discovery">Using MQTT (Automatically Setup Entities using Homeassistant MQTT Discovery)</h2>
|
||||
<p>:bangbang: This feature will be available with the next release!</p>
|
||||
<p>Starting with Version <code>>12.0.1</code>, AI-on-the-edge-devices support Homeassistant Discovery.
|
||||
1. Check <a href="https://www.home-assistant.io/docs/mqtt/discovery/">here</a> to learn more about it and how to enable it in Homeassistant.
|
||||
1. You also have to enable it in the MQTT settings of your device:</p>
|
||||
<pre><code>
|
||||
|
||||
Make sure to select the right Meter Type to get the right units!
|
||||
</code></pre>
|
||||
<p>On the next start of the device, it will send discovery topics and Homeassistant should pick them up and show them under <code>Settings > Integrations > MQTT</code>:</p>
|
||||
<p><img alt="grafik" src="https://user-images.githubusercontent.com/1783586/199352538-ddcc3484-39ef-44f4-a853-53286807d30b.png" />
|
||||
<img alt="grafik" src="https://user-images.githubusercontent.com/1783586/199352565-9b0ade28-cb43-47b4-821f-7909cad41a73.png" />
|
||||
<img alt="grafik" src="https://user-images.githubusercontent.com/1783586/199352619-217df627-4b87-4fa0-86a2-f5347c452fdb.png" /></p>
|
||||
<h3 id="using-mqtt-manually-setup-entities">Using MQTT (Manually Setup Entities)</h3>
|
||||
<p>First make sure with an MQTT client (for example <a href="http://mqtt-explorer.com/">MQTT Explorer</a>) that MQTT works as expected and to get a list of the available topics!</p>
|
||||
<p>Then add a sensor for each property:</p>
|
||||
<pre><code class="language-yaml">mqtt:
|
||||
sensor:
|
||||
- state_topic: "wasserzaehler/main/value"
|
||||
name: "Watermeter Value"
|
||||
unique_id: watermeter_value
|
||||
unit_of_measurement: 'm³'
|
||||
state_class: total_increasing
|
||||
device_class: water # Needs Homeassistant 2022.11!
|
||||
icon: 'mdi:water-pump'
|
||||
availability_topic: wasserzaehler/connection
|
||||
payload_available: connected
|
||||
payload_not_available: connection lost
|
||||
|
||||
- state_topic: "wasserzaehler/main/rate"
|
||||
name: "Watermeter Rate"
|
||||
unique_id: watermeter_rate
|
||||
unit_of_measurement: 'm³/min'
|
||||
state_class: measurement
|
||||
device_class: water # Needs Homeassistant 2022.11!
|
||||
icon: 'mdi:water-pump'
|
||||
availability_topic: wasserzaehler/connection
|
||||
payload_available: connected
|
||||
payload_not_available: connection lost
|
||||
|
||||
- state_topic: "wasserzaehler/main/error"
|
||||
name: "Watermeter Error"
|
||||
unique_id: watermeter_error
|
||||
icon: "mdi:water-alert"
|
||||
availability_topic: wasserzaehler/connection
|
||||
payload_available: connected
|
||||
payload_not_available: connection lost
|
||||
|
||||
- state_topic: "wasserzaehler/uptime"
|
||||
name: "Watermeter Uptime"
|
||||
unique_id: watermeter_uptime
|
||||
unit_of_measurement: 's'
|
||||
state_class: measurement
|
||||
device_class: duration
|
||||
entity_category: diagnostic
|
||||
icon: "mdi:timer-outline"
|
||||
availability_topic: wasserzaehler/connection
|
||||
payload_available: connected
|
||||
payload_not_available: connection lost
|
||||
</code></pre>
|
||||
<p>If you run the discovery once, you can also extract the information from there (MQTT Info, untested):</p>
|
||||
<pre><code class="language-yaml">mqtt: # Extracted form the Discovery but untested!
|
||||
sensor:
|
||||
- name: Value
|
||||
unique_id: wasserzaehler-main_value
|
||||
icon: mdi:gauge
|
||||
state_topic: wasserzaehler/main/value
|
||||
unit_of_measurement: m³
|
||||
device_class: water
|
||||
state_class: total_increasing
|
||||
availability_topic: wasserzaehler/connection
|
||||
payload_available: connected
|
||||
payload_not_available: connection lost
|
||||
</code></pre>
|
||||
<p>If you want to convert the <code>m³</code> to <code>l</code>, use a template sensor:</p>
|
||||
<pre><code class="language-yaml">template:
|
||||
- sensor:
|
||||
- name: "Watermeter in l"
|
||||
unique_id: watermeter_in_l
|
||||
icon: "mdi:gauge"
|
||||
state: "{{ states('sensor.watermeter_value')|float(default=0) * 1000 }}" # Convert 1 m3 => 1000 l
|
||||
unit_of_measurement: l
|
||||
availability: "{{ states('sensor.watermeter_value') not in ['unknown', 'unavailable', 'none'] }}"
|
||||
</code></pre>
|
||||
<p>If you you want to have the consumption per day, you can use an <a href="https://www.home-assistant.io/integrations/utility_meter/">Utility Meter</a>.
|
||||
it is a helper and can be used to reset the total increasing values once a day</p>
|
||||
<pre><code class="language-yaml">utility_meter:
|
||||
utility_meter_gas_per_day:
|
||||
source: sensor.gasmeter_value
|
||||
cycle: daily
|
||||
|
||||
utility_meter_water_per_day:
|
||||
source: sensor.watermeter_value
|
||||
cycle: daily
|
||||
</code></pre>
|
||||
<p>Note that you also can add it using the UI.</p>
|
||||
<h3 id="examples">Examples</h3>
|
||||
<p><img alt="grafik" src="https://user-images.githubusercontent.com/1783586/193472069-4135736e-e63a-4afb-8009-5b97aa5c9ac5.png" /></p>
|
||||
<p><img alt="grafik" src="https://user-images.githubusercontent.com/1783586/193472091-1484aac4-ddc2-48ba-896c-28370963fc2d.png" /></p>
|
||||
<h3 id="statistics-graph">Statistics Graph</h3>
|
||||
<p>Creating Statistics Graphs (eg. usage per day) is easy using the <a href="https://www.home-assistant.io/home-energy-management/">Energy Dashboard</a>:
|
||||
<img alt="grafik" src="https://user-images.githubusercontent.com/1783586/193471893-d8ab8f5f-0906-4076-8926-8b5a69a24bce.png" /></p>
|
||||
<p>Note that there seems to be a bug in the graph, see https://github.com/home-assistant/frontend/issues/13995!</p>
|
||||
<h3 id="influxdb-graphs">InfluxDb Graphs</h3>
|
||||
<p>If you have setup InfluxDB already, it is also possible to fetch statistics from there, eg. daily usage:</p>
|
||||
<pre><code>from(bucket: "HomeAssistant")
|
||||
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|
||||
|> filter(fn: (r) => r["entity_id"] == "wasserverbrauch_tag")
|
||||
|> filter(fn: (r) => r["_field"] == "value")
|
||||
|> timeShift(duration: -1d)
|
||||
|> aggregateWindow(every: 1d, fn: max, createEmpty: false)
|
||||
|> yield(name: "mean")
|
||||
</code></pre>
|
||||
<p><img alt="grafik" src="https://user-images.githubusercontent.com/1783586/193473347-c81fc301-c52f-4af0-9fcb-56fab12cacac.png" /></p>
|
||||
<h2 id="using-rest">Using REST</h2>
|
||||
<p>When using REST, Home Assistant has to periodically call an URL on the ESP32 which in return provides the requested data.</p>
|
||||
<p>See <a href="https://github.com/jomjol/AI-on-the-edge-device/wiki/REST-API">REST API</a> for a list of available URLs.</p>
|
||||
<p>The most practical one is the <code>json</code> entrypoint which provides the most relevant data JSON formated:
|
||||
<code>http://<IP>/json</code>
|
||||
This would return:</p>
|
||||
<pre><code class="language-JSON">{
|
||||
"main":
|
||||
{
|
||||
"value": "512.3020",
|
||||
"raw": "0512.3020",
|
||||
"error": "no error",
|
||||
"rate": 0.000000,
|
||||
"timestamp": "2022-10-02T20:32:06"
|
||||
[..]
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
<p>To do such a REST call, you need to create a REST sensor:</p>
|
||||
<pre><code class="language-yaml">sensor:
|
||||
- platform: rest
|
||||
name: "Gasmeter JSON"
|
||||
resource: http://<IP>/json
|
||||
json_attributes:
|
||||
- main
|
||||
value_template: '{{ value_json.value }}'
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
scan_interval: 60
|
||||
|
||||
template:
|
||||
sensor:
|
||||
- name: "Gasmeter Value from JSON"
|
||||
unique_id: gas_meter_value_from_json
|
||||
state: "{{ state_attr('sensor.gasmeter_json','main')['value'] }}"
|
||||
unit_of_measurement: 'm³'
|
||||
|
||||
- name: "Watermeter Value from JSON"
|
||||
unique_id: water_meter_value_from_json
|
||||
state: >-
|
||||
{{ state_attr('sensor.watermeter_json','main')['value'] | float }}
|
||||
unit_of_measurement: 'm³'
|
||||
device_class: water
|
||||
state_class: total_increasing
|
||||
icon: mdi:gauge
|
||||
|
||||
</code></pre>
|
||||
<p>See also https://community.home-assistant.io/t/rest-sensor-nested-json/243420/9</p>
|
||||
<h4 id="photo">Photo</h4>
|
||||
<p>REST can also be used to show the photo of the last round:</p>
|
||||
<p><img alt="grafik" src="https://user-images.githubusercontent.com/1783586/193546075-b247942f-9106-47a4-a64b-42ff96dd9078.png" /></p>
|
||||
<p>To access it, use <code>http://<IP>/img_tmp/alg_roi.jpg</code> resp <code>http://<IP>/img_tmp/raw.jpg</code>.</p>
|
||||
|
||||
</div>
|
||||
</div><footer>
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
|
||||
<a href="../Integrated%20Functions/" class="btn btn-neutral float-left" title="Integrated Functions"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
||||
<a href="../Learn-models-with-your-own-images/" class="btn btn-neutral float-right" title="Learn models with your own images">Next <span class="icon icon-circle-arrow-right"></span></a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<!-- Copyright etc -->
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="rst-versions" role="note" aria-label="Versions">
|
||||
<span class="rst-current-version" data-toggle="rst-current-version">
|
||||
|
||||
<span>
|
||||
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs" class="fa fa-github" style="color: #fcfcfc"> GitHub</a>
|
||||
</span>
|
||||
|
||||
|
||||
<span><a href="../Integrated%20Functions/" style="color: #fcfcfc">« Previous</a></span>
|
||||
|
||||
|
||||
<span><a href="../Learn-models-with-your-own-images/" style="color: #fcfcfc">Next »</a></span>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<script>var base_url = '..';</script>
|
||||
<script src="../js/theme_extra.js" defer></script>
|
||||
<script src="../js/theme.js" defer></script>
|
||||
<script src="../search/main.js" defer></script>
|
||||
<script defer>
|
||||
window.onload = function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
};
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user