Category Archives: Uncategorized

Visual indicator that the gargage door is open with Openhab2 and Homeseer HS-WD200+ zwave

I am using openhab2 running on a centos server in the house with a USB Zwave stick.

I have 2 Monoprice Z-Wave Garage Door Sensor, NO LOGO (D132) Monoprice Z-Wave Garage Door Sensors.

I have been using these excellent dimmers in the house HomeSeer HS-WD100+ Z-Wave Plus Scene Capable Wall Dimmer but recently changed one in the living room to HomeSeer HS-WD200+ Z-Wave Plus Scene Capable RGB Wall Dimmer which has the ability to set the LED color and if an LED will flash or not.

My goal was to have LED 7 flash red when garage door 1 is open, and LED 6 flash green when garage door 2 is open.

I am running openhab2 2.3.0 nightly snapshot openhab2-2.3.0.20180427191516-1.noarch. This may or may not work in earlier versions. I have the Z-Wave Binding installed, and in configuration -> system i have Item Linking – Simple Mode turned off.

Here are the relevant openhab items and rules.

items/motion.items

Group Motion

Number garage_door_1_battery "Garage 1 Battery" (Motion) {channel="zwave:device:9d6ae427:node9:battery-level"}
Contact garage_door_1_motion "Garage 1 Motion [%s]" (Motion) {channel="zwave:device:9d6ae427:node9:sensor_door"}
Switch garage_door_1_tamper "Garage 1 Tamper [%s]" (Motion) {channel="zwave:device:9d6ae427:node9:alarm_burglar"}

Number garage_door_2_battery "Garage 2 Battery" (Motion) {channel="zwave:device:9d6ae427:node11:batter-level"}
Contact garage_door_2_motion "Garage 2 Motion [%s]" (Motion) {channel="zwave:device:9d6ae427:node11:sensor_door"}
Switch garage_door_2_tamper "Garage 2 Tamper [%s]" (Motion) {channel="zwave:device:9d6ae427:node11:alarm_burglar"}

items/tv.items

Group GF (All)
Group BS (All)
Group US (All)
Group gSunset
Group g1am
Group g12midnight
Group gfLights

Dimmer light_tv_dimmer "TV light" (GF,gfLights) [ "Lighting" ] {channel="zwave:device:9d6ae427:node20:switch_dimmer"}
Switch light_tv_switch "TV light switch" (GF,gfLights,gSunset,g1am) [ "Lighting" ] {channel="zwave:device:9d6ae427:node20:switch_dimmer"}

Number tv_mode "TV Mode" {channel="zwave:device:9d6ae427:node20:config_decimal_param13"}
Number tv_led1 "TV LED 1" {channel="zwave:device:9d6ae427:node20:config_decimal_param21"}
Number tv_led2 "TV LED 2" {channel="zwave:device:9d6ae427:node20:config_decimal_param22"}
Number tv_led3 "TV LED 3" {channel="zwave:device:9d6ae427:node20:config_decimal_param23"}
Number tv_led4 "TV LED 4" {channel="zwave:device:9d6ae427:node20:config_decimal_param24"}
Number tv_led5 "TV LED 5" {channel="zwave:device:9d6ae427:node20:config_decimal_param25"}
Number tv_led6 "TV LED 6" {channel="zwave:device:9d6ae427:node20:config_decimal_param26"}
Number tv_led7 "TV LED 7" {channel="zwave:device:9d6ae427:node20:config_decimal_param27"}
Number tv_blink_feq "TV Blink Frequency" {channel="zwave:device:9d6ae427:node20:config_decimal_param30"}
Number tv_led_blink_status "TV Blink Status" {channel="zwave:device:9d6ae427:node20:config_decimal_param31"}

rules/garage.rules

rule "G1Open"
when
Item garage_door_1_motion changed to OPEN
then
logInfo("TEST","G1 ON")
tv_mode.sendCommand(1)
tv_blink_feq.sendCommand(1)
tv_led7.sendCommand(1)

var Integer state = (tv_led_blink_status.state as DecimalType).intValue
var Integer mask = state.bitwiseOr(64)
tv_led_blink_status.sendCommand(mask)
end

rule "G1Closed"
when
Item garage_door_1_motion changed to CLOSED
then
logInfo("TEST", "G1 OFF")
var Integer state = (tv_led_blink_status.state as DecimalType).intValue
var Integer mask = state.bitwiseXor(64)
if (mask == 0){
tv_mode.sendCommand(0)
}
tv_led7.sendCommand(0)
tv_led_blink_status.sendCommand(mask)
end

rule "G2Open"
when
Item garage_door_2_motion changed to OPEN
then
logInfo("TEST","G2 ON")
tv_mode.sendCommand(1)
tv_blink_feq.sendCommand(1)
tv_led6.sendCommand(2)

var Integer state = (tv_led_blink_status.state as DecimalType).intValue
var Integer mask = state.bitwiseOr(32)
tv_led_blink_status.sendCommand(mask)
end

rule "G2Closed"
when
Item garage_door_2_motion changed to CLOSED
then
logInfo("TEST", "G2 OFF")
var Integer state = (tv_led_blink_status.state as DecimalType).intValue
var Integer mask = state.bitwiseXor(32)
if (mask == 0) {
tv_mode.sendCommand(0)
}
tv_led6.sendCommand(0)
tv_led_blink_status.sendCommand(mask)
end

Note: [ “Lighting” ] is for the alexa bridge, gSunset, g1am, g12midnight are used to by other rules to turn on lights at sunset and turn off at 1am or midnight. gfLights is used by the scene controller so if you double tap the Homeseer switch it turns off all the light lights on the ground floor. I have included that below as a bonus.

items/scene.items

Number TVScene "TV Scene" { channel="zwave:device:9d6ae427:node20:scene_number" }
Number SofaScene "Sofa Scene" { channel="zwave:device:9d6ae427:node18:scene_number" }
Number DiningScene "Dining Scene" { channel="zwave:device:9d6ae427:node17:scene_number" }

rules/scene.rules

rule "Mushroom Pushing"
when
Item SofaScene received update
then
if (SofaScene.state == 1.0) {
logInfo("Test", "Mushroom 1x pushed")
}
if (SofaScene.state == 1.1) {
logInfo("Test", "Mushroom leave alone")
}
if (SofaScene.state == 1.2) {
logInfo("Test", "Mushroom kept in")
}
if (SofaScene.state == 1.3) {
logInfo("Test", "Mushroom 2x pushed")
gfLights.members.forEach(Switch|
sendCommand(Switch, OFF)
)

}
if (SofaScene.state == 1.4) {
logInfo("Test", "Mushroom 3x pushed")
}
if (SofaScene.state == 1.5) {
logInfo("Test", "Mushroom 4x pushed")
}
if (SofaScene.state == 1.6) {
logInfo("Test", "Mushroom 5x pushed")
}
end
rule "TVScene Pushing"
when
Item TVScene received update
then
if (TVScene.state == 1.0) {
logInfo("Test", "Mushroom 1x pushed")
}
if (TVScene.state == 1.1) {
logInfo("Test", "Mushroom leave alone")
}
if (TVScene.state == 1.2) {
logInfo("Test", "Mushroom kept in")
}
if (TVScene.state == 1.3) {
logInfo("Test", "Mushroom 2x pushed")
gfLights.members.forEach(Switch|
sendCommand(Switch, OFF)
)

}
if (TVScene.state == 1.4) {
logInfo("Test", "Mushroom 3x pushed")
}
if (TVScene.state == 1.5) {
logInfo("Test", "Mushroom 4x pushed")
}
if (TVScene.state == 1.6) {
logInfo("Test", "Mushroom 5x pushed")
}
end
rule "DiningScene Pushing"
when
Item DiningScene received update
then
if (DiningScene.state == 1.0) {
logInfo("Test", "Mushroom 1x pushed")
}
if (DiningScene.state == 1.1) {
logInfo("Test", "Mushroom leave alone")
}
if (DiningScene.state == 1.2) {
logInfo("Test", "Mushroom kept in")
}
if (DiningScene.state == 1.3) {
logInfo("Test", "Mushroom 2x pushed")
gfLights.members.forEach(Switch|
sendCommand(Switch, OFF)
)

}
if (DiningScene.state == 1.4) {
logInfo("Test", "Mushroom 3x pushed")
}
if (DiningScene.state == 1.5) {
logInfo("Test", "Mushroom 4x pushed")
}
if (DiningScene.state == 1.6) {
logInfo("Test", "Mushroom 5x pushed")
}
end

Updating Exchange distribution lists if you use a apple mac

I use a Apple Mac with outlook 2016 (v15). One of the problems i have is that I can’t update Exchange based email distribution lists. I haven’t been able find a way to do this from outlook but you can update them using Microsofts Exchange Web (OWA)  that most companies run for employees.

I believe this is office 365 version of OWA, other versions may be different

If you have access to OWA (Outlook Web App), then after you log in

Click on Options, then See All options in the top right hand corner

Click on Groups

 

Enter the name of the group in the right hand section of the screen that says “Public Groups | OWN

When the group shows up, double click on it

Click on membership

Then you can click on the add or remove, to edit the list.

 

Comparing Garmin Edge 305 to Nexus 6P with strava

Today i recorded the same route from both a garmin edge 305 and using strava on my nexus 6p. The Garmin appears to win. The Garmin on on a flybar mount on front of my bike and the phone was in a ziplock bag  in my back jersey pocket, so it might be interesting to do some further testing with it in a similar position to the garmin. The garmin data is fed to garmin connect, which is in turn fed into strava.

Nexus 5P and Strava



Garmin 305

The garmin output appears to be less jaggy and follows the road or the path more accurately

I also have an ANT+ usb adaptor on the phone and the heart rate monitor was emmm poor

Nexus 6p

Garmin Edge 305

I had thought about switching to just using my phone, but the garmin is giving me consistently  better gps mapping.

Uploading ride with GPS routes to garmin 305

My goal was to be able to get turn notifications on routes so i don’t have to constantly look at cue sheets.

This is a work in progress and may change

First create your route on ridewithgps.

Then click on the export tab, choose GPX Route (.gpx)

Open the .gpx file in Garmin Base Camp and right click on the route name and say send to device.

On the Garmin Edge 305 it should now show up under Navigation -> Routes

Garmin Edge 305

The case on my Garmin edge 305 has been separating for while now, and today during a ride it completely came apart. I was doing some research to see what kind of glue i should use to reattach it, but I also noticed that this unit is a little different from the ones on the Garmin Edge repair blogs like http://bikepathwarrior.blogspot.com/2011/09/repairing-garmin-edge-205-or-305.html and https://www.jimcarson.com/2009/replacing-the-battery-in-a-garmin-edge-305/

The edge 305 had issues with the daughter board with the battery disconnecting from the garmin when it was bumped. So I was a little surprised why mine continued to work while the case was separated. My unit is a replacement unit from Garmin so it looks like it has had some modifications before they sent it to me

So the first thing to notice is that the black and red wire from the battery are soldered onto the main board and don’t rely on the jumper board and spring connectors

IMG_20160710_160538

Then there appears to be a red shim between the daughter board and the back case.

IMG_20160710_160549

This unit has obviously been worked on since the foil had already been moved to get at the components under it, I just lifted it to show what was under it, i didn’t work the foil loose it was already like that.

IMG_20160710_160613

another of the main board

IMG_20160710_161927

and the battery
IMG_20160710_160636

I am tempted to see if i can get a replacement battery before i reseal the unit.

Create a linux partition bigger than 2TB

If you use fdisk to create a partition on your disc that is larger than 2TB you will only see the first 2TB of the disc. Instead you should use parted.

sudo parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
Warning: The existing disk label on /dev/sdb will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
(parted) mkpart primary ext4 0% 100%
(parted) p                                                                
Model: ATA WDC WD60EFRX-68M (scsi)
Disk /dev/sdb: 6001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  6001GB  6001GB               primary
sudo mkfs.ext4 /dev/sdb1

Extending a lennox icomfort thermostat: part 2

I setup up an android emulator, side loaded the icomfort app, installed charles proxy, installed the cert from charles proxy, started the emulator with an http proxy, then started sniffing the https traffic. This all took me a while to get all working, but after a lot of banging of heads i finally started to get the unencrypted packets from the app.

The website and the android app use a completely different API. i converted my first attempt at a logging app to the same API that android uses and now have a much cleaner app. Have a look at https://github.com/bruman/ruby-icomfort for the full code.

I added a lot of debug statements so you can see the json that gets passed back and forward, then it starts print

"date, Cool_Set_Point, Head_Set_Point, Indoor_temp, Fan_Mode, Indoor_Humidity, System_Status, Operation_Mode"
"/Date(1416870002787+0000)/,78.0,68.0,71.0,auto,47,idle,heat or cool"

part 1 of my post about interfacing with the icomfort

 

 

Installshield: Prompt user for a license file, then copy it

Project:

I need to add a prompt to an installshield project that asks the user where the license key file is, then copy the file to the INSTALLDIR location.

This is going to be a fairly complex thing, First I am going to create an install script function that copies the file, then I am going to create two custom actions, one that executes the CopyLicenseFile installscript file, the other prompts for the File location using  a file browser. Then I am going to create a new dialog that will call the FileBrowse custom action.

I am assuming you have already created a basic MSI project.

References

I used the following references

http://helpnet.installshield.com/installshield16helplib/IHelpIScriptEntryPoint.htm

http://helpnet.installshield.com/installshield18helplib/mergedProjects/installshield18langref/LangrefCopyFile_Example.htm

http://helpnet.installshield.com/installshield16helplib/AccessingProps-DeferredCAs.htm

http://helpnet.installshield.com/installshield16helplib/FileOpenDialog-HowTo.htm

InstallScript

Expand out Behavior and Logic, and click on InstallScript

Click on the Installscript, then right click on Files and choose New Script File

Comment out the same code

//export prototype MyFunction(HWND);

 

///////////////////////////////////////////////////////////////////////////////
// 
// Function: MyFunction
// 
// Purpose: This function will be called by the script engine when
// Windows(TM) Installer executes your custom action (see the "To
// Do," above).
// 
///////////////////////////////////////////////////////////////////////////////
//function MyFunction(hMSI)
 // To Do: Declare local variables.
//begin

 // To Do: Write script that will be executed when MyFunction is called.

//end;

We are going to create an extry point function called ExFn_CopyLicenseFile Copy and Paste into the Setup.rul,

#include "ifx.h"
///////////////////////////////////////////////////////////////////////////////
// 
// Function: ExFn_CopyLicenseFile
// 
// Purpose: This function will be called by the script engine when
// Windows(TM) Installer executes your custom action (see the "To
// Do," above).
// The Function reads from the Property LICENSEFILE and INSTALLDIR, then copies the
// file LICENSEFILE to INSTALLDIR/LICENSEFILE
// 
///////////////////////////////////////////////////////////////////////////////
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_CopyLicenceFile(HWND);
function ExFn_CopyLicenceFile(hMSI)
 NUMBER nResult;
 STRING licenseFilePath;
 NUMBER licenseFilePathBuffer;
begin
 licenseFilePathBuffer = MAX_PATH;
 if(MsiGetProperty(hMSI, "LICENSEFILE", licenseFilePath, licenseFilePathBuffer) == ERROR_SUCCESS) then
 SprintfBox(INFORMATION,"Deferred Execution","The value of LICENSEFILE is %s",licenseFilePath);
 SprintfBox(INFORMATION,"Deferred Execution","The value of INSTALLDIR is %s",INSTALLDIR);
 endif;

 // Copy all files in the source directory, including files
 // in subdirectories, to the target directory.
 nResult = CopyFile(licenseFilePath, INSTALLDIR + "license.lic"); 
 // Report the results of the copy operation.
 switch (nResult)
 case 0:
 MessageBox ("File successfully copied.", INFORMATION);
 case COPY_ERR_CREATEDIR:
 MessageBox ("A target directory could not be created.", SEVERE);
 case COPY_ERR_MEMORY:
 MessageBox ("Insufficient memory.", SEVERE);
 case COPY_ERR_NODISKSPACE:
 MessageBox ("Insufficint disk space.", SEVERE);
 case COPY_ERR_OPENINPUT:
 MessageBox ("Unable to open the input files in "+ INSTALLDIR +".",
 SEVERE);
 case COPY_ERR_OPENOUTPUT:
 MessageBox ("Unable to copy the source files.", SEVERE);
 case COPY_ERR_TARGETREADONLY:
 MessageBox ("A target file already exists and cannot be overwritten.",
 SEVERE);
 default:
 MessageBox ("An unspecified error occurred.", SEVERE);
 endswitch;
end;

I have left in the MessageBox and the SprintfBox lines to aid in debugged, and would be removed for your production version.

You should now have file -> Setup.rul and Functions -> ExFn_CopyLicenseFile

Custom Actions

Expand out Behavior and Logic, then click Custom Actions and Sequences

Right click on Custom Actions and choose New InstallScript

Change name to “CopyLicenseFile”

Set ‘Function Name’ to ExFn_CopyLicenseFile

Set install Exec Sequence to After MsiConfigureService

Set the ‘Install Exec Condition’ to ‘NOT Installed AND NOT PATCH’ this will mean it only runs if the Product is not installed and this isn’t a Patch

Create another Custom action, New MSI DLL, Stored in Binary Table

Rename to FileBrowse

 

In the right hand pane

DLL Filename: <ISProductFolder>\redist\language independent\i386\FileBrowse.dll
Function Name: FileBrowse
Return Processing: Synchronous (Ignores exit code)
In-Script Execution: Immediate Execution
Execution Scheduling: Always execute
For all other settings, leave the default values. The value of the MSI Type Number setting should be 65.

Create Properties

Expand out Behavior and Logic, and click on Property Manager

Click on New

Rename to LICENSEFILE, since this starts with a CAPITAL it creates a global property that can be referenced later.

Create another IS_BROWSE_FILEBROWSED

Create Custom Dialog

Expand out User Interface and click on Dialogs

Find the DestinationFolder Dialog,

Right Click and clone

Rename to LicenseFileLocation

We are doing to repeat the following steps for a number of resources, the goal is to create a new STRING property for each string we are changing, so we don’t accidentally change the strings in other dialogs.

Click on LicenFileLocation, English (United States)

Click on the string Destination Folder so it is highlighted

Click in the Text field where is says Destination Folder

Click on the …

Then Cick on New

Change Value to License File

Repeat for “Click next to install

 

Change Text to “Click Next to install, or click Change to change the source of the License File”, remember to do the three dot and then new to create a new string, or you will also change the value in the dialog you cloned.

Change “Install [ProductName] to:” to “Install [ProductName] License File:”

Click on  [INSTALLDIR]

Change Property to LICENSEFILE

Change Text: to [LICENSEFILE], remeber the three dots and create new string

Click on LicenseFileLocation -> Behavior

Click on ChangeFolder

Change SpawnDialog to DoAction, and Argument to FileBrowse

Change [_BrowseProperty] to [LICENSEFILE] and Argument to [IS_BROWSE_FILEBROWSED]

Click on Back

Change NewDialog to “Destination Folder”

Click on DestinationFolder -> Behavior

Click on Next

Change NewDIalog to LicenseFileLocation

Click on SetupType -> Behavior

Click on Back

Change NewDialog to LicenseFileLocation

Test

Now the moment of truth, build and test, Why are not setting a default license file so it is pulling the default value from the property which is “0”

Click on Change…

 

Succcess 🙂