Skip to content
ggodart edited this page Jan 5, 2021 · 2 revisions

You can nested create menus that let you query MisterHouse data or control MisterHouse items or commands. You can use any or all of these interfaces to walk through menus:

  Web browser:        http://localhost/sub?menu_html
  WAP phone:          http://localhost/sub?menu_wml
  Tellme.com phone:   http://localhost/sub?menu_vxml
  LCD keypads:        see mh/code/bruce/lcdproc.pl for an example
  Audible feedback:   see mh/code/public/audible_menu.* for an example

To enable, use mh/code/test/menu.pl to read in menu files. The format of the menu files is a simple text file, where each record is prefixed with a record type character. Here is an example:

 M: Test            # Top level menu can have any name
    D: HVAC
    D: Lights
 M: HVAC
    D: Indoor temperature
       R: At $Time_Date, the temperature is $Weather{TempIndoor}
    D: Living fan [on,off]
       A: set $living_fan $state
    D: Outdoor temperature
       A: What is the outdoor temperature
       R: last_response
    D: Humidity
       A: What is the humidity temperature
 M: Lights
    D: Camera [+,-,^,v]
       A: Camera light [on,off,+30,-30]
       R: eval "Light $state" . chr(07) # Ring bell
    D: Bedroom [on,off,+30,-30]
       P: anyone
    M: Outside
 M: Outside
    P: anyone
    D: Garage Light [on,off,+30,-30]
    D: Backyard Light [on,off,+30,-30]

These are the record types:

 M:  Menu screen
 D:  text to Display as a menu choice
 P:  Password bypass group
 A:  what Action to run (either a voice cmd or code to eval)
 R:  what Response to display.
     last_response will pick up the last mh response
     no_response   will return no response
     href=url      will goto the url (is using a web browser)
     If not specified, defaults to select state or last_response.
     Begin with eval to eval the string first.

The above example specifies 3 menu (M:) records that creates a Test menu, with 2 submenus, HVAC and Lights.

The HVAC 'Indoor temperature' display record (D:) will respond (R:) with the indoor $Weather data.

The 'Living fan' entry will evaluate the 'set $living_fan $state' action (A:) record to set the fan to the specified (on or off) state.

The 'Outdoor temperature' record will run a Voice_Cmd action (A:), and respond with the last data printed or spoken by MisterHouse (the results of the outdoor temperature command). The 'Humidity' record will also run a Voice_Cmd and default to last_response.

The 'Camera light' record also runs a Voice_Cmd action. To save (LCD) display space, the on,off,+30,-30 Action states were renamed on the Display record to +,-,^,v.

The 'Bedroom' record matches a Voice_Cmd exactly, so no action record is required. It specifies a Password bypass group of anyone, meaning anyone can run this command without having to use a password.

The last Outside Light records are a 3rd level menu, nested under the 2nd level Lights menu. There are no limits to how deep you can nest menus and they can appear in any order you want in the file. The same menu can be a submenu of more than one other parent menu.

The Outside menu specifies a P: record before any items are specified, so that is the default for all items on this menu, meaning anyone can run the commands on this page without a password.

If you want a starting point to customise your own menus, you can find an auto-generated menu for all the MisterHouse Voice_Cmds in the mh_temp.menu file in your code directory. This file is re-generated on reload, so copy and edit this file, then point menu.pl at your edited copy.

You can have different sets of menus, for use with different interfaces or users. For example, the default menu.pl looks like this:

    my $menu_mh   = menu_create "$config_parms{code_dir}/mh_temp.menu";
    my $menu_test = file_read   "$config_parms{code_dir}/test.menu";
    menu_parse $menu_test, 'default';
    menu_parse $menu_mh,   'mh'; # This menu has all the mh voice commands

menu_create creates the example mh_temp.menu file for all voice commands and returns it into $menu_mh. $menu_test has the test menu, similar to the above example. You can specify the menu group (e.g. default or MisterHouse) when calling any of the menu interface subroutines. For the above menu.pl, you can point your WAP phone to either of these to get the 'default' test menu:

    http://misterhouse.net:8090/sub?menu_wml
    http://misterhouse.net:8090/sub?menu_wml(default)

This will get the auto-generated 'mh' entry for all voice commands:

    http://misterhouse.net:8090/sub?menu_wml(mh)

Something like this could be used to create different menus for different LCD controllers:

  $menu_standard = file_read 'standard.menu';
  $menu_bedroom  = file_read 'bedroom.menu';
  $menu_living   = file_read 'living.menu';
  $menu_all      = file_read 'all.menu';

  if ($Reread) {
    menu_parse $menu_bedroom  $menu_bedroom . $menu_standard,  'bedroom';
    menu_parse $menu_living   $menu_living  . $menu_standard,  'living';
    menu_parse $menu_all      $menu_all     . $menu_living .
                              $menu_bedroom . $menu_standard, 'all';
    $lcd_data{bed1}   {menu_group} = 'bedroom';
    $lcd_data{living1}{menu_group} = 'living';
    $lcd_data{living2}{menu_group} = 'all';
  }

To test your menus, point your browser at http://localhost:8080/sub?menu_html To view auto-generated menus, try http://localhost:8080/sub?menu_html(mh)

NOTE: With the demise of WAP, the following contains broken links.

If you have a LCD supported by lcdproc program (http://lcdproc.omnipotent.net) (e.g. crystalfontz or matrix-orbital), you can use mh/code/bruce/lcdproc.pl to display menus. Currently only the linux version of lcdproc supports the keypad option on the maxrix-orbital displays. Several other MisterHousers are writing similar code for their LCD displays.

NOTE: With the demise of WAP, the following contains broken links.

If you have a 24x7 internet connection, you can walk the menus with either a WAP compatible cell phone, or using voice commands with any phone via a Voice Portal like http://studio.tellme.com.

For cell phones, simply point your phone to http://your_domain/sub?menu_wml. You can test your menus with a web based phone simulator at http://www.yospace.com or download a phone simulator from http://phone.com . Other browsers are listed at /http://www.gelon.net .

Clone this wiki locally