mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-22 15:08:12 +01:00
473 lines
No EOL
20 KiB
HTML
473 lines
No EOL
20 KiB
HTML
|
||
|
||
<!DOCTYPE html>
|
||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||
<head>
|
||
<meta charset="utf-8">
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<title>Sensor — CraftBeerPi 4.0 documentation</title>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
<link rel="index" title="Index" href="genindex.html" />
|
||
<link rel="search" title="Search" href="search.html" />
|
||
<link rel="next" title="Brewing Step" href="step.html" />
|
||
<link rel="prev" title="Actor" href="actor.html" />
|
||
|
||
|
||
<script src="_static/js/modernizr.min.js"></script>
|
||
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav">
|
||
|
||
|
||
<div class="wy-grid-for-nav">
|
||
|
||
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search">
|
||
|
||
|
||
|
||
<a href="index.html" class="icon icon-home"> CraftBeerPi
|
||
|
||
|
||
|
||
</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" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<ul class="current">
|
||
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="core.html">Core</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="actor.html">Actor</a></li>
|
||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Sensor</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="#sensor-controller">Sensor Controller</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#cbpisensor">CBPiSensor</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#custom-sensor">Custom Sensor</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference internal" href="step.html">Brewing Step</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="kettle_controller.html">Kettle</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="properties.html">Properties</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="standards.html">Standard & Guidelines</a></li>
|
||
</ul>
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||
|
||
|
||
<nav class="wy-nav-top" aria-label="top navigation">
|
||
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="index.html">CraftBeerPi</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="index.html">Docs</a> »</li>
|
||
|
||
<li>Sensor</li>
|
||
|
||
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
<a href="_sources/sensor.rst.txt" rel="nofollow"> View page source</a>
|
||
|
||
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<div class="section" id="sensor">
|
||
<h1>Sensor<a class="headerlink" href="#sensor" title="Permalink to this headline">¶</a></h1>
|
||
<div class="section" id="sensor-controller">
|
||
<h2>Sensor Controller<a class="headerlink" href="#sensor-controller" title="Permalink to this headline">¶</a></h2>
|
||
<dl class="class">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController">
|
||
<em class="property">class </em><code class="descclassname">cbpi.controller.sensor_controller.</code><code class="descname">SensorController</code><span class="sig-paren">(</span><em>cbpi</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">cbpi.controller.crud_controller.CRUDController</span></code></p>
|
||
<dl class="attribute">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController._abc_impl">
|
||
<code class="descname">_abc_impl</code><em class="property"> = <_abc_data object></em><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController._abc_impl" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController._post_add_callback">
|
||
<code class="descname">_post_add_callback</code><span class="sig-paren">(</span><em>m</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController._post_add_callback" title="Permalink to this definition">¶</a></dt>
|
||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||
<col class="field-name" />
|
||
<col class="field-body" />
|
||
<tbody valign="top">
|
||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>m</strong> – </td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController._post_update_callback">
|
||
<code class="descname">_post_update_callback</code><span class="sig-paren">(</span><em>sensor</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController._post_update_callback" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController._pre_delete_callback">
|
||
<code class="descname">_pre_delete_callback</code><span class="sig-paren">(</span><em>sensor_id</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController._pre_delete_callback" title="Permalink to this definition">¶</a></dt>
|
||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||
<col class="field-name" />
|
||
<col class="field-body" />
|
||
<tbody valign="top">
|
||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>m</strong> – </td>
|
||
</tr>
|
||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController._pre_update_callback">
|
||
<code class="descname">_pre_update_callback</code><span class="sig-paren">(</span><em>sensor</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController._pre_update_callback" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController.get_state">
|
||
<code class="descname">get_state</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController.get_state" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController.get_value">
|
||
<code class="descname">get_value</code><span class="sig-paren">(</span><em>sensor_id</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController.get_value" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController.init">
|
||
<code class="descname">init</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController.init" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This method initializes all actors during startup. It creates actor instances</p>
|
||
<table class="docutils field-list" frame="void" rules="none">
|
||
<col class="field-name" />
|
||
<col class="field-body" />
|
||
<tbody valign="top">
|
||
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController.init_sensor">
|
||
<code class="descname">init_sensor</code><span class="sig-paren">(</span><em>sensor</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController.init_sensor" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="attribute">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController.model">
|
||
<code class="descname">model</code><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController.model" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">cbpi.database.model.SensorModel</span></code></p>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.controller.sensor_controller.SensorController.stop_sensor">
|
||
<code class="descname">stop_sensor</code><span class="sig-paren">(</span><em>sensor</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.controller.sensor_controller.SensorController.stop_sensor" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="cbpisensor">
|
||
<h2>CBPiSensor<a class="headerlink" href="#cbpisensor" title="Permalink to this headline">¶</a></h2>
|
||
<dl class="class">
|
||
<dt id="cbpi.api.CBPiSensor">
|
||
<em class="property">class </em><code class="descclassname">cbpi.api.</code><code class="descname">CBPiSensor</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwds</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSensor" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">cbpi.api.extension.CBPiExtension</span></code></p>
|
||
<dl class="method">
|
||
<dt id="cbpi.api.CBPiSensor.init">
|
||
<code class="descname">init</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSensor.init" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.api.CBPiSensor.log_data">
|
||
<code class="descname">log_data</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSensor.log_data" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.api.CBPiSensor.run">
|
||
<code class="descname">run</code><span class="sig-paren">(</span><em>cbpi</em><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSensor.run" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="cbpi.api.CBPiSensor.state">
|
||
<code class="descname">state</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cbpi.api.CBPiSensor.state" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="custom-sensor">
|
||
<h2>Custom Sensor<a class="headerlink" href="#custom-sensor" title="Permalink to this headline">¶</a></h2>
|
||
<div class="literal-block-wrapper docutils container" id="init-py">
|
||
<div class="code-block-caption"><span class="caption-text">__init__.py</span><a class="headerlink" href="#init-py" title="Permalink to this code">¶</a></div>
|
||
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
|
||
2
|
||
3
|
||
4
|
||
5
|
||
6
|
||
7
|
||
8
|
||
9
|
||
10
|
||
11
|
||
12
|
||
13
|
||
14
|
||
15
|
||
16
|
||
17
|
||
18
|
||
19
|
||
20
|
||
21
|
||
22
|
||
23
|
||
24
|
||
25
|
||
26
|
||
27
|
||
28
|
||
29
|
||
30
|
||
31
|
||
32
|
||
33
|
||
34
|
||
35
|
||
36
|
||
37
|
||
38
|
||
39
|
||
40
|
||
41
|
||
42
|
||
43
|
||
44
|
||
45
|
||
46
|
||
47
|
||
48
|
||
49
|
||
50
|
||
51
|
||
52
|
||
53
|
||
54
|
||
55
|
||
56
|
||
57
|
||
58</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">asyncio</span>
|
||
<span class="kn">import</span> <span class="nn">logging</span>
|
||
<span class="kn">import</span> <span class="nn">random</span>
|
||
|
||
<span class="kn">from</span> <span class="nn">cbpi.api</span> <span class="kn">import</span> <span class="o">*</span>
|
||
|
||
<span class="k">class</span> <span class="nc">CustomSensor</span><span class="p">(</span><span class="n">CBPiSensor</span><span class="p">):</span>
|
||
|
||
<span class="c1"># Custom Properties which will can be configured by the user</span>
|
||
|
||
<span class="n">p1</span> <span class="o">=</span> <span class="n">Property</span><span class="o">.</span><span class="n">Number</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s2">"Test"</span><span class="p">)</span>
|
||
<span class="n">p2</span> <span class="o">=</span> <span class="n">Property</span><span class="o">.</span><span class="n">Text</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s2">"Test"</span><span class="p">)</span>
|
||
<span class="n">interval</span> <span class="o">=</span> <span class="n">Property</span><span class="o">.</span><span class="n">Number</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s2">"interval"</span><span class="p">)</span>
|
||
|
||
<span class="c1"># Internal runtime variable</span>
|
||
<span class="n">value</span> <span class="o">=</span> <span class="mi">0</span>
|
||
|
||
<span class="nd">@action</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="s2">"name"</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="p">{})</span>
|
||
<span class="k">def</span> <span class="nf">myAction</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||
<span class="sd">'''</span>
|
||
<span class="sd"> Custom Action Exampel</span>
|
||
<span class="sd"> :return: None</span>
|
||
<span class="sd"> '''</span>
|
||
<span class="k">pass</span>
|
||
|
||
<span class="k">def</span> <span class="nf">init</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">init</span><span class="p">()</span>
|
||
|
||
|
||
<span class="k">def</span> <span class="nf">state</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">state</span><span class="p">()</span>
|
||
|
||
<span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||
<span class="k">pass</span>
|
||
|
||
<span class="n">async</span> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cbpi</span><span class="p">):</span>
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="mi">0</span>
|
||
<span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
|
||
<span class="n">await</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">interval</span><span class="p">)</span>
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">log_data</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">+</span> <span class="mi">1</span>
|
||
<span class="n">await</span> <span class="n">cbpi</span><span class="o">.</span><span class="n">bus</span><span class="o">.</span><span class="n">fire</span><span class="p">(</span><span class="s2">"sensor/</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
|
||
|
||
|
||
|
||
|
||
|
||
<span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="n">cbpi</span><span class="p">):</span>
|
||
|
||
<span class="sd">'''</span>
|
||
<span class="sd"> This method is called by the server during startup </span>
|
||
<span class="sd"> Here you need to register your plugins at the server</span>
|
||
<span class="sd"> </span>
|
||
<span class="sd"> :param cbpi: the cbpi core </span>
|
||
<span class="sd"> :return: </span>
|
||
<span class="sd"> '''</span>
|
||
|
||
<span class="n">cbpi</span><span class="o">.</span><span class="n">plugin</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="s2">"CustomSensor"</span><span class="p">,</span> <span class="n">CustomSensor</span><span class="p">)</span>
|
||
</pre></div>
|
||
</td></tr></table></div>
|
||
</div>
|
||
<p>config.yaml</p>
|
||
<div class="highlight-yaml notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
|
||
2</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">DummySensor</span>
|
||
<span class="l l-Scalar l-Scalar-Plain">version</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">4</span>
|
||
</pre></div>
|
||
</td></tr></table></div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<footer>
|
||
|
||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||
|
||
<a href="step.html" class="btn btn-neutral float-right" title="Brewing Step" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||
|
||
|
||
<a href="actor.html" class="btn btn-neutral" title="Actor" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||
|
||
</div>
|
||
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>
|
||
© Copyright 2018, Manuel Fritsch
|
||
|
||
</p>
|
||
</div>
|
||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
||
</footer>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||
<script type="text/javascript" src="_static/underscore.js"></script>
|
||
<script type="text/javascript" src="_static/doctools.js"></script>
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript" src="_static/js/theme.js"></script>
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function () {
|
||
SphinxRtdTheme.Navigation.enable(true);
|
||
});
|
||
</script>
|
||
|
||
</body>
|
||
</html> |