用docker快速建立自己的魔镜软件系统
最近一直在研究hass的控制中心,前两天搞定了用闲置surfaceRT显示TileBoard作为控制中心,今天又研究了各位大神的魔镜教程,由于手里没有镜子,就先琢磨着搞定软件部分,至于硬件部分可以参考墨澜大神的教程。
在魔镜项目里看到魔镜系统支持docker运行浏览器访问,自己研究了一下,成功在浏览器里显示出魔镜界面,基本的功能都实现了,天气调用自带的api不太稳定,全屏幕后就能看到效果了,可以直接在pad或电脑上浏览器调出,如果再来一张镜面贴膜贴上,是不是简易的魔镜就实现了
【效果图】
【简易教程】
1. docker安装
docker run -d \
--publish 8088:8080 \
--restart always \
--volume ~/magic_mirror/config:/opt/magic_mirror/config \
--volume ~/magic_mirror/modules:/opt/magic_mirror/modules \
--name magic_mirror \
bastilimbach/docker-magicmirror
浏览器:docker的IP:8088就能访问了
2. 配置文件
* Magic Mirror 配置文件样例
var config = {
address: "0.0.0.0",
port: 8080,
ipWhitelist: [],
language: "zh-cn",
timeFormat: 24,
units: "metric",
modules: [
{
module: "newsfeed",
position: "bottom_bar",
config: {
lengthDescription: 100,
showDescription: true,
feeds: [
{
title: "IT之家",
url: "https://www.ithome.com/rss/",
encoding: "UTF-8"
},
{
title: "少数派",
url: "https://sspai.com/feed",
encoding: "UTF-8"
},
]
}
},
{
module: "updatenotification",
position: "top_center",
config: {
updateInterval: 3600000,// 1h
}
},
{
module: "currentweather",
position: "top_right",
config: {
location: "city",
locationID: "",
appid: "12b2817fbec86915a6e9b4dbbd3d9036",
showHumidity: true,
showFeelsLike: false,
}
},
{
module: "weatherforecast",
position: "top_right",
config: {
location: "city",
locationID: "",
appid: "12b2817fbec86915a6e9b4dbbd3d9036",
maxNumberOfDays: 6,
}
},
{
module: "compliments",
position: "lower_third",
config: {
compliments: {
anytime: [
"女神,又见面了 !"
],
morning: [
"美女, 早上好 !",
"享受享受美好的一天 !",
"睡得好吗 ?"
],
afternoon: [
"你好,美女 !!",
"你看起来好苗条 !",
"今天的你真美 !"
],
evening: [
"晚上好,女神 !",
"你真美 !",
"好美的人儿 !"
]
}
}
},
{
module: "clock",
position: "top_left",
config: {
showPeriodUpper: true,
}
},
{
module: 'MMM-homeassistant-sensors',
position: 'top_left',
config: {
title: '生活讯息',
url: 'https://HASS地址/api/states?api_password=密码',
prettyName: false,
stripName: false,
values: [
{
sensor: "sensor.temperature_xxxxx",
icons: [{
"default": "temperature-celsius"
}
]
},
{
sensor: "sensor.humidity_xxxx",
icons: [{
"default": "water-percent",
}
]
},
{
sensor: "sensor.wenhualu_traffic",
icons: [{
"default": "traffic-light"
}
]
},
{
sensor: "sensor.phicomm_balance",
icons: [{
"default": "scale-bathroom",
}
]
},
]
}
},
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {module.exports = config;}
3. MMM-homeassistant-sensors第三方插件
cd ~\MagicMirror\modules
git clone https://github.com/leinich/MMM-homeassistant-sensors.git
4. AirQuality空气质量第三方插件
cd ~/MagicMirror/modules
git clone https://github.com/CFenner/MMM-AirQuality