Skip to main content

Posts

12 Factor Config for .Net on Mono in a Docker

Recently I've been thinking about how to run a .Net application using Mono inside a Docker, along with this we'd like to use Twelve Factor config . Whilst it is possible to use some library to access environment variables instead of using appSettings it becomes difficult for database and message broker URLs which other libraries may expect to find within the App.config or Web.config file. The solution I came up with follows: Build the application without  an App.config  moving the existing configuration file renaming it App.config.template .  Substitute any environment variables you want with ${} .  E.g: <amqp> <connections> < connection name="rabbit" server="${RABBITMQ_URL}" password="${RABBITMQ_PASSWORD}" /> </connections> </amqp> Include within the Docker image a script named sub.sh similar to this and add it to /conf : #!/bin/sh while read line do eval echo ...

Howto: Node-RED Change Hue Lights Temporarily On Door Open

We fitted a LightwaveRF magnetic sensor to a door to detect whether it is open or closed. The main driver behind this was to increase the level of the hallway lights for a predetermined period of time whenever the door was opened. Since we’re using coloured lights it makes sense to put the light back to how it was once the time period as elapsed.  Node-RED does not offer a node as a means of storing state between, but it does offer functions which have access to a context object which can be used to store state between flows.  I’ve created a flow which listens to the `domoticz/out` MQTT topic filters messages based on their Domoticz IDX value and furthers filters on the door switches `nvalue` where 1 indicates door open and 0 indicates door closed.  https://dl.dropboxusercontent.com/u/174818/FrontDoorLight.json On Door Open: Retrieve state of current light and if nothing already stored, store the current bulb state in the context.  Change the ...

Howto: Node Red Subflow for Hue Bulbs

When writing some flows for Node-RED controlling my Philips Hue bulbs; I wanted to read from a bulb do some work then write that same colour back to the bulb. When you perform a GET on a bulb, you get all of the information, whilst good this means it is a bit more inconvenient to PUT that back into a bulb as that API has a slightly different resource shape where the colour mode is determined by which values are submitted. After using a group of nodes in one flow which did exactly this, I needed the same block in another flow. So I created a sub flow by selected those nodes, clicking the hamburger menu in the top right and choosing 'Subflows > Selection to Subflow'. This replaces the selected nodes with a single node which you can edit in a 'subflows' menu group in the left pane. Download this selection and make your own subflow: https://dl.dropboxusercontent.com/u/174818/HueInputToOutput.json?dl=1

Automatic Kitchen Lights

We recently purchased Hue bulbs for our Kitchen they’re great, but since we already have an RFXCom 433 unit (as per my blog on automating hifi), we wanted to automate the lights and invested in a Lightwave PIR motion sensor.  I downloaded Domoticz [ http://domoticz.com/ ] on an SD Card for my Raspberry PI and also installed node-red [ http://nodered.org/ ] a tool for filtering and processing MQTT messages.  Domoticz is used to store the state of the motion sensor and is configured to emit an MQTT message whenever the state changes.  We also wanted the lights to have a different colour depending on the time of day we enter the kitchen, for example during the evening we might want a relaxing light, meal times a white light above the dining table and during the day some multi coloured lights, but not change them if they've already on.  For each of the time slots of the day, a template has been created containing the settings of each of th...

Linn DS Homebrew RCU with Playlist Support

After installing a hidden Linn DS for my bathroom, I found controlling it tricky, whilst using the phone is okay, I'd still like the convenience of a remote to switch off the music on the way out. I worked around this problem by extending the alarm clock functionality already in use for my kitchen to include a 'set standby' option. This would place the bathroom DS into standby mode at known times. Not ideal, but more useful. The Linn solution to this is a control panel on the wall which offers volume, power and a remote IR sensor. Whilst this gives me the ability to switch off on the way out. It would mean having a remote control in the bathroom to change source and not something I'd like. Since I'd added functionality to schedule stored playlists to start as well as the radio I convinced myself I also wanted the ability to preload a known selection of music at the press of a button. I'm a coder and after watching the RI Christmas lectures on 'hacking yo...

Test Driven Development

Recently I watched David Heinemeier Hanson's controversial railsconf keynote and I thought I'd express my views. His main argument suggests TDD is dead. Oddly I agree with many of his headline views which I try to document below. I just not convinced of his supporting arguments. DHH appears to have a dim view on TDD practicing developers; whom he generalises write simple unit tests having 100% code coverage, use many mocks, but test nothing real. His example was a bug in Basecamp which lost customer data, their code had 100% code coverage, but still didn't work. I really doubt there are many developers who just stop when they hit 100% unit test coverage? I'm not going to speak for everyone else; I only started using TDD (not exclusively) about 18 months ago despite 12 years developer experience writing some really cool stuff, some well designed and some not so well... The well designed stuff has tended to be driven by TDD. I've never used code metrics, I use...

Linn DS Alarm Function

Update 2014 - An alternative to this is available on GitHub which uses Node.js and should be cross platform. Linn DS Playlist and Alarm Server Switching the radio on in the kitchen in the morning is a low priority amongst setting table, pouring cereals, carrying children, etc. The Sonos has an alarm clock facility which allows you to switch on the radio at a set time avoiding hassle of starting a controller. When I upgraded to my Linn Sneaky DS, I no longer had this function, though the remote control made it easy if I forgot to take my phone downstairs with me. Last week I decided to figure it out. I have a Linux machine which runs Ubuntu and runs all the media servers, backups and network shares. I decided to investigate how to control my DS from the command line. Conveniently, the DS can be controlled via a web api, so after reading the docs and a few examples I was able to switch off and on and change source via Postman (Chrome REST client). I then set about writing...

Asus AT37N7A-I Nvidia ION Linux Configuration

I've been using this excellent motherboard for about 2 years, it has now been disassembled as I had less of a need for a silent PC in the living room after retiring my use of MythTV.  I had Ubuntu installed on this PC and during its lifetime was subjected to many performance tweaks. Rather than delete this work, I've decided to put the files online for other people to use. Sound I wanted digital sound over the HDMI cable so it can be played by either my TV or AV amp; I've played back DTS HD with this configuration, my TV had issues with some sample rates which is why the rate is configured explicitly. asoundrc pcm.!default front pcm.analog-hw { type hw card 0 device 0 } pcm.analog-hw-formatted { type plug slave { pcm analog-hw rate 48000 } } pcm.digital-hw { type hw card 0 device 3 } pcm.digital-hw-formatted { type plug slave { pcm digital-hw rate 48000 } } pcm.hdmi_softvol { type softvol slave.pcm digital-hw-formatt...

Letters and Press Button

We purchased an iPad last year for my son to use and in the year he has become eerily proficient with the touchscreen interface. The educational applications have been very good and still use it for this purpose; however more recently it is being used as a video player... Whilst I'm not particularly against this, I would rather he start creating content rather than merely consuming it. One problem with being used to touchscreen is the keyboard and mouse paradigm is alien - it must be really weird to have to press a keyboard key located somewhere else. I imagine using a keyboard for the first time would be like writing notes on a piece of paper but the ink actually appears on a different pad. Anyway, keyboards are here to stay and I want my son to learn how to use a keyboard as well as learn the alphabet (he is already pretty good at numbers). Therefore as part of my Raspberry Pi setup, I purchased a Duragadget keyboard for my son to use, this has large keys, lower case letters...

Initial Thoughts on an iPad 2 for Toddlers

I'm a bit late to the game here, but I've been swithering over the iPad 2 as an educational device for my son. Whilst I've been an Apple Mac OS X user since 2005, the iPhone and subsequent iOS devices have never appealed and I prefer the Android ecosystem. However in terms of applications - specifically educational ones - nothing can beat iOS, in fact, I wouldn't even consider purchasing an Android tablet. A combination of my son soon being two and the recent black friday sales at the Apple store I felt the time was right to go ahead and purchase one. So I purchased a white iPad 2 with the green smart cover. We've had it in the house now for 1 week and I think it is a great device. I have a few issues, for example why can't the keyboard keys show capitalisation so you see what case you have? There is no haptic feedback unlike HTC when pressing an active part of the screen which means sometimes you don't know if that is really a button or not. Also my son lov...

Dell 5530 / Ericsson f3507g 3G Signal Monitor on Linux

A few months back I made a python script available which monitored the Dell 5530 / Ericsson f3507g mobile broadband modem in Linux providing network, access type and signal information to a file for other programs (such as Conky) to pick up and display the data. I've since updated this program to now use PyGTK to display a status icon indicating the signal strength and the access type. Through this icon the radio state can be changed to enforce 3G only, GPRS only or 3G preferred connections (aswell as turning the radio off). The script should work in tandem to network-manager so you can still get online using something you already use. The only addition is a new status icon with your signal strength - something ModemManager should resolve when it becomes available as standard in a few months time. If you can't wait that long and want signal monitoring, then this is for you! Additionally, if you use vnstat to monitor your bandwidth, clicking the status icon will displ...

Dell 5530/Ericsson f3507g on Linux

A few months back I posted a howto guide on getting this mobile broadband card working with Linux, what I failed to mention was I continued to work on these scripts. I feel it is appropriate to post a status update on what I use now especially given there appears to be no further updates on the NetworkManager front. I no longer use UMTSMon as I found it relied on AT+CSQ for the signal quality and during UMTS and HSPA connections, the f3507g/dell 5530 returns either the previous GPRS value or 99,99 which UMTSMon considers as no connection available. I've used a simplified wvdial.conf scripts and now do the rest of the radio work using python. wvdial.conf # Author: Barry John Williams # Creative Commons Attribute-Share Alike 2.5 UK:Scotland Licence [Dialer defaults] New PPPD = yes Stupid Mode = 1 Modem Type = ACM Modem Modem = /dev/ttyACM1 Init1 = AT Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+CGDCONT=1,"ip","internet" Baud = 460800 I...

Howto: Ubuntu 8.10, Dell 5530, 3G/WWan and GPS

There is an updated howto on the Dell 5530 using my own python based monitoring tool at http://blog.bjw.me.uk/2009/03/dell-5530ericsson-f3507g-on-linux.html Introduction Here is a Howto document for getting the Dell 5530 wwan card working along with the onboard GPS under Ubuntu 8.10. This card does not work conveniently with the bundled Network Manager software, but replacing NetworkManager with other utilities will give the ability to get online using a pretty GUI and not have to resort to using wvdial and the command line... It should also work with the Ericsson f3507g as I believe the Dell 5530 is a rebadged version of this module. Check Hardware First you need to check the modem is detected correctly. On my computer, the modem is detected out of the box by the cdc_acm module and exposes three serial ports (/dev/ttyACM[0,1,2]) for communication. Check by running: dmesg | grep ACM Mine shows the following: [ 34.385302] cdc_acm 1-6:1.1: ttyACM0: USB ACM device [ ...