home-assistant: move out of module
This commit is contained in:
94
hosts/pi/home-assistant/floorplan/default.nix
Normal file
94
hosts/pi/home-assistant/floorplan/default.nix
Normal file
@ -0,0 +1,94 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.modules.services.home-assistant;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.home-assistant = {
|
||||
customLovelaceModules = [
|
||||
pkgs.lovelace-floorplan
|
||||
];
|
||||
};
|
||||
|
||||
environment.etc."home-assistant/www/floorplan/style.css".source = ./style.css;
|
||||
environment.etc."home-assistant/www/floorplan/config.yaml".text = builtins.toJSON {
|
||||
image = {
|
||||
location = "/local/floorplan/beetham.svg";
|
||||
cache = false;
|
||||
};
|
||||
stylesheet = {
|
||||
location = "/local/floorplan/style.css";
|
||||
cache = false;
|
||||
};
|
||||
|
||||
defaults = {
|
||||
hover_action = "hover-info";
|
||||
hold_action = "toggle";
|
||||
tap_action = "more-info";
|
||||
};
|
||||
|
||||
rules = [
|
||||
{
|
||||
name = "Rooms";
|
||||
entities = [
|
||||
{
|
||||
entity = "light.bedroom_lamps";
|
||||
element = "area.bedroom";
|
||||
}
|
||||
{
|
||||
entity = "light.hallway_spots";
|
||||
element = "area.hallway";
|
||||
}
|
||||
{
|
||||
entity = "light.living_room_lamps";
|
||||
element = "area.livingroom";
|
||||
}
|
||||
{
|
||||
entity = "light.office_lamps";
|
||||
element = "area.office";
|
||||
}
|
||||
];
|
||||
tap_action = "light.toggle";
|
||||
state_action = {
|
||||
service = "floorplan.class_set";
|
||||
service_data = ''
|
||||
if (entity.state === "on") {
|
||||
return "light-on";
|
||||
}
|
||||
return "light-off";
|
||||
'';
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "Temperature";
|
||||
entities = [
|
||||
"sensor.motion_sensor_temperature"
|
||||
];
|
||||
state_action = [
|
||||
{
|
||||
service = "floorplan.text_set";
|
||||
service_data = ''
|
||||
if (!isNaN(entity.state)) {
|
||||
return Math.round(entity.state * 10) / 10 + "°";
|
||||
}
|
||||
return "Unknown";
|
||||
'';
|
||||
}
|
||||
{
|
||||
service = "floorplan.class_set";
|
||||
service_data = {
|
||||
class = "static-temp";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
27
hosts/pi/home-assistant/floorplan/style.css
Normal file
27
hosts/pi/home-assistant/floorplan/style.css
Normal file
@ -0,0 +1,27 @@
|
||||
#floorplan {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
svg, svg * {
|
||||
vector-effect: non-scaling-stroke !important;
|
||||
pointer-events: all !important;
|
||||
}
|
||||
|
||||
path[id*="area."].light-on {
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
path[id*="area."] {
|
||||
opacity: 0.5 !important;
|
||||
transition: opacity .25s;
|
||||
-moz-transition: opacity .25s;
|
||||
-webkit-transition: opacity .25s;
|
||||
}
|
||||
|
||||
svg tspan {
|
||||
fill: var(--primary-text-color);
|
||||
}
|
||||
|
||||
.static-temp, .static-temp tspan {
|
||||
fill: #ffffff;
|
||||
}
|
Reference in New Issue
Block a user