Ankündigung

Einklappen
Keine Ankündigung bisher.

Werte von Radio-Buttons auf Item übertragen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Werte von Radio-Buttons auf Item übertragen

    Hallo,

    bitte mal wieder Kopfbrett entfernen: Ich versuche gerade, auf einem Popup eine Gruppe von Radiobuttons mit einem smarthome.py-Item zu verbinden (siehe Anhang - Gruppe 15'...2h oben).

    Der Code bisher:

    Code:
     [FONT=Courier New]<fieldset >
       <input type="radio" id="radio1" name="radios" value="15" checked><label for="radio1">15</label>
       <input type="radio" id="radio2" name="radios" value="30"><label for="radio2">30</label>
       <input type="radio" id="radio3" name="radios" value="45"><label for="radio3">45</label>
       <input type="radio" id="radio4" name="radios" value="60"><label for="radio4">60</label>
       <input type="radio" id="radio5" name="radios" value="90"><label for="radio5">90</label>
       <input type="radio" id="radio6" name="radios" value="120"><label for="radio6">2h</label>
    </fieldset>[/FONT]
    Ich will versuchen, möglichst ohne Einsatz von JS diese Buttons mit einem Item zu verbinden.

    Gibt es dafür eine einfache Lösung? Danke für Tips im Voraus! (Design bitte noch ignorieren, ist alles noch Bastellabor)

    /tom
    Angehängte Dateien

    #2
    Eigene Antwort und Frage an die Profis

    Ich antworte mir mal selbst:

    Ganz ohne JS ging es natürlich nicht (ich weigere mich derzeit noch standhaft, mich neben Aufbau und Funktionsweise von sh.py / smartVISU / Raspberyy Pi / diversen RS485-Protokollen sowie neben HTML und php und Python auch noch gleichzeitig tiefer in JS einarbeiten zu müssen - information overflow).

    Falls jemand mal ein ähnliches Problem hat, so funktioniert es (ich habe mal ein bisschen in den Basis-JS-Dateien der Visu geschnüffelt):

    HTML-Code:
     <form>
     <script type="text/javascript">
      io.write('ventilation.booster_mode.boost_duration',45);
     </script>
     <b>Dauer: {{ basic.value('nur-zum-test', 'ventilation.booster_mode.boost_duration') }}</b>
     <fieldset>
      <input type="radio" id="radio1" name="radios" value= 15 onclick="io.write('ventilation.booster_mode.boost_duration',value)"><label for="radio1">15</label>
      <input type="radio" id="radio2" name="radios" value= 30 onclick="io.write('ventilation.booster_mode.boost_duration',value)"><label for="radio2">30</label>
      <input type="radio" id="radio3" name="radios" value= 45 onclick="io.write('ventilation.booster_mode.boost_duration',value)" checked><label for="radio3">45</label>
      <input type="radio" id="radio4" name="radios" value= 60 onclick="io.write('ventilation.booster_mode.boost_duration',value)"><label for="radio4">1h</label>
      <input type="radio" id="radio5" name="radios" value= 90 onclick="io.write('ventilation.booster_mode.boost_duration',value)"><label for="radio5">90</label>
      <input type="radio" id="radio6" name="radios" value=120 onclick="io.write('ventilation.booster_mode.boost_duration',value)"><label for="radio6">2h</label>
     </fieldset>
    </form>

    Frage an die Profis: Mal davon abgesehen, dass das ganze ein wenig unelegant aussieht - ist ein "hartes" Schreiben auf Items aus irgendwelchen Gründen, die ich zur Zeit nicht kenne, problematisch?

    /tom
    Angehängte Dateien

    Kommentar


      #3
      Hi,
      Sorry I don’t speak German will write in English.
      I’m trying to make a new device in widget\device.html this device is similar to the device.rtr but it has to work with the “synco” from Siemens.
      Just for the story Siemens synco use 2 dpt 20.102 one in read only and a second one in read/write. Because when we are in auto mode the read/write dpt =0 and to know which mode is used we read in the read only dpt (which can never be = to 0)

      And it’s new for me Jquery and javascript ;-)

      I ‘want to use the type radio in the widget\device.html but there are some thing I’don’t understand with the variable my code it’s not workin.
      And I also want when we load the page the correct button is selected following the gad value.

      HTML-Code:
      /**
      * Siemens QAX913 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 mode PRE (1x byte) $$$$ a unique gad for mode (0 = Auto, 1 = Comfort; 2 = Precomfort (Standby); 3 = Economy; 4 = Protection (BldgProtect))
      * @param a gad/item for mode actual mode (1 = Comfort; 2 = Precomfort (Standby); 3 = Economy; 4 = Protection (BldgProtect))
      * @param a gad/item for the current state of the actor
      * @param a gad/item for a text (some rtr have a text-display), (optional)
      * @param step for plus/minus buttons (optional, default 0.5)
      * @param a gad/item for economy set point temperature $$$PABLO
      * @param a gad/item for precomfort set point temperature $$$PABLO
      * @param a gad/item for comfort set point temperature $$$PABLO
      */
      {% macro rtr2(id, gad_actual, gad_set, gad_pre, gad_actu, gad_state, gad_txt, gad_eco, gad_pre, gad_conf, step) %}
       {% import "basic.html" as basic %}
       <div id="{{ uid(page, id) }}" data-widget="device.rtr2" data-step="{{ step|default(0.5) }}" class="rtr">
       
       <div class="actual">
         <div class="temp">{{ basic.float(id~'actual', gad_actual, '°' ) }}</div>
                  <div class="text">Position de la vanne {{ basic.float(id~'state', gad_state, '%0' ) }}</div>
          </div>    
          <div class="set"> {{ basic.float(id~'set', gad_set, '°' ) }}</div>
       
             <form>
                  <script type="text/javascript">
                  io.write(gad_pre);
                  </script>
                  <b>Mode: {{ basic.value('nur-zum-test', gad_pre) }}</b>
                       <fieldset>
                            <input type="radio" id="radio1" name="radios" value= 0 onclick="io.write(gad_pre,value)"><label for="radio1">Auto</label>
                            <input type="radio" id="radio2" name="radios" value= 1 onclick="io.write(gad_pre,value)"><label for="radio2">Confort</label>
                            <input type="radio" id="radio3" name="radios" value= 2 onclick="io.write(gad_pre,value)" checked><label for="radio3">Pré-conf</label>
                            <input type="radio" id="radio4" name="radios" value= 3 onclick="io.write(gad_pre,value)"><label for="radio4">Eco</label>
                            <input type="radio" id="radio5" name="radios" value= 4 onclick="io.write(gad_pre,value)"><label for="radio5">Anti-gel</label>
                       </fieldset>
              </form>
          </div>
      {% endmacro %}

      Kommentar

      Lädt...
      X