Ankündigung

Einklappen
Keine Ankündigung bisher.

symbol in widget dynamisch ändern "if" problem

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

    symbol in widget dynamisch ändern "if" problem

    Ich würde gerne das rtr widget etwas anpassen, damm es mir anzeigt, ob geheizt oder gekühlt wird. Dafür würde ich gerne einen Status mitübergeben "gad_cool" /true wenn kühlmodus, sonst false:
    PHP-Code:
    {% macro rtr2(idtxtgad_actualgad_setgad_comfortgad_nightgad_frostgad_stategad_txtstepgad_actual_bodengad_cool) %}
        {% 
    import "basic.html" as basic %} 
    am Ende will ich dann gad_cool verwenden um je nach heiz oder kühlmodus ein anderes Symbol anzuzeigen:

    PHP-Code:
            <div class="control">
                {% if ((
    config_driver == 'linknx') and (gad_comfort == gad_night) and (gad_night == gad_frost)) %}
                    {{ 
    basic.switch(id~'mode'gad_comfort'user_available.svg''user_away.svg''comfort''standby') }}
                    {{ 
    basic.switch(id~'night'gad_night'scene_night.svg''scene_day.svg''night''standby') }}
                    {{ 
    basic.switch(id~'frost'gad_frost'weather_frost.svg''weather_frost.svg''frost''standby') }}
                {% elseif ((
    gad_comfort == gad_night) and (gad_night == gad_frost)) %}
                    {{ 
    basic.switch(id~'mode'gad_comfort'user_available.svg''user_away.svg''1''2') }}
                    {{ 
    basic.switch(id~'night'gad_night'scene_night.svg''scene_day.svg''3''2') }}
                    {{ 
    basic.switch(id~'frost'gad_frost'weather_frost.svg''weather_frost.svg''4''2') }}
                {% else %}
                    {{ 
    basic.switch(id~'mode'gad_comfort'user_available.svg''user_away.svg') }}
                    {{ 
    basic.switch(id~'night'gad_night'scene_night.svg''scene_day.svg') }}
                    {{ 
    basic.switch(id~'frost'gad_frost'weather_frost.svg''weather_frost.svg') }}
                {% endif %}
                <
    div style="float:left; width: 3px; height: 50px;"></div>
                {% if 
    gad_cool %}
                    {{ 
    basic.switch(id~'state'gad_state'weather_frost.svg''weather_frost.svg') }}
                {% else %}
                    {{ 
    basic.switch(id~'state'gad_state'sani_heating.svg''sani_heating.svg') }}{% endif %}
            </
    div>
        </
    div
    funktioniert nur leider nicht und ich frage mich, ob es überhaupt möglich ist in einem widget items abzufragen und die Anzeige entsprechend zu ändern.
    Zuletzt geändert von Marcov; 27.06.2016, 23:10.

    #2
    Das was Du das hast ist nicht dynamisch. Schau mal unter Basic.Symbol in der Doku nach. Dort steht {{ basic.symbol(id, items, txt, pic, val, mode) }} als Beispiel dann:

    Code:
    {{ basic.symbol('s2', 'bath_light_switch', 'Light on', icon1~'light_light.png') }}
    {{ basic.symbol('s3', 'bath_light_switch', 'Light off', icon1~'light_light.png', 0) }}
    Das Symbol wäre dann dynamisch. Du kannst dann oben statt
    Code:
    [COLOR=#000000][COLOR=#007700]{% if [/COLOR][COLOR=#0000BB]gad_cool [/COLOR][COLOR=#007700]%}
      {{ [/COLOR][COLOR=#0000BB]basic[/COLOR][COLOR=#007700].switch([/COLOR][COLOR=#0000BB]id[/COLOR][COLOR=#007700]~[/COLOR][COLOR=#DD0000]'state'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]gad_state[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]'weather_frost.svg'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]'weather_frost.svg'[/COLOR][COLOR=#007700]) }}
    {% else %}
      {{ [/COLOR][COLOR=#0000BB]basic[/COLOR][COLOR=#007700].switch([/COLOR][COLOR=#0000BB]id[/COLOR][COLOR=#007700]~[/COLOR][COLOR=#DD0000]'state'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]gad_state[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]'sani_heating.svg'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]'sani_heating.svg'[/COLOR][COLOR=#007700]) }}
    {% endif %}[/COLOR][/COLOR]
    sowas schreiben:wie
    Code:
    {{ basic.symbol(id~'cooling', gad_cool, 'Kühlen', [COLOR=#000000][COLOR=#DD0000]'weather_frost.svg'[/COLOR][/COLOR], 1) }}
    {{ basic.symbol(id~'heating', gad_cool, 'Heizen', [COLOR=#000000][COLOR=#DD0000]'sani_heating.svg'[/COLOR][/COLOR]) }}
    Zuletzt geändert von bmx; 28.06.2016, 20:16.

    Kommentar


      #3
      vielen Dank - das geht schon mal grob.

      Ich würde jetzt gerne, dass wenn:
      1. gad_cool und gad_state true sind das symbol Kühlen angeziegt wird und "on" leuchtet
      2. gad_cool true und gad_state false sind das symbol Kühlen angezeigt wird und "off" ist
      3. gad_cool false und gad_state true -> symbol heizen "on"
      4. gad_cool false und gad_state false -> symbole heizen "off"

      1. geht so:
      {{ basic.symbol(id~'cooling2', [gad_cool, gad_state], '', 'weather_frost.svg', 1, 'and', 'icon1') }}
      2. geht leider nicht bzw. nur so:
      {{ basic.symbol(id~'cooling2', gad_cool, '', 'weather_frost.svg', 1, '', '') }} -> wenn nun aber gad_state gleichzeitig true ist, werden beide Symbole angezeigt. Wie schaffe ich es cooling2 nur einzublenden, wenn gad_state false ist?

      Alternativ könnte ich es über einzelne Items in smarthome.py machen und dann noch mehr items übergeben, finde ich aber irgendwie unelegant.

      Kommentar

      Lädt...
      X