Hallo zusammen,
ich bin gerade dabei meine MAX Thermostate per smartvisu zu steuern, dabei habe ich folgendes im WIKI gefunden:
https://forum.fhem.de/index.php?topic=30909.msg241379#msg241379 (https://forum.fhem.de/index.php?topic=30909.msg241379#msg241379)
Ich habe also dies:
/**
* Small RTR (Room Temperatur Regulator)
*
* @param unique id for this widget
* @param name of the rtr
* @param a gad/item for the actual temperature
* @param a gad/item for the set temperature
* @param a gad/item for the current state of the actor
* @param step for plus/minus buttons (optional, default 0.5°)
*/
{% macro smallrtr(id, txt, gad_actual, gad_set, gad_state, step) %}
{% import "basic.html" as basic %}
{% set uid = uid(page, id) %}
/** Design */
<div id="{{ uid }}" class="rtr">
<table style="width:100%; text-align: left;">
<tr>
<th width="25%">{% if txt %} {{ txt }} {% endif %}</th>
<td width="15%"><div class="temp">{{ basic.float(id~'actual', gad_actual, '°C' ) }}</div></td>
<td width="15%">
{% if gad_set %}
{{ basic.button(id~'minus', '', '', 'minus', '', 'micro') }}
{% endif %}
</td>
<td width="15%"><div class="temp">{{ basic.float(id~'set', gad_set, '°C' ) }}</div></td>
<td width="15%">
{% if gad_set %}
{{ basic.button(id~'plus', '', '', 'plus', '', 'micro') }}
{% endif %}
</td>
<td width="15%">
{{ basic.symbol(id~'stateon', gad_state, '', icon1~'sani_floor_heating.png', 1) }}
{{ basic.symbol(id~'stateoff', gad_state, '', icon0~'sani_floor_heating.png', 0) }}
</td>
</tr>
</table>
{% if gad_set %}
/** Events */
<script type="text/javascript">
// plus / minus
$("#{{ uid~'minus' }}").unbind('click').bind('click', function(){
var temp = (Math.round((parseFloat($("#{{ uid~'set' }}").html().replace(',','.')) - {{ step|default(0.5) }}) * 10) / 10).toFixed(1);
$("#{{ uid~'set' }}").html(temp + ' °C');
io.write("{{ gad_set }}", temp);
});
$("#{{ uid~'plus' }}").unbind('click').bind('click', function(){
var temp = (Math.round((parseFloat($("#{{ uid~'set' }}").html().replace(',','.')) + {{ step|default(0.5) }}) * 10) / 10).toFixed(1);
$("#{{ uid~'set' }}").html(temp + ' °C');
io.write("{{ gad_set }}", temp);
});
</script>
{% endif %}
</div>
/**
* Max RTR (Room Temperatur Regulator)
*
* @param unique id for this widget
* @param name of the rtr
* @param a gad/item for the actual temperature
* @param a gad/item for the set temperature
* @param a gad/item for the current state of the actor
* @param step for plus/minus buttons (optional, default 0.5)
*/
{% macro rtr(id, txt, gad_actual, gad_set, gad_state, step) %}
{% import "basic.html" as basic %}
<div id="{{ uid(page, id) }}" data-widget="device.rtr" data-step="{{ step|default(0.5) }}"
class="rtr">
<div class="actual">
<div class="temp">{{ basic.float(id~'actual', gad_actual, '°C' ) }}</div>
<div class="text">{{ txt }} {% if gad_state != 0 %} ({{ gad_state }}) {% endif %}</div>
</div>
{% if gad_set %}
<div class="set">
<a data-role="button" data-icon="minus" data-inline="true" data-iconpos="notext" class="ui-mini"></a>
<div class="temp">{{ basic.float(id~'set', gad_set, '°C' ) }}</div>
<a data-role="button" data-icon="plus" data-inline="true" data-iconpos="notext" class="ui-mini"></a>
</div>
{% endif %}
</div>
{% endmacro %}
{% endmacro %}
in device.html im widget Ordner eingefügt.
wenn ich nun meinen device definiere:
{{ max.rtr('Sch_Hzg_rtr', '', 'Sch_Hzg_rtr_act', 'Sch_Hzg_rtr_set', 'Sch_Hzg_rtr_state')}}
wird nichts angezeigt.
wo liegt hier mein Fehler?
Gruß und Danke im voraus
Edit:
Langsam kommt etwas Licht ins Dunkel. Ich denke ich habe nicht alle notwendige files angepasst...
Ich finde dazu leider auch keine Anleitung :(
Welche Dateien muss ich wo erstellen/anpassen um ein eigenes Widget (max.rtr) zu verwirklichen?
Ich würde den Code in eine neue Datei "max.html" im widget-Ordner speichern und ihn aus der
device.html wieder löschen.
Die Definition sollte dann so auschauen (zusätzlicher Import des Widgets vor der Definition):
{% import max.html" as max %}
{{ max.rtr('Sch_Hzg_rtr', '', 'Sch_Hzg_rtr_act', 'Sch_Hzg_rtr_set', 'Sch_Hzg_rtr_state')}}
Danke! so klappts