Read the statement by Michael Teeuw here.
Visibility of variables in MMM-HomeAssistantDisplay
-
Hello everyone, I have integrated around 20 window contacts via Homeassistant and would only like to display the window contacts on Magicmirror that are TRUE. Do you have a CODE for this?
-
@DrKaMo see the MMM-HomeAssistantDisplay module
Use the 3rd party module list linked in the header above
-
/* MagicMirror² Config Sample * * By Michael Teeuw https://michaelteeuw.nl * MIT Licensed. * * For more information on how you can configure this file * see https://docs.magicmirror.builders/configuration/introduction.html * and https://docs.magicmirror.builders/modules/configuration.html * * You can use environment variables using a `config.js.template` file instead of `config.js` * which will be converted to `config.js` while starting. For more information * see https://docs.magicmirror.builders/configuration/introduction.html#enviromnent-variables */ let perimeterShutter = [ { entity: "cover.ankleide", name: "Ankleide" }, { entity: "cover.babsygarten", name: "Babsy Garten" }, { entity: "cover.babsystrasse", name: "Babsy Straße" }, { entity: "cover.ben", name: "Ben" }, { entity: "cover.essen_wohnen", name: "Essen/Wohnen" }, { entity: "cover.gastebad", name: "Gäste Bad" }, { entity: "cover.hannah", name: "Hannah" }, { entity: "cover.kuche", name: "Küche" }, { entity: "cover.kuche_esszimmer", name: "Küche/Esszimmer" }, { entity: "cover.schlafen_ankleide", name: "Schlafen/Ankleide" }, { entity: "cover.schlafzimmer", name: "Schlafzimmer" }, { entity: "cover.wohnzimmer", name: "Wohnzimmer" }, ]; let perimeterShutterSections = [] perimeterShutter.forEach((item, i) => { perimeterShutterSections.push({ triggerEntities: [ item.entity ], displayTemplate: ` {% if states.${item.entity}.attributes.current_position < 50 %}<i class='mdi mdi-windows-shutter'></i> ${item.name}{% endif %} `, class: "shutter" })}); let perimeterWindows = [ { entity: "binary_sensor.fensterkontakt_ankleide_contact", name: "Ankleide Fenster" }, { entity: "binary_sensor.fensterkontakt_ankleideschlafzimmer_contact", name: "Babsy Garten Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_251d9b06_on_off", name: "Babsy Straße Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_11c19306_on_off", name: "Ben Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_5d8d8b06_on_off", name: "Essen/Wohnen Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_25c19306_on_off", name: "Gäste Bad Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_d3c99a06_on_off", name: "Hannah Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_54428b06_on_off", name: "Küche Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_e1379b06_on_off", name: "Küche/Esszimmer Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_dcb49306_on_off", name: "Schlafen/Ankleide Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_d60e9d06_on_off", name: "Schlafzimmer Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_9f518b06_on_off", name: "Wohnzimmer Fenster" }, { entity: "binary_sensor.tur_garage_door", name: "Garagen Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_35418b06_on_off", name: "Karl Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_86169b06_on_off", name: "Bad OG Fenster" }, { entity: "binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off", name: "Eingangstür" }, { entity: "binary_sensor.nuki_garage_locked", name: "Nuki Garage" }, { entity: "binary_sensor.nuki_htr_locked", name: "Nuki HTR" }, ]; let perimeterWindowSections = [] perimeterWindows.forEach((item, i) => { perimeterWindowSections.push({ triggerEntities: [ item.entity ], displayTemplate: ` {% if states.${item.entity}.state == "on" %}<i class='mdi mdi-window-open'></i> ${item.name}{% endif %} `, class: "window" })}); let config = { address: "localhost", // Address to listen on, can be: // - "localhost", "127.0.0.1", "::1" to listen on loopback interface // - another specific IPv4/6 to listen on a specific interface // - "0.0.0.0", "::" to listen on any interface // Default, when address config is left out or empty, is "localhost" port: 8080, basePath: "/", // The URL path where MagicMirror² is hosted. If you are using a Reverse proxy // you must set the sub path here. basePath must end with a / ipWhitelist: [], // Set [] to allow all IP addresses // or add a specific IPv4 of 192.168.1.5 : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"], // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"], useHttps: false, // Support HTTPS or not, default "false" will use HTTP httpsPrivateKey: "", // HTTPS private key path, only require when useHttps is true httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true language: "de", locale: "de-DE", logLevel: ["INFO", "LOG", "WARN", "ERROR"], // Add "DEBUG" for even more logging timeFormat: 24, units: "metric", modules: [ { module: 'MMM-homeassistant-sensors', position: 'bottom_left', config: { host: "xxx.xxx.xxx.xxx", token: "xxxxx" , port: "8123", https: false, prettyName: false, stripName: false, debuglogging: false, title: "Rolladen zu", useModuleTigger: false, class: "Shutter", sections: [ ...perimeterWindowSections, ] } }, { module: 'MMM-homeassistant-sensors', position: 'bottom_center', config: { host: "xxx.xxx.xxx.xxx", port: "8123", https: false, token: "xxx" , prettyName: false, stripName: false, debuglogging: false, title:" Fenster", values: [{ sensor: "binary_sensor.fensterkontakt_ankleide_contact", name: "Ankleide", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_babsy_garten_contact", name: "Arbeitszimmer Unten Garten", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_babsy_strasse_contact", name: "Arbeitszimmer Unten Straße", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_ben_contact", name: "Ben", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_kuche_esszimmer_contact", name: "Essen/Wohnen", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_bad_ug_contact", name: "Gäste Bad", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_hannah_contact", name: "Hannah", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_kuche_contact", name: "Küche", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_esszimmer_contact", name: "Küche/Esszimmer", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_ankleideschlafzimmer_contact", name: "Schlafen/Ankleide", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_schlafzimmer_contact", name: "Schlafzimmer", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_wohnzimmer_contact", name: "Wohnzimmer", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.tur_garage_door", name: "Garage Tür", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_karl_contact", name: "Arbeitszimmeroben", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.fensterkontakt_bad_og_contact", name: "Bad OG", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.eingangstur_kontakt_contact", name: "Eingangstür", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.nuki_garage_locked", name: "Nuki Garage", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "binary_sensor.nuki_htr_locked", name: "Nuki HTR", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] }, ] }, }, { module: 'MMM-homeassistant-sensors', position: 'bottom_right', config: { host: "xxx.xxx.xxx.xxx", port: "8123", https: false, token: "xxx" , prettyName: false, stripName: false, debuglogging: false, title:" Rolladen", values: [{ sensor: "cover.wohnzimmer", name: "Wohnzimmer", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] }, { sensor: "cover.schlafzimmer", name: "Schlafzimmer", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] }, { sensor: "cover.hannah", name: "Hannah", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.ben", name: "Ben", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.ankleide", name: "Ankleide", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.babsygarten", name: "Arbeitszimmer Unten Garten", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.babsystrasse", name: "Arbeitszimmer Unten Straße", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.essen_wohnen", name: "Esszimmer Wohnzimmer", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.gastebad", name: "Bad unten", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.kuche", name: "Küche", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.kuche_esszimmer", name: "Küche/Esszimmer", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] },{ sensor: "cover.schlafen_ankleide", name: "Schlafzimmer/Ankleide", alertThreshold: 50, icons: [{ "default": "window-shutter" } ] }, ] }, }, ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") {module.exports = config;} -
this is the code, I would like if a fixed is closed (status false) that this is not displayed. Unfortunately this was not displayed in your link.
-
@DrKaMo said in Visibility of variables:
I would like if a fixed is closed (status false)
what is a ‘fixed’?
-
@sdetweil I only want to display the windows that are open. I have already tried this link but apparently my variable does not have the state bit but only the bit itself.
-
@DrKaMo I have a garage door that is a ‘cover’ type device
my config (copied from the sample )
let perimeterWindowSections = []; perimeterWindows.forEach((item, i) => { perimeterWindowSections.push({ triggerEntities: [ item.entity ], displayTemplate: ` {% if states.${item.entity}.state == "open" %}<i class='mdi mdi-window-open'></i> ${item.name}{% endif %} `, class: "window" }); });and it changes immediately when the door is opened and closed…
if I change entity state === ‘closed’ then it shows(as it IS closed) when closed , and not if its ‘open’
the module config itself
{ module: 'MMM-HomeAssistantDisplay', position: 'top_right', classes:"page2", config: { host: "xxx", token: "..", port: 8123, useTLS: false, title: "Open Windows", useModuleTigger: false, class: "windows", sections: [ ...perimeterWindowSections, ] }, },I also used a light switch
{% if states.${item.entity}.state == "on" %}<i class='mdi mdi-window-open'></i> ${item.name}{% endif %}and it worked as expected, and the MM display responded immediately
so it looks like just getting the entity state value is what you need
if the entity is a switch , the states are on and off
if the entity is a cover, then the states are open and closed
and I checked with a binary sensor{ entity: "binary_sensor.athom_garage_door_status", name:"fooo" }and it is on or off
-
@DrKaMo did you resolve this?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login