Skip to content

Online indicator for remote controllable power plugs in openHAB

Recently I installed a number of new power sockets (like this one). The Hue bridge can not only add each switch to a light group, but also reports each plug as a Thing in openHAB. There I thought it will be a nice touch if openHAB actually reports when it sees a device plugged in. The power socket has a LED which turns on when the plug is on. The Hue bridge reports OFFLINE and ONLINE. That's useful.

The plan is to turn the LED light - and the power plug - on and off for a few second.

 

Continue reading "Online indicator for remote controllable power plugs in openHAB"
  • Twitter
  • Bookmark Online indicator for remote controllable power plugs in openHAB at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Online indicator for remote controllable power plugs in openHAB
  • Bloglines Online indicator for remote controllable power plugs in openHAB
  • Technorati Online indicator for remote controllable power plugs in openHAB
  • Fark this: Online indicator for remote controllable power plugs in openHAB
  • Bookmark Online indicator for remote controllable power plugs in openHAB at YahooMyWeb
  • Bookmark Online indicator for remote controllable power plugs in openHAB at Furl.net
  • Bookmark Online indicator for remote controllable power plugs in openHAB at reddit.com
  • Bookmark Online indicator for remote controllable power plugs in openHAB at blinklist.com
  • Bookmark Online indicator for remote controllable power plugs in openHAB at Spurl.net
  • Bookmark Online indicator for remote controllable power plugs in openHAB at Simpy.com
  • Bookmark Online indicator for remote controllable power plugs in openHAB at blogmarks
  • Bookmark Online indicator for remote controllable power plugs in openHAB with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

openHAB: reset DateTime in rules

In one of my openHAB rules I'm using a timestamp to track when an Item went offline. This is used in my monitoring to let the user (me) know how long the Item is already offline.

Background: we have a couple ChromeCasts in our network. When they are connected to a 5GHz Wi-Fi they are quite unstable and often loose the network connection. Usually the openHAB binding reconnects the device quickly, but it happens that the device stays offline. It might have something to do with the router, but nevertheless I want to know when things go offline.

For this I defined a virtual Switch as DateTime:

DateTime	LivingRoom_OfflineSince		"Offline Since [%tY-%tm-%td%tH:%tM:%tS]"

When the ChromeCast goes offline, this Switch is updated in a rule with the current time:

LivingRoom_OfflineSince.postUpdate( new DateTimeType() )

 

However resetting the DateTime switch when the item comes back online proved to be a small challenge, the documentation is unclear. People write online about "UnDeftype", "UNDEF", "(unknown)", "UnDefType.UNDEF", "UnDefType.NULL" and a couple more.

In the end it's quite easy:

LivingRoom_OfflineSince.postUpdate(NULL)

Just update the Item with NULL. Don't use sendCommand() here, you only want to update the Item, not send a new command to a virtual switch.

  • Twitter
  • Bookmark openHAB: reset DateTime in rules at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg openHAB: reset DateTime in rules
  • Bloglines openHAB: reset DateTime in rules
  • Technorati openHAB: reset DateTime in rules
  • Fark this: openHAB: reset DateTime in rules
  • Bookmark openHAB: reset DateTime in rules at YahooMyWeb
  • Bookmark openHAB: reset DateTime in rules at Furl.net
  • Bookmark openHAB: reset DateTime in rules at reddit.com
  • Bookmark openHAB: reset DateTime in rules at blinklist.com
  • Bookmark openHAB: reset DateTime in rules at Spurl.net
  • Bookmark openHAB: reset DateTime in rules at Simpy.com
  • Bookmark openHAB: reset DateTime in rules at blogmarks
  • Bookmark openHAB: reset DateTime in rules with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Restic backup

Was asked quite a few times how I do my backups with Restic.

For more than 10 years I was using "Duplicity" for backups, but in 2019 I changed to Restic. The main reason for the change was that Duplicity still can't handle "Big Data", as in: larger directories. In 2009 someone opened an issue on the Duplicity bugtracker, and this problem still exists as of today. For about two years I was shifting around the problem, excluding files, trying to make the sigfile smaller. But at some point I decided that it is enough and I need to change the tool.

Duplicity knows two backup modes: "full backup" and "incremental backup". Once in a while you take a full backup, and then you add incremental backups to that full backup. In order to restore a certain backup you need the full backup and the incremental backups. Therefore my go-to mode was to always have two full backups and a couple incremental backups in-between. Even if something goes wrong with the latest full backup, I can still go back to the previous full backup (of course with some changes lost, but that's still better than nothing). When taking a new full backup, the oldest one is only deleted when the new one is completed. Accordingly when a new incremental backup is created, it's a new set of files. Removing the backup removes all the files from this incremental backup. That worked well, but needed scheduling. Over time I wrote a wrapper script around Duplicity, which did schedule new full and incremental backups.

Restic works in a different way. There is no concept of "full backup" and "incremental backup". Basically every backup is a full backup, and Restic figures out which files changed, got deleted, or added. Also it does deduplication: if files are moved around, or appear multiple times, they are not added multiple times into the backup. Deduplication is something which Duplicity can't do. But because Restic can do deduplication, there is no common set of files which belong to a single snapshot. Data blobs from one backup can stay in the repository forever, removing snapshots might not remove any files at all.

Restic on the other hand needs "prune" to remove old data. A snapshot can be removed according to the policy specified, but this does not remove the data from the backup directory. A "prune" run will go over the data and remove any block which is no longer needed.

My first question - after figuring out which other backup tool to use: shall I replicate the wrapper script, or try something else? Given that the backup doesn't need complex scheduling, I decided against writing a complex wrapper. And since I am now deploying all devices with Ansible, I decided to integrate this into my Playbooks, and deploy a set of shell scripts. The goal was to have a small number of dedicated scripts doing the daily backup work, and another set of "helper" scripts which I can use to inspect the backup, modify it, or restore something.

My main goals for this: "small number of programs/scripts" (Unix style: each tool does one job), "rapid development" (don't spend weeks writing another scheduler), "rapid deployment" (re-run Playbooks and let Ansible deploy this to all devices).

 

Continue reading "Restic backup"
  • Twitter
  • Bookmark Restic backup at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Restic backup
  • Bloglines Restic backup
  • Technorati Restic backup
  • Fark this: Restic backup
  • Bookmark Restic backup at YahooMyWeb
  • Bookmark Restic backup at Furl.net
  • Bookmark Restic backup at reddit.com
  • Bookmark Restic backup at blinklist.com
  • Bookmark Restic backup at Spurl.net
  • Bookmark Restic backup at Simpy.com
  • Bookmark Restic backup at blogmarks
  • Bookmark Restic backup with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...'

The openHAB rule system is not very helpful by pointing out when it's missing something, or when there is an error to actually point to the problem.

Was debugging an error message for a while and couldn't figure out what is wrong:

Configuration model '....rules' has errors, therefore ignoring it: [152,5]: no viable alternative at input '...'

The line number specified was somewhere else in the file, and had nothing to do with the rule in question. After removing almost everything from the rule, except a logInfo() message, the error still happened - and then it occured to me: I forgot to specify "Item".

My faulty code was:

rule "Rule Name"
when
    Sensor_name received update
then

where it should have been:

rule "Rule Name"
when
    Item Sensor_name received update
then

Error message totally not helpful ...

  • Twitter
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...'
  • Bloglines openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...'
  • Technorati openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...'
  • Fark this: openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...'
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' at YahooMyWeb
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' at Furl.net
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' at reddit.com
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' at blinklist.com
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' at Spurl.net
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' at Simpy.com
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' at blogmarks
  • Bookmark openHAB: Configuration model '....rules' has errors, therefore ignoring it: no viable alternative at input '...' with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

OpenStreetMap: Find benches with missing access tag in JOSM

As reference for me: find benches with missing access tag in JOSM when editing OpenStreetMap:

amenity=bench -access=* inview

 

  • Twitter
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg OpenStreetMap: Find benches with missing access tag in JOSM
  • Bloglines OpenStreetMap: Find benches with missing access tag in JOSM
  • Technorati OpenStreetMap: Find benches with missing access tag in JOSM
  • Fark this: OpenStreetMap: Find benches with missing access tag in JOSM
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM at YahooMyWeb
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM at Furl.net
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM at reddit.com
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM at blinklist.com
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM at Spurl.net
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM at Simpy.com
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM at blogmarks
  • Bookmark OpenStreetMap: Find benches with missing access tag in JOSM with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

OpenStreetMap: Find buildings with missing tags in JOSM

As reference for me: find buildings with missing tags in JOSM when editing OpenStreetMap:

building=* -"roof:colour"
building=* -"roof:shape"

 

  • Twitter
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg OpenStreetMap: Find buildings with missing tags in JOSM
  • Bloglines OpenStreetMap: Find buildings with missing tags in JOSM
  • Technorati OpenStreetMap: Find buildings with missing tags in JOSM
  • Fark this: OpenStreetMap: Find buildings with missing tags in JOSM
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM at YahooMyWeb
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM at Furl.net
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM at reddit.com
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM at blinklist.com
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM at Spurl.net
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM at Simpy.com
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM at blogmarks
  • Bookmark OpenStreetMap: Find buildings with missing tags in JOSM with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Django: Change or translate the app name in the admin menu

Let's say I have a Django app "users". The admin menu shows this as category "Users". That's ok, but if the website users speak another language I want this name translated. Also I'm not necessarily using "Users" as name in the admin menu as section name, but can use something more descriptive. "Website Users", as example.

 

Continue reading "Django: Change or translate the app name in the admin menu"
  • Twitter
  • Bookmark Django: Change or translate the app name in the admin menu at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Django: Change or translate the app name in the admin menu
  • Bloglines Django: Change or translate the app name in the admin menu
  • Technorati Django: Change or translate the app name in the admin menu
  • Fark this: Django: Change or translate the app name in the admin menu
  • Bookmark Django: Change or translate the app name in the admin menu at YahooMyWeb
  • Bookmark Django: Change or translate the app name in the admin menu at Furl.net
  • Bookmark Django: Change or translate the app name in the admin menu at reddit.com
  • Bookmark Django: Change or translate the app name in the admin menu at blinklist.com
  • Bookmark Django: Change or translate the app name in the admin menu at Spurl.net
  • Bookmark Django: Change or translate the app name in the admin menu at Simpy.com
  • Bookmark Django: Change or translate the app name in the admin menu at blogmarks
  • Bookmark Django: Change or translate the app name in the admin menu with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Django: Remove default entries from admin menu

The Django administration site comes with a couple of default entries, depending on which apps and middleware is installed.

Usually there is at least "Users" and "Groups", and if the quite common "allauth" is installed, then there is also "Site", "SocialApp", "SocialAccount", and "SocialToken". They are not always necessary, especially when no Social Login is used. Or why have the "Site" administration when only Site=1 is used?

With a few tricks these can be removed from the admin menu.

 

Continue reading "Django: Remove default entries from admin menu"
  • Twitter
  • Bookmark Django: Remove default entries from admin menu at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Django: Remove default entries from admin menu
  • Bloglines Django: Remove default entries from admin menu
  • Technorati Django: Remove default entries from admin menu
  • Fark this: Django: Remove default entries from admin menu
  • Bookmark Django: Remove default entries from admin menu at YahooMyWeb
  • Bookmark Django: Remove default entries from admin menu at Furl.net
  • Bookmark Django: Remove default entries from admin menu at reddit.com
  • Bookmark Django: Remove default entries from admin menu at blinklist.com
  • Bookmark Django: Remove default entries from admin menu at Spurl.net
  • Bookmark Django: Remove default entries from admin menu at Simpy.com
  • Bookmark Django: Remove default entries from admin menu at blogmarks
  • Bookmark Django: Remove default entries from admin menu with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Huginn: Monitor changes in websites

The Huginn software is not only good for monitoring Twitter feeds, it can also be used to monitor websites for changes.

That's actually easy and needs only two agents:

 

 

Continue reading "Huginn: Monitor changes in websites"
  • Twitter
  • Bookmark Huginn: Monitor changes in websites at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Huginn: Monitor changes in websites
  • Bloglines Huginn: Monitor changes in websites
  • Technorati Huginn: Monitor changes in websites
  • Fark this: Huginn: Monitor changes in websites
  • Bookmark Huginn: Monitor changes in websites at YahooMyWeb
  • Bookmark Huginn: Monitor changes in websites at Furl.net
  • Bookmark Huginn: Monitor changes in websites at reddit.com
  • Bookmark Huginn: Monitor changes in websites at blinklist.com
  • Bookmark Huginn: Monitor changes in websites at Spurl.net
  • Bookmark Huginn: Monitor changes in websites at Simpy.com
  • Bookmark Huginn: Monitor changes in websites at blogmarks
  • Bookmark Huginn: Monitor changes in websites with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Django: disable inline option to add new referenced objects

The Django Web Framework makes it quite easy to add new referenced objects in the admin menu.

Let's say the model has two foreign keys in it:

class TeamMember(models.Model):
    team = models.ForeignKey(Team, on_delete=models.CASCADE, verbose_name=_("Team"))
    user = models.ForeignKey(CustomUser, on_delete=models.CASCADE, verbose_name=_("User"))

And the admin form:

class TeamMemberForm(forms.ModelForm):
    class Meta:
        model = TeamMember

class CustomTeamMemberAdmin(admin.ModelAdmin):
    form = TeamMemberForm
    add_form = TeamMemberForm
    model = TeamMember
    fieldsets = [
        (None,      {'fields': ['team', 'user']}),
    ]

admin.site.register(TeamMember, CustomTeamMemberAdmin)

Then Django will show small a small green "Django add reference" sign next to the fields:

Continue reading "Django: disable inline option to add new referenced objects"
  • Twitter
  • Bookmark Django: disable inline option to add new referenced objects at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Django: disable inline option to add new referenced objects
  • Bloglines Django: disable inline option to add new referenced objects
  • Technorati Django: disable inline option to add new referenced objects
  • Fark this: Django: disable inline option to add new referenced objects
  • Bookmark Django: disable inline option to add new referenced objects at YahooMyWeb
  • Bookmark Django: disable inline option to add new referenced objects at Furl.net
  • Bookmark Django: disable inline option to add new referenced objects at reddit.com
  • Bookmark Django: disable inline option to add new referenced objects at blinklist.com
  • Bookmark Django: disable inline option to add new referenced objects at Spurl.net
  • Bookmark Django: disable inline option to add new referenced objects at Simpy.com
  • Bookmark Django: disable inline option to add new referenced objects at blogmarks
  • Bookmark Django: disable inline option to add new referenced objects with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca