I am trying to get a switch created for displaying a module on my MagicMirror. I have the on and off working but I would like to get the status working but am struggling with the nested JSON and getting the state value template to work. Anyone have ideas on how to parse this JSON with a value template?
ON = hidden: false
OFF = hidden:true
If its easier I can reverse the switch be module_hidden to match off with false and on with true if it helps.
Switch YAML
##########################################################
## MagicMirror Weekend Chore Switch
##########################################################
- platform: command_line
switches:
magicmirror_weekend_chores_display:
command_on: "curl -X GET 'http://192.168.Y.XX:8080/api/module/module_5_MMM-HomeAssistantDisplay/show'"
command_off: "curl -X GET 'http://192.168.Y.XX:8080/api/module/module_5_MMM-HomeAssistantDisplay/hide'"
# command_state: "curl -X GET http://192.168.Y.XX:8080/api/module/module_5_MMM-HomeAssistantDisplay/"
# value_template: "{{ value_json.data.hidden == 'false' }}"
JSON RETURNED ON STATE CALL
{
"success": true,
"data": [
{
"index": 5,
"identifier": "module_5_MMM-HomeAssistantDisplay",
"name": "MMM-HomeAssistantDisplay",
"path": "modules/MMM-HomeAssistantDisplay/",
"file": "MMM-HomeAssistantDisplay.js",
"position": "top_left",
"configDeepMerge": false,
"config": {
"title": "Weekend Chores",
"host": "XXXXXXXXX",
"port": 443,
"useTLS": true,
"ignoreCert": true,
"token": "XXXX.XXXXXXX.XXXXX_XXXXX",
"debuglogging": false,
"useModuleTigger": false,
"moduleTriggerTemplate": "",
"moduleTriggerEntities": false,
"animationSpeed": 3000,
"sections": [
{
"triggerEntities": [
"input_boolean.chore_xxx_bedroom_cleaned",
"input_boolean.chore_xxx_bathroom_cleaned",
"input_boolean.chore_yyy_bedroom_cleaned",
"input_boolean.chore_yyy_bathroom_cleaned"
],
"displayTemplate": "\n {%- if states.input_boolean.chore_xxx_bedroom_cleaned.state == \"off\" -%}\n <div> <i class='mdi mdi-bed'></i> xxx Bedroom </div>\n {%- endif -%}\n {%- if states.input_boolean.chore_xxx_bathroom_cleaned.state == \"off\" -%}\n <div> <i class='mdi mdi-toilet'></i> xxx Bathroom </div>\n {%- endif -%}\n {%- if states.input_boolean.chore_yyy_bedroom_cleaned.state == \"off\" -%}\n <div> <i class='mdi mdi-bed'></i> yyy Bedroom </div>\n {%- endif -%}\n {%- if states.input_boolean.chore_yyy_bathroom_cleaned.state == \"off\" -%}\n <div> <i class='mdi mdi-toilet'></i> yyy Bathroom </div>\n {%- endif -%} \n ",
"class": "ha-name",
"render": "<div> <i class='mdi mdi-bed'></i> xxx Bedroom </div><div> <i class='mdi mdi-toilet'></i> xxx Bathroom </div><div> <i class='mdi mdi-bed'></i> yyy Bedroom </div><div> <i class='mdi mdi-toilet'></i> yyy Bathroom </div>"
}
],
"class": "chores",
"identifier": "module_5_MMM-HomeAssistantDisplay"
},
"classes": "MMM-HomeAssistantDisplay",
"hidden": true,
"lockStrings": [
"module_13_MMM-Remote-Control"
]
}
]
}```