VeraPlus, MiOS binding, and HouseModes

Tags: #<Tag:0x00007faf83808268>

I have a VeraPlus connected to my OpenHAB 1.8.3 via the MiOS binding and I’m trying to read and eventually write the house mode. I read the thread at MiOS Binding - House Mode but I don’t have a urn:micasaverde-com:serviceId:HouseModes1 (or any HouseModes) device anywhere in my user_data.xml, so I don’t know what deviceId to use.

Maybe I misunderstood how to access it, or maybe the format has changed. I DO see the mode in my user_data.xml, but it’s in the Mode attribute of my <root> tag and I’ve watched it change from Mode=“1” to 2, 3, and 4 as I cycle through the Home, Away, Night, and Vacation modes. I did try accessing it as:

String HouseMode "House mode: [%s]" <house> (MIOSDevices) {mios="unit:house,system:/Mode"}

But all that gets me is this:

2017-03-01 17:05:57.277 [WARN ] [ore.internal.items.ItemUpdater] - InstantiationException on org.openhab.core.library.types.StringType

Any ideas how to proceed from here?

(Note: I am running a beta build of the Vera firmware right now in order to get Alexa support, but it looks like the Mode was in the <root> tag instead of a HouseModes1 device even before I did that upgrade, as I still have the first user_data.xml file I worked on almost a year ago.)

The Item format you’ve listed looks correct for a Mode attribute hanging off the root XML element.

IIRC, I don’t provide an implementation to set things at the System level, but let’s cross that bridge when we get to it.

Can you turn on TRACE level logging for the MiOS Binding, and then provide the logs?

It’ll be a logger entry like this in your logback.xml file:

<logger name="org.openhab.binding.mios" level="TRACE" />

That’ll give me details on whats happening up to the error you’re seeing.

Ah, that helped. I admit I didn’t think to try it first because my binding logging was broken but this motivated me to fix that…

2017-03-04 13:34:51.851 [TRACE] [.b.m.i.MiosBindingProviderImpl] - getItemNamesForProperty: MATCH property 'unit:house,system:/Mode' against BindingConfig.toProperty 'unit:house,system:/Mode' 2017-03-04 13:34:51.851 [DEBUG] [.o.b.mios.internal.MiosBinding] - internalPropertyUpdate: BOUND (Incr) Updating 'HouseMode {mios="unit:house,system:/Mode"}' to '3' 2017-03-04 13:34:51.852 [TRACE] [.o.b.mios.internal.MiosBinding] - internalPropertyUpdate: BOUND {mios="unit:house,system:/Mode"}, value=3, bound 1 time(s) 2017-03-04 13:34:51.867 [TRACE] [.o.b.mios.internal.MiosBinding] - internalReceiveUpdate: itemName 'HouseMode', newState '3', class 'class org.openhab.core.library.types.DecimalType'

Using a Number instead of a String fixed that, at least. Thank you for that!


Now, if you set the House-mode via Vera’s UI, then Vera’s logs will have the [URL] call they’re making to do that.

You’ll need to enable Verbose logging on your Vera prior to running through this exercise.

If you can grab me that section of Vera’s /var/log/cmh/LuaUPnP.log file then I might be able to work out how to add set capability to the System settings via the MiOS openHAB binding (or at least give you a work-around…

Using this as a reference:

Setting the house Mode value should look similar to this issue:

Assuming an Item declaration like:

Number   MiOSGateway "ID [%d]" {mios="unit:house,device:0/id"}

Then a Rule declaration a construct like this will set the mode. The mode values are listed in MiOS’s doc (link above):

sendMiosAction(MiOSGateway, 'HAGateway/SetHouseMode',
               newArrayList('Mode' -> '1'))

It doesn’t look like I’m getting back an ID for device 0.

Number MiOSGateway "ID [%d]" <vera> (MIOSSystem,MIOSDevices) {mios="unit:house,device:0/id"}

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><item><type>NumberItem</type><name>MiOSGateway</name><state>Uninitialized</state><link>http://openhab:8080/rest/items/MiOSGateway</link></item>

With trace logging enabled:

2017-03-06 16:48:24.712 [TRACE] [.o.b.mios.internal.MiosBinding] - getMiosConnector: start unitName 'null' 2017-03-06 16:48:24.713 [TRACE] [.b.m.i.MiosBindingProviderImpl] - parseBindingConfig: unit 'house' thing 'device:0/id' inTrans 'null' outTrans 'null' 2017-03-06 16:48:24.714 [TRACE] [.b.m.i.MiosBindingProviderImpl] - parseBindingConfig: in: (Type 'device' id '0' Stuff 'id'), command: ('null') 2017-03-06 16:48:24.714 [TRACE] [b.m.i.config.MiosBindingConfig] - Device ParameterDefaults NOT FOUND 'MiOSGateway' for 'id' 2017-03-06 16:48:24.715 [TRACE] [b.m.i.config.MiosBindingConfig] - newInStuff 'id', iName 'null', iVar 'null' 2017-03-06 16:48:24.715 [DEBUG] [.b.m.i.MiosBindingProviderImpl] - processBindingConfiguration: Adding Item 'MiOSGateway' Binding 'unit:house,device:/id', from 'mios.items' 2017-03-06 16:48:24.715 [DEBUG] [.o.b.mios.internal.MiosBinding] - bindingChanged: start provider 'org.openhab.binding.mios.internal.MiosBindingProviderImpl@18859bd', itemName 'MiOSGateway' 2017-03-06 16:48:24.716 [DEBUG] [.o.b.mios.internal.MiosBinding] - registerWatch: start miosProvider 'org.openhab.binding.mios.internal.MiosBindingProviderImpl@18859bd', itemName 'MiOSGateway'

I did enable verbose logging on the VeraPlus and it looks like it’s using action=SetHouseMode:
12 03/04/17 16:04:00.450 luvd_get_info_data_request starting /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=1&rand=0.5997565290129718 pMem 0x145e000/21356544 diff: 6074368 <0x7487b520>

Using that URL with my own generated random value (or, as it turns out, no rand at all) seems to work: I was able to trigger the mode change (including the arming delay that exists for everything but “Home”). Worst-case, you’ve given me enough clues that I could wrap a shell script around it at this point. I am curious as to the “right” way to use sendMiosAction() here so let me know what other info I can provide.

Did you try running this from a Rule:

I have an Item decl:

Number   MiOSGateway "ID [%d]" {mios="unit:house,device:0/id"}

and then used the code snippet in rule:

rule "Test MiOSGateway"
  Time cron "0/10 * * * * ?"
  logInfo("test-miosgateway", "testing: ")  
  sendMiosAction(MiOSGateway, 'HAGateway/SetHouseMode',
                 newArrayList('Mode' -> '1'))

and I can see openHAB calling my Vera. In my case, it’s Vera3/UI5 so my Vera is returning an error response (the rand is only needed by the UI, to bypass browser-caching):

Request side (openHAB)
	0x0020:  0000 0000 0000 0000 4745 5420 2f64 6174  ........GET./dat
	0x0030:  615f 7265 7175 6573 743f 6964 3d61 6374  a_request?id=act
	0x0040:  696f 6e26 4465 7669 6365 4e75 6d3d 3026  ion&DeviceNum=0&
	0x0050:  7365 7276 6963 6549 643d 7572 6e25 3341  serviceId=urn%3A
	0x0060:  6d69 6361 7361 7665 7264 652d 636f 6d25  micasaverde-com%
	0x0070:  3341 7365 7276 6963 6549 6425 3341 486f  3AserviceId%3AHo
	0x0080:  6d65 4175 746f 6d61 7469 6f6e 4761 7465  meAutomationGate
	0x0090:  7761 7931 2661 6374 696f 6e3d 5365 7448  way1&action=SetH
	0x00a0:  6f75 7365 4d6f 6465 264d 6f64 653d 3120  ouseMode&Mode=1.
	0x00b0:  4854 5450 2f31 2e31 0d0a 4163 6365 7074  HTTP/1.1..Accept
	0x00c0:  3a20 2a2f 2a0d 0a55 7365 722d 4167 656e  :.*/*..User-Agen

Response side (Vera)
	0x0030:  2032 3030 204f 4b0d 0a63 6f6e 7465 6e74  .200.OK..content
	0x0040:  2d54 7970 653a 2078 6d6c 0d0a 0d0a       -Type:.xml....

Response side (Vera)
	0x0020:  0000 0000 0000 0000 3c3f 786d 6c20 7665  ........<?
	0x0030:  7273 696f 6e3d 2231 2e30 223f 3e0d 0a3c  rsion="1.0"?>..<
	0x0040:  753a 5365 7448 6f75 7365 4d6f 6465 5265  u:SetHouseModeRe
	0x0050:  7370 6f6e 7365 2078 6d6c 6e73 3a75 3d22  sponse.xmlns:u="
	0x0060:  556e 6b6e 6f77 6e20 5365 7276 6963 6522  Unknown.Service"
	0x0070:  3e0d 0a3c 4f4b 3e4f 4b3c 2f4f 4b3e 0d0a  >..<OK>OK</OK>..
	0x0080:  3c2f 753a 5365 7448 6f75 7365 4d6f 6465  </u:SetHouseMode
	0x0090:  5265 7370 6f6e 7365 3e0d 0a              Response>..

OK, yeah, it looks like it works! I expected an exception due to it being null but I guess that would just be the MiOSGateway.state.

1 Like