Skip to content

Latest commit

 

History

History
381 lines (357 loc) · 9.88 KB

README.md

File metadata and controls

381 lines (357 loc) · 9.88 KB

MMM-homeassistant-sensors

This a module for the MagicMirror².

This module can display information from Home Assistant using the home assistant REST API.

Screen shots

Advanced configuration.

Using many of the features:

  • Adding the "value" to the name.
  • Adding time to the name column.
  • Hiding the unit it from the "unit" collumn.
  • Hiding the value in from the "value" collumn.
  • Using "pictures" from the entity.
  • Using different "pictures" for different values.
  • Using different "icons" for different values from the Material Design Font.
  • Replacing "values" with defined values.
  • Setting a "default" icon from the Material Design Font.

Advanced

Installation

In your terminal, go to your MagicMirror's Module folder:

cd ~/MagicMirror/modules

Clone this repository:

git clone https://github.com/Snille/MMM-homeassistant-sensors

Enter the folder:

cd MMM-homeassistant-sensors

Install Node-Modules (The MaterialDesignIcons webfont icon names can be used.).

npm install

Configuration

The configuration can be very simpel, from just displaying a simple value from a senor, to parsing the sensorvalue and changeing it to different pictures depending on the value. It's all up to you.

Configuration Options

Option Deafult Description
prettyName true Pretty print the name of each JSON key (remove camelCase and underscores).
stripName true Removes all keys before the printed key.

Example: a.b.c will print c.
title Home Assistant Title to display at the top of the module.
host REQUIRED hassio.local The hostname or ip adress of the home assistant instance.
port 8321 Port of homeassistant e.g. 443 for SSL.
https REQUIRED false Is SSL enabled on home assistant (true/false)
token REQUIRED The long lived token.
fade 100 When updating the values, this is the time (in milliswconds) the "table" fades out and in again.
updateInterval 300000 The time between updates (in milliseconds) (300000 = 5 minutes).
displaySymbol true If you don't want either "icons" nor "pictures" in your list, set it to false.
displaydates false If you want to show dates for last update by default. This can be turned off or on for each sensor as well.
displaytimes false If you want to show times for last update by default. This can be turned off or on for each sensor as well.
debuglogging false Enable logging into /home/pi/.pm2/logs/mm-error.log (true/false).
values [array{}] Specify specific values from the json feed to only show what you need (entity_id).

Check the options!

Sensor options

Option Type Description
sensor entity_id Entity ID from Home Assistant. Please have a look at the states pages for the unique entity_id of your sensor.
name string You can specify a name that will be displayed instead of the one from HA.
defunit string You can specify a unit that will be displayed instead of the one from HA.
icons [array{}] Define specific icons for spesific values (see example below). You can use the icon names from the: MaterialDesignIcons.
replace [array{}] Define specific values that will be owerriden by the specified values.

Sensor icon options

value Icon Description
value icon-name You can define a specific MaterialDesignIcons icon or the URL to a picture for a specific value.
default icon-name The default icon for the sensor (if nothing else is specified).

Sensor value options

Value New Value Description
value your new value You can define a specific value the will be replaced with this value.

Here is the advanced configuration

{
	module: 'MMM-homeassistant-sensors',
	position: 'top_left',
	config: {
		host: "IP TO HOME ASSISTANT",
		port: "8123",
		https: false,
		token: "YOUR OWN",
		title: 'Husinformation',
		values: [
			{
				sensor: "device_tracker.360_kidswatch_xplora4",
				name: "Louise är %v%",
				displayvalue: false,
				replace: [{
						"home": "hemma",
						"not_home": "ute",
					}
				]
			},
			{
				sensor: "device_tracker.google_maps_109299643857913851232",
				name: "Camilla är %v%",
				displayvalue: false,
				replace: [{
						"home": "hemma",
						"not_home": "ute",
					}
				]
			},
			{
				sensor: "device_tracker.google_maps_105082325528346759172",
				name: "Erik är %v%",
				displayvalue: false,
				replace: [{
						"home": "hemma",
						"not_home": "ute",
					}
				]
			},
			{
				sensor: "sensor.vind_temperature",
				name: "Temp på vinden %t%",
				icons: [{
						"default": "thermometer"
					}
				]
			},
			{
				sensor: "sensor.vind_humidity",
				name: "Fukt på vinden %t%",
				icons: [{
						"default": "water-percent"
					}
				]
			},
			{
				sensor: "sensor.vardagsrum_temperature",
				name: "Temp i Vardagsrummet %t%",
				icons: [{
						"default": "thermometer"
					}
				]
			},
			{
				sensor: "sensor.vardagsrum_humidity",
				name: "Fukt i Vardagsrummet %t%",
				icons: [{
						"default": "water-percent"
					}
				]
			},
			{
				sensor: "sensor.krypgrund_temperature",
				name: "Temp i Krypgrunden %t%",
				icons: [{
						"default": "thermometer"
					}
				]
			},
			{
				sensor: "sensor.krypgrund_humidity",
				name: "Fukt i Krypgrunden %t%",
				icons: [{
						"default": "water-percent"
					}
				]
			},
			{
				sensor: "media_player.snilles_tv",
				name: "Just nu är TV:n",
				icons: [{
						"default": "television-off",
						"off": "television-off",
						"on": "television"
					}
				],
				replace: [{
						"on": "På",
						"off": "Av",
						"unknown": "Av"
					}
				]
			},
			{
				sensor: "sensor.tv_on_today",
				name: "Timmar TV:n varit på idag",
				defunit: " ",
				},
			{
				sensor: "binary_sensor.pet_cappuccino",
				name: "Cappuccino gick %v% %t%",
				displayvalue: false,
				icons: [{
						"off": "http://10.0.0.30/img/magicmirror/users/Cappuccino-Out-60x60.png",
						"on": "http://10.0.0.30/img/magicmirror/users/Cappuccino-In-60x60.png"
					}
				],
				replace: [{
						"on": "in",
						"off": "ut"
					}
				]
			},
			{
				sensor: "sensor.cappuccinos_outside_time_today",
				name: "Timmar ute idag:",
				defunit: " ",
				replace: [{
						"unknown": "0",
					}
				]
			},
			{
				sensor: "sensor.cappuccinos_trips_outside_today",
				name: "Antal gånger ute idag:",
				defunit: " ",
				replace: [{
						"unknown": "0",
					}
				]
			},
			{
				sensor: "sensor.cappuccino_outside_yesterday",
				name: "Timmar ute igår:",
				defunit: " ",
				replace: [{
						"unknown": "0",
					}
				]
			},
			{
				sensor: "sensor.cappuccinos_trips_outside_yesterday",
				name: "Antal gånger ute igår:",
				defunit: " ",
				replace: [{
						"unknown": "0",
					}
				]
			},
			{
				sensor: "binary_sensor.pet_kakan",
				name: "Kakan gick %v% %t%",
				displayvalue: false,
				icons: [{
						"off": "http://10.0.0.30/img/magicmirror/users/Kakan-Out-60x60.png",
						"on": "http://10.0.0.30/img/magicmirror/users/Kakan-In-60x60.png"
					}
				],
				replace: [{
						"on": "in",
						"off": "ut"
					}
				]
			},
			{
				sensor: "sensor.kakans_outside_time_today",
				name: "Timmar ute idag:",
				defunit: " ",
				replace: [{
						"unknown": "0",
					}
				]
			},
			{
				sensor: "sensor.kakans_trips_outside_today",
				name: "Antal gånger ute idag:",
				defunit: " ",
				replace: [{
						"unknown": "0",
					}
				]
			},
			{
				sensor: "sensor.kakan_outside_yesterday",
				name: "Timmar ute igår:",
				defunit: " ",
				replace: [{
						"unknown": "0",
					}
				]
			},
			{
				sensor: "sensor.kakans_trips_outside_yesterday",
				name: "Antal gånger ute igår:",
				defunit: " ",
				replace: [{
						"unknown": "0",
					}
				]
			},
			{
				sensor: "binary_sensor.washing_machine",
				name: "Tvättmaskinen",
				icons: [{
						"off": "washing-machine-off",
						"on": "washing-machine"
					}
				],
				replace: [{
						"on": "På",
						"off": "Av"
					}
				]
			},
			{
				sensor: "binary_sensor.drying_cabinet",
				name: "Torkskåpet",
				icons: [{
						"off": "tumble-dryer-off",
						"on": "tumble-dryer"
					}
				],
				replace: [{
						"on": "På",
						"off": "Av"
					}
				]
			},
			{
				sensor: "binary_sensor.dishwasher",
				name: "Diskmaskinen",
				icons: [{
						"off": "dishwasher-off",
						"on": "dishwasher"
					}
				],
				replace: [{
						"on": "På",
						"off": "Av"
					}
				]
			},
			{
				sensor: "binary_sensor.coffee_maker",
				icons: [{
						"on": "kettle",
						"off": "kettle-off"
					}
				],
				replace: [{
						"on": "På",
						"off": "Av"
					}
				]
			},
			{
				sensor: "binary_sensor.espresso_machine",
				icons: [{
						"off": "coffee-off",
						"on": "coffee"
					}
				],
				replace: [{
						"on": "På",
						"off": "Av"
					}
				]
			}
		]
	}
},

Special Thanks

  • Michael Teeuw for creating the awesome MagicMirror2 project that made this module possible.

  • tkoeberl for creating the initial module that I used as guidance in creating this module.