Home Assistant Integration¶
This page provides an example of how to integrate FrameFi with <Home Assistant> using MQTT.
Prerequisites¶
- MQTT is enabled and configured on your FrameFi device.
- You have a running MQTT broker that is accessible by both Home Assistant and your FrameFi.
- You have the <MQTT integration> set up in Home Assistant.
Configuration¶
To enable MQTT, you must first configure it in the WiFiManager setup page. See Getting Started for more details.
Next, add the following configuration to your configuration.yaml file in Home Assistant.
configuration.yaml
mqtt:
- sensor:
- name: "FrameFi Status"
state_topic: "frame-fi/state"
value_template: "{{ value_json.mode }}"
icon: "mdi:image-frame"
- name: "FrameFi File Count"
state_topic: "frame-fi/state"
value_template: "{{ value_json.sd_card.file_count }}"
unit_of_measurement: "files"
icon: "mdi:file-multiple"
- name: "FrameFi Used Space"
state_topic: "frame-fi/state"
value_template: "{{ (value_json.sd_card.used_size | float / 1024 / 1024 / 1024) | round(2) }}"
unit_of_measurement: "GB"
icon: "mdi:sd"
- name: "FrameFi Total Space"
state_topic: "frame-fi/state"
value_template: "{{ (value_json.sd_card.total_size | float / 1024 / 1024 / 1024) | round(2) }}"
unit_of_measurement: "GB"
icon: "mdi:sd"
- switch:
- name: "FrameFi Display"
state_topic: "frame-fi/display/status"
command_topic: "frame-fi/display/set"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: true
icon: "mdi:monitor"
- select:
- name: "FrameFi Mode"
state_topic: "frame-fi/state"
value_template: "{{ value_json.mode }}"
command_topic: "frame-fi/mode/set"
options:
- "ftp"
- "msc"
optimistic: false
qos: 0
retain: true
icon: "mdi:swap-horizontal"
- button:
- name: "FrameFi Restart"
command_topic: "frame-fi/restart"
payload_press: "RESTART"
icon: "mdi:restart"
- device_tracker:
- name: "FrameFi"
state_topic: "frame-fi/status"
availability_topic: "frame-fi/status"
payload_available: "online"
payload_not_available: "offline"
payload_home: "online"
payload_not_home: "offline"
source_type: "router"
Explanation¶
-
mqtt.sensor:- This creates a new sensor entity in Home Assistant named
FrameFi Status. - It listens to the
frame-fi/statetopic and uses avalue_templateto extract themodefrom the JSON payload. - The icon is set to
mdi:image-frame.
- This creates a new sensor entity in Home Assistant named
-
mqtt.switch:- This creates a new switch entity named
FrameFi Display. - It allows you to turn the FrameFi's display on and off from the Home Assistant UI.
command_topic: When you toggle the switch, it sends eitherONorOFFto theframe-fi/display/settopic.state_topic: It listens to theframe-fi/display/statustopic to get the current state of the display.retain: true: This ensures that the last command is retained by the MQTT broker, so the device will pick up the correct state when it reconnects.
- This creates a new switch entity named
-
mqtt.select:- This creates a new select entity named
FrameFi Mode. - It allows you to switch between
ftpandmscmodes from the Home Assistant UI. command_topic: When you select an option, it sends the selected mode (ftpormsc) to theframe-fi/mode/settopic.state_topic: It listens to theframe-fi/statetopic and uses avalue_templateto extract the currentmodefrom the JSON payload.retain: true: This ensures that the last command is retained by the MQTT broker.
- This creates a new select entity named
-
mqtt.button:- This creates a new button entity named
FrameFi Restart. - When you press the button, it sends
RESTARTto theframe-fi/restarttopic.
- This creates a new button entity named
-
mqtt.device_tracker:- This creates a new device tracker entity named
FrameFi. - It listens to the
frame-fi/statustopic to determine the device's online/offline status. payload_available: When the device publishesonlineto theframe-fi/statustopic, it will be marked ashome.payload_not_available: When the device publishesofflineto theframe-fi/statustopic, it will be marked asaway.source_type: "router": This tells Home Assistant to treat the device as a network-based tracker.
- This creates a new device tracker entity named
-
Additional Sensors:
- The configuration also adds sensors for
File Count,Used Space, andTotal Space. - These sensors also listen to the
frame-fi/statetopic and usevalue_templateto extract their respective values from the JSON payload. - They are configured with appropriate units (
files,GB) and icons.
- The configuration also adds sensors for