Thanks for the excellent explanation of how to implement new modes
with a minimum of extra work.
I hope everyone in the misterhouse-o-sphere has a Happy Thanksgiving
(or for those not in the US, a happy Thursday this week).
On Sun, 18 Nov 2012, it would appear that Eloy Paris wrote:
> Hi Lieven,
> On 11/18/2012 04:04 PM, Lieven Hollevoet wrote:
>> I have setup some modes in the past to be able to quickly enable
>> rules that only should run now and then (e.g. automatic x-mas
>> lighting through a MH-controllable socket).
>> I have added support for mode control by editing the
>> mh/web/ia5/modes/main.shtml file as documented here:
>> However, this is not really the way to go since you're making
>> customizations in the main code tree. I think this should go
>> somewhere into the 'local' folder.
>> Can somebody point me to/explain me how to set this up? The wiki was
>> not really helping me there
> This should be very easy to do by using HTML aliases, which are a very
> nice feature that allows us to customize different parts of the web
> interface without modifying the corresponding files shipped with the MH
> I just tested this and it seems to be working nicely. Here's what I did:
> 1. Created xmas.pl in my user code directory with just these two lines:
> $mode_xmastree = new Generic_Item; #noloop
> $mode_xmastree->set_states('on', 'off'); #noloop
> 2. Edited my mh.private.ini and added this line:
> html_alias_ia5 = /home/mrhouse/web
> In my installation, the MH distribution is installed at
> /opt/misterhouse. This is the official MH code, and it is read-only for
> the user that run the mh executable (I created a "mrhouse" user for
> that). /home/mrhouse is the home directory for the "mrhouse", so the mh
> process, run by the "mrhouse" user, can write anywhere in this directory.
> 3. Created /home/mrhouse/web/modes and copied web/ia5/modes/main.shtml
> (from the official MH code) there.
> 4. Modified /home/mrhouse/web/modes/main.shtml by adding this:
> <td align='middle'> <!--#include
> file="/bin/button_toggle.pl?mode_xmastree&/ia5/modes/main.shtml"--> </td>
> 5. Now visiting the modes page shows a button for the new mode. The
> first time it is shown it does not show the current mode because it has
> not be set yet. However, after you click on the button one time, it will
> start showing the mode, and it will cycle through the possible states as
> you click on the button.
> Using HTML aliases should be the correct way to customize the web
> interface. There are a bunch of different aliases that are recognized.
> Look at bin/mh.ini and search for "alias" to see them.
> I still have a bit of a problem understanding what specific html_alias*
> to use, but looking at the source code usually provides the answer. In
> the case of the html_alias_ia5 I mention in (2) above, bin/mh.ini has a
> sample comment (for mh/web/ia5/security) that put me in the right track
> -- I tried it and it worked on the first try.
> Another alias that I have in my mh.private.ini file is this:
> html_alias_my_mh = /home/mrhouse/web/my_mh
> I put in this directory all the files in web/my_mh/ (from the MH
> original code) and modified them to put links to other pages and buttons
> that are only relevant in my specific situation (for example, I have
> buttons to turn all lights off, to close the garage door, etc.) All this
> shows up when I click on the "My MH" button at the top of the ia5 web
> interface. This way I don't have to touch the original MH files, which
> would require me to port my customizations from one MH release to
> another (or source code branch, like trunk and insteon branches). (I now
> think that can probably remove this alias and just use the alias I
> mention in (2) above, but the my_mh alias has worked perfectly until today.)
> Please let us know if an HTML alias works for you without introducing
> any other problems, and if it does, please consider putting the above
> information in a wiki page (if you have write access to the wiki) and
> updating http://misterhouse.wikispaces.com/Modes to point to the new
> page so people know how to customize things without modifying the main
> code tree.
> Eloy Paris.-