OpenHAB

From MiOS
(Difference between revisions)
Jump to: navigation, search
(Creating an items file)
(Creating an items file)
Line 81: Line 81:
  
 
</source>
 
</source>
 +
 +
== Tips & Tricks ==
 +
 +
=== Synchronizing Vera's devices with openHAB ===
 +
 +
Mount ~/openHAB/runtime/configurations/items on Vera (see http://forum.micasaverde.com/index.php/topic,16452.msg125963.html#msg125963) and write the items file via Apps -> Develop Apps -> Edit Startup Lua.

Revision as of 18:01, 26 November 2014

Contents

openHAB Downloads

http://www.openhab.org/downloads.html

openHAB MiOS binding

https://github.com/openhab/openhab/tree/master/bundles/binding/org.openhab.binding.mios

Tools

Creating an items file

https://github.com/openhab/openhab/wiki/Explanation-of-items

local unit_name = 'house'
 
local device_types =
{ [ 'urn:schemas-upnp-org:device:DimmableLight:1'            ] = { 'Dimmer' , ' [%d]%'     , '<slider>'     , '/service/Dimming1/LoadLevelStatus,command:MAP(miosDimmerCommand.map)' },
  [ 'urn:schemas-upnp-org:device:BinaryLight:1'              ] = { 'Switch' , ''           , ''             , '/service/SwitchPower1/Status,command:ON=SwitchPower1/SetTarget(newTargetValue=1)|OFF=SwitchPower1/SetTarget(newTargetValue=0),in:MAP(miosSwitchIn.map)' },
  [ 'urn:schemas-micasaverde-com:device:TemperatureSensor:1' ] = { 'Number' , ' [%.1f °C]' , '<temperature>', '/service/TemperatureSensor1/CurrentTemperature' },
  [ 'urn:schemas-micasaverde-com:device:HumiditySensor:1'    ] = { 'Number' , ' [%d]%'     , ''             , '/service/HumiditySensor1/CurrentLevel' },
  [ 'urn:schemas-micasaverde-com:device:MotionSensor:1'      ] = { 'Contact', ' [%s]'      , '<contact>'    , '/service/SecuritySensor1/Tripped,in:MAP(miosContactIn.map)' },
  [ 'urn:schemas-micasaverde-com:device:LightSensor:1'       ] = { 'Number' , ' [%.2f]%'   , ''             , '/service/urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel' },
  [ 'urn:schemas-micasaverde-com:device:DoorSensor:1'        ] = { 'Contact', ' [%s]'      , '<contact>'    , '/service/SecuritySensor1/Tripped,in:MAP(miosContactIn.map)' },
  [ 'urn:schemas-upnp-org:device:Heater:1'                   ] = { 'Number' , ' [%.1f °C]' , '<temperature>', '/service/urn:upnp-org:serviceId:TemperatureSetpoint1_Heat/CurrentSetpoint' },
  [ 'urn:schemas-micasaverde-com:device:UvSensor:1'          ] = { 'Number' , ' [%d]'      , ''             , '/service/urn:upnp-org:serviceId:UvSensor1/CurrentLevel' },
  [ 'urn:schemas-micasaverde-com:device:RainSensor:1'        ] = { 'Number' , ' [%.1f]'    , ''             , '/service/urn:upnp-org:serviceId:RainSensor1/CurrentTRain' },
  [ 'urn:schemas-micasaverde-com:device:ScaleSensor:1'       ] = { 'Number' , ' [%.1f]'    , ''             , '/service/urn:micasaverde-com:serviceId:ScaleSensor1/Weight' },
  [ 'urn:schemas-micasaverde-com:device:BarometerSensor:1'   ] = { 'Number' , ' [%.2f]hPa' , ''             , '/service/urn:upnp-org:serviceId:BarometerSensor1/CurrentPressure' },
  [ 'urn:schemas-micasaverde-com:device:WindSensor:1'        ] = { 'Number' , ' [%.1f]'    , '<wind>'       , '/service/urn:upnp-org:serviceId:WindSensor1/AvgSpeed' },
  [ 'urn:schemas-micasaverde-com:device:SmokeSensor:1'       ] = { 'Contact', ' [%s]'      , '<contact>'    , '/service/urn:upnp-org:serviceId:SmokeSensor1/Tripped,in:MAP(miosContactIn.map)' },
  [ 'urn:demo-micasaverde-com:device:weather:1'              ] = { 'String' , ' [%s]'      , ''             , '/service/urn:micasaverde-com:serviceId:Weather1/Condition' },
  [ 'urn:schemas-ap15e-com:device:DAD'                       ] = { 'String' , ' [%s]'      , '<sun>'        , '/service/urn:upnp-ap15e-com:serviceId:DAD1/Sunrise_HHMMSS' },
  [ 'urn:schemas-micasaverde-com:device:WindowCovering:1'    ] = { 'Switch' , ''         , '<rollershutter>', '/service/SwitchPower1/Status,command:ON=SwitchPower1/SetTarget(newTargetValue=1)|OFF=SwitchPower1/SetTarget(newTargetValue=0),in:MAP(miosSwitchIn.map)' } }
 
 
function normalize_name( s )
 
 s = string.gsub( s or '', '[%s-/%.:]', '_' )
 return '_' .. s
 
end
 
luup.log( 'AAAGroup Rooms (All)' )
 
for k, v in pairs( device_types )
 do
 
  t = string.match( k or '', '%:(%a*)%:1' )
  luup.log( 'AAAGroup _' .. tostring( t ) .. 's "' .. tostring( t ) .. 's" (Rooms)' )
  luup.log( 'AAANumber _' .. tostring( t ) .. 'sChartPeriod' )
 
 end
 
for k, v in pairs( luup.rooms )
 do
 
  luup.log( 'AAAGroup ' .. normalize_name( tostring( v ) ) .. ' "' .. tostring( v ) .. '" <' .. normalize_name( tostring( v ) ) .. '> (Rooms)' )
 
 end
 
luup.log( 'AAAGroup _nil "nil" <_nil> (Rooms)' )
 
for k, v in pairs(luup.devices) do
 
 dt = device_types[ v.device_type ]
 
 if dt ~= nil
  then
 
   t = string.match( v.device_type or '', '%:(%a*)%:1' )
 
   luup.log( 'AAA' .. tostring( dt[ 1 ] ) .. ' ' .. normalize_name( tostring( v.description ) ) .. ' "' .. tostring( v.description ) .. tostring( dt[ 2 ] ) .. '" ' .. tostring( dt[ 3 ] ) .. ' (' .. normalize_name( tostring( luup.rooms[ v.room_num ] ) ) .. ',_' .. tostring( t ) .. 's) {mios="unit:' .. tostring( unit_name ) .. ',device:' .. k .. tostring( dt[ 4 ] ) .. '"}' )
 
  end
 
end

Tips & Tricks

Synchronizing Vera's devices with openHAB

Mount ~/openHAB/runtime/configurations/items on Vera (see http://forum.micasaverde.com/index.php/topic,16452.msg125963.html#msg125963) and write the items file via Apps -> Develop Apps -> Edit Startup Lua.

Personal tools