ma bureautomation: fetch latest xkcd comic
This commit is contained in:
parent
4cb0ff12ba
commit
5ccb8e08e8
@ -3,4 +3,8 @@
|
|||||||
platform = "generic";
|
platform = "generic";
|
||||||
still_image_url = http://127.0.0.1:8123/local/lines.png ;
|
still_image_url = http://127.0.0.1:8123/local/lines.png ;
|
||||||
}
|
}
|
||||||
|
{ name = "XKCD";
|
||||||
|
platform = "generic";
|
||||||
|
still_image_url = http://127.0.0.1:8123/local/xkcd.png ;
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
@ -6,21 +6,29 @@ let
|
|||||||
in {
|
in {
|
||||||
systemd.services.comic-updater = {
|
systemd.services.comic-updater = {
|
||||||
startAt = "daily";
|
startAt = "daily";
|
||||||
description = "Send led change to message queue";
|
description = "update our comics";
|
||||||
after = [ "network-online.target" ] ++ (lib.optional config.services.mosquitto.enable "mosquitto.service");
|
after = [ "network-online.target" ] ++ (lib.optional config.services.mosquitto.enable "mosquitto.service");
|
||||||
path = with pkgs; [ wget xmlstarlet ];
|
path = with pkgs; [ wget xmlstarlet ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "hass";
|
User = "hass";
|
||||||
WorkingDirectory = config.services.home-assistant.configDir;
|
WorkingDirectory = config.services.home-assistant.configDir;
|
||||||
ExecStart = pkgs.writeDash "update-poorly-drawn-lines" ''
|
ExecStart = pkgs.writeDash "update-comics" ''
|
||||||
set -euf
|
set -euf
|
||||||
mkdir -p www/
|
mkdir -p www/
|
||||||
cd www/
|
cd www/
|
||||||
|
# poorly drawn lines
|
||||||
pic=$(wget -O- http://www.poorlydrawnlines.com/feed/ \
|
pic=$(wget -O- http://www.poorlydrawnlines.com/feed/ \
|
||||||
| xml sel -t -v '/rss/channel/item/content:encoded' \
|
| xml sel -t -v '/rss/channel/item/content:encoded' \
|
||||||
| head -n 2 | sed -n 's/.*src="\([^"]\+\)".*/\1/p' )
|
| head -n 2 | sed -n 's/.*src="\([^"]\+\)".*/\1/p' )
|
||||||
wget "$pic" -nc && cp -v "$(basename "$pic")" lines.png
|
wget "$pic" -nc && cp -v "$(basename "$pic")" lines.png
|
||||||
|
|
||||||
|
#pic=$(curl -L xkcd.com 2>/dev/null | grep imgs.xkcd.com | grep title | sed -n 's/.*src="\([^"]\+\)" .*/https:\1/p')
|
||||||
|
# xkcd
|
||||||
|
pic=$(wget -O- https://xkcd.com/rss.xml \
|
||||||
|
| xml sel -t -v '/rss/channel/item/description' \
|
||||||
|
| head -n 1 | sed -n 's/.*src="\([^"]\+\)".*/\1/p' )
|
||||||
|
wget "$pic" -nc && cp -v "$(basename "$pic")" xkcd.png
|
||||||
'';
|
'';
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
};
|
};
|
||||||
|
@ -137,9 +137,9 @@ in {
|
|||||||
++ frosch.binary_sensor
|
++ frosch.binary_sensor
|
||||||
++ aramark.binary_sensor;
|
++ aramark.binary_sensor;
|
||||||
|
|
||||||
sensor =
|
sensor = []
|
||||||
# [{ platform = "version"; }] ++ # pyhaversion
|
++ [{ platform = "version"; }] # pyhaversion
|
||||||
(import ./sensor/pollen.nix)
|
++ (import ./sensor/pollen.nix)
|
||||||
++ (import ./sensor/espeasy.nix)
|
++ (import ./sensor/espeasy.nix)
|
||||||
++ (import ./sensor/airquality.nix)
|
++ (import ./sensor/airquality.nix)
|
||||||
++ ((import ./sensor/outside.nix) {inherit lib;})
|
++ ((import ./sensor/outside.nix) {inherit lib;})
|
||||||
@ -238,6 +238,7 @@ in {
|
|||||||
"camera.Autobahn_Singen"
|
"camera.Autobahn_Singen"
|
||||||
"camera.puppies"
|
"camera.puppies"
|
||||||
"camera.poorly_drawn_lines"
|
"camera.poorly_drawn_lines"
|
||||||
|
"camera.xkcd"
|
||||||
];
|
];
|
||||||
nachtlicht = [
|
nachtlicht = [
|
||||||
"switch.nachtlicht_a"
|
"switch.nachtlicht_a"
|
||||||
|
Loading…
Reference in New Issue
Block a user