I thought it can not be worse but since yesterday ...
Down: 1113 kbit/s
Up: 636 kbit/s
2016-03-08
2016-01-10
Setup/Configuration for another Magic Mirror
Labels:
Electronic,
Home,
Linux,
Raspberry PI
Note: Unfortunately, a glitch from the TV, which sometimes occurred before, seems now to be manifested. The TV doesn't power on anymore, neither using remote control nor buttons. I couldn't find a faulty component on TV circuit board. I will/have to stop this project. However, I have learned a lot, so it was not wasted time.
General setup
- Raspberry PI 2
- SEG ArtColor TV
- PIR module (GPIO 17, 18), IR transmitter (GPIO 4)
The PIR module will detect motion. If a motion is sense the TV will be switched on via the IR transmitter (simulation of IR remote). After a predefined timeout periode without further motion the TV will switched off (to standby).
Install and enable lirc
-
install
lircsudo apt-get install lirc
- enable
lircmodule - edit/boot/config.txtdtoverlay=lirc-rpi,gpio_out_pin=4,gpio_in_pin=22
- configure
lirc- edit/etc/lirc/hardware.confLIRCD_ARGS="" ... DRIVER="default" DEVICE="/dev/lirc0" MODULES="lirc_rpi"
Setup IR command to power on/off the TV
- learn IR command
irrecord -d /dev/lirc0 ~/lircd.conf
- copy new file
sudo cp ~/lircd.conf /etc/lirc/lircd.conf
- edit the name parameter in
/etc/lirc/lircd.confI choose magicmirror - start
lircpi@mamomami /etc/lirc $ sudo /etc/init.d/lirc start [ ok ] Loading LIRC modules:. [ ok ] Starting remote control daemon(s) : LIRC :.
- check if IR command is available
pi@mamomami /etc/lirc $ irsend LIST "magicmirror" "" irsend: 00000000000043bc KEY_POWER
- run
lircservice on start upsudo update-rc.d lirc defaults
2016-01-08
Ansible: using numbered backreference followed by digit in lineinfile
While playing around with Ansible I've stumbled over a problem with backreferences followed by a digit.
A possible ansible playbook may look as follows:
But the result is:
The problem is that the backreference
The following playbook shows all three variants.
For the example file
Update 2019-10-29: Replace inline code by embedded github gist to fix issue with not shown group in example.
The problem
I've want to modify some lines in a file like this:# an example something=xxxxLets assume I want to update the xxxx with some values.
A possible ansible playbook may look as follows:
---
- hosts: localhost
tasks:
- name: create file
copy: src=./demo dest=/tmp/demo
- name: update xxxx
lineinfile:
dest: /tmp/demo
regexp: '^(.*)xxxx'
line: '\1{{ansible_date_time.year}}'
backrefs: yes
state: present
The update task "update xxxx" should inspect the file, search for the line with "xxxx" and replace the "xxxx" while keeping the part in front of it. But the result is:
# an example P16
The problem is that the backreference
\1 is not resolved as expected but merged with (some) of the year digits. This results in the "P".Solution
To solve it you have to use named groups. A named group is defined by(?P<name>pattern) and can than be reference with \g<1> or \g<name>
The following playbook shows all three variants.
For the example file
# an example simple backref=xxxx group backref with number=yyyy group backref with name=zzzzthe generated output is:
# an example P16 group backref with number=2016 group backref with name=2016
Update 2019-10-29: Replace inline code by embedded github gist to fix issue with not shown group in example.
2015-10-23
Magic-Mirror: OpenWeatherMap Fix und TimeStamp bei den News
Labels:
Electronic,
make,
maker,
Raspberry PI
Wegen einer Änderung der API bei OpenWeatherMap bedurfte mein MagicMirror einer Wartung. Zum Glück waren die Änderungen gering: Beschrieben sind sie schon an anderer Stelle, daher hier nur ein Link auf eine Beschreibung in Deutsch und beim Magic-Mirror Autor.
Daneben habe ich die Gelegenheit gleich genutzt, um die Anzeige der News um die Angabe der Veröffentlichungszeit zu ergänzen. Das ganze sieht jetzt so aus:
Das GitHub Projekt ist entsprechend aktualisiert - wer will ... bitte schön.
Daneben habe ich die Gelegenheit gleich genutzt, um die Anzeige der News um die Angabe der Veröffentlichungszeit zu ergänzen. Das ganze sieht jetzt so aus:
Das GitHub Projekt ist entsprechend aktualisiert - wer will ... bitte schön.
2015-10-11
Get the current role name in an Ansible Role
Since Ansible 1.8 the variable
role_path returns the current role's pathname (see Ansible docs). Use the basename filter to extract the role name.{{ role_path | basename }}
Note: role_path is only defined inside a role.
2015-10-03
Install inadyn-mt on CentOS7
(Update: see post "Updated inadyn-mt package for CentOS7")
I didn't found an inadyn-mt rpm package for CentOS7. So I built one myself:
I didn't found an inadyn-mt rpm package for CentOS7. So I built one myself:
- Download the source rpm for Fedora 22.
- Install the source rpm
rpm -i inadyn-mt-2.24.44-1.fc22.src.rpm
- The sources are installed in the ~/rpmbuild directory.
- Move to the rpmbuild directory and run rpmbuild
cd ~/rpmbuild/SPECS rpmbuild -ba inadyn-mt.spec
- That's all. The rpm can now be installed with
rpm -i ~/rpmbuild/RPMS/x86_64/inadyn-mt-2.24.44-1.el7.centos.x86_64.rpm
2015-09-27
ssh-add complains: Could not open a connection to your authentication agent
When running an ansible playbook a series of ssh connections is used to perform the different playbook actions. Each ssh connection requires the ssh-key passphrase to be entered. The default way to avoid this is to use ssh-agent. The ssh-agent stores your passphrase and send it to ssh if needed. To import a key into ssh-agent you use ssh-add.
I try it for my ansible experiments where ansible is running in a docker container (see my previous posts)
docker run --rm -i -t -v $(pwd):/data -w /data thomo/ansible bash -c "ssh-add deploy__2015 && ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=newhosts.keys -i ./deploy__2015' ansible-playbook site.yml -i ./inventories/hosts.baremetal" Could not open a connection to your authentication agent.Seams that there is no ssh-agent running. The agent can be start with
eval $(ssh-agent)But you have to take care, that the evaluation is postponed to shell in the docker - and not be done already in the host shell. So put it in single quotes:
$ ./dr 'eval $(ssh-agent) && ssh-add ./deploy__2015 && ANSIBLE_SSH_ARGS="-o UserKnownHostsFile=newhosts.keys -i ./deploy__2015" ansible-playbook site.yml -i ./inventories/hosts.baremetal' Agent pid 8 Enter passphrase for ./deploy__2015: Identity added: ./deploy__2015 (./deploy__2015) PLAY [apply common configuration to all nodes] ************************* ...dr is a small script which wraps the docker run parameter
docker run --rm -i -t -w /data -v $(pwd):/data thomo/ansible bash -c "$*"
Update 2016-01-06
Improveddr script
SSHPARAM='eval $(ssh-agent) && ssh-add ./deploy__2015 && ANSIBLE_SSH_ARGS="-o UserKnownHostsFile=newhosts.keys -i ./deploy__2015"'
docker run --rm -i -t -w /data -v $(pwd):/data thomo/ansible:20160106 sh -c "${SSHPARAM} $*"
Example usage:
$ ./dr "ansible server -u deploy -m ping -i ./inventories/hosts.baremetal"
Agent pid 9
Enter passphrase for ./deploy__2015:
Identity added: ./deploy__2015 (./deploy__2015)
10.0.0.1 | success >> {
"changed": false,
"ping": "pong"
}
Abonnieren
Posts (Atom)
