Author Topic: Tools: openHAB Item file generator  (Read 26812 times)

Offline AgileHumor

  • Hero Member
  • *****
  • Posts: 984
  • Karma: +51/-27
  • KISS
Re: Tools: openHAB Item file generator
« Reply #30 on: February 05, 2015, 10:40:44 am »
@guessed, finally got a moment to implement OH and the item file generator.  Even though it will be a few days before I will get back to it...

Whoever may decide to venture...

How simple has @guessed made this process? Extremely!

Thanks mate and I look forward to getting looking at this instead to work stuff.

Hazah!!
WMC Leviton:18xVPE06,8xVRS15,3xVRP03-W,2xVRR15,4xVRCS4,2xVRCS2,VP00R,8xVRS15 Aeon:5xDSC06106,4xDSC24,4xDSC25,12xDSB29,2xDSC11,4xDSB54,DSB05,3xDSA22,DSA38,2xDSA03202B,DSB09104,HEM Other:3xYale,12xHSM100v3,7xSP103,45604,WDHA-12,SSA2USR,EVLCD1T,6xWWA02A,7xIPC-HFW2100,URTSI,Hue,Russound,OpenSprinker

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Tools: openHAB Item file generator
« Reply #31 on: February 05, 2015, 11:03:47 am »
@guessed, finally got a moment to implement OH and the item file generator.  Even though it will be a few days before I will get back to it...

Whoever may decide to venture...

How simple has @guessed made this process? Extremely!

Thanks mate and I look forward to getting looking at this instead to work stuff.

Cool, great to hear!   Looking forward to seeing your try out the Binding also.

The Generator is getting stronger as more people use it and give feedback, so the more the merrier!  There are some very exotic devices/plugins out there ;)

Looks like @watou found an issue in a part of what's generated so I'll try to sort that out today.

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Tools: openHAB Item file generator
« Reply #32 on: February 05, 2015, 12:46:55 pm »
New version uploaded, this one:

  • Fix generated Item formatting for Number items, add special-cases for Watt-values
    • Number Items use [%.4f] as format
    • Integer items separated out to use [%d] as format
    • Watt values use [%.1f W] as format
    • kWh values use [%.1f kWh] as format

This should address the problems that @watou saw in the GitHub review feedback on the PR.

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Tools: openHAB Item file generator
« Reply #33 on: February 05, 2015, 03:33:15 pm »
These tools have been submitted to openHAB for formal inclusion under PR #2080.

This has been approved, and merged into the openHAB 1.7 (current) codeline.  I've updated the links in the first post to indicate how to get the nightly version (from openHAB GitHub) and the untested version (Box.net)

Offline AgileHumor

  • Hero Member
  • *****
  • Posts: 984
  • Karma: +51/-27
  • KISS
Re: Tools: openHAB Item file generator
« Reply #34 on: February 07, 2015, 02:01:02 pm »
@guessed, this is maybe more of a question than suggestion.

/* Device - Stairs - Motion */
Number   StairsMotionId "ID [%d]" (GDevices) {mios="unit:main,device:344/id"}
String   StairsMotionDeviceStatus "Stairs - Motion Device Status [%s]" (GDevices) {mios="unit:main,device:344/status"}
String   StairsMotionConfigured "Stairs - Motion Configured [%s]" (GDevices,GRoom17) {mios="unit:main,device:344/service/HaDevice1/Configured"}
DateTime StairsMotionLastUpdate "Stairs - Motion Last Update [%1$ta, %1$tm/%1$te %1$tR]" <calendar> (GDevices,GRoom17) {mios="unit:main,device:344/service/HaDevice1/LastUpdate"}
DateTime StairsMotionFirstConfigured "Stairs - Motion First Configured [%1$ta, %1$tm/%1$te %1$tR]" <calendar> (GDevices,GRoom17) {mios="unit:main,device:344/service/HaDevice1/FirstConfigured"}
Contact  StairsMotionTripped "Stairs - Motion Tripped [%s]" <contact> (GDevices,GRoom17) {mios="unit:main,device:344/service/SecuritySensor1/Tripped"}
DateTime StairsMotionLastTrip "Stairs - Motion Last Trip [%1$ta, %1$tm/%1$te %1$tR]" <calendar> (GDevices,GRoom17) {mios="unit:main,device:344/service/SecuritySensor1/LastTrip"}
DateTime StairsMotionBatteryDate "Stairs - Motion Battery Date [%1$ta, %1$tm/%1$te %1$tR]" <calendar> (GDevices,GRoom17) {mios="unit:main,device:344/service/HaDevice1/BatteryDate"}
Number   StairsMotionBatteryLevel "Stairs - Motion Battery Level [%d]" (GDevices,GRoom17) {mios="unit:main,device:344/service/HaDevice1/BatteryLevel"}
Number   StairsMotionCurrentTemperature "Stairs - Motion Current Temperature [%.1f F]" (GDevices,GRoom17) {mios="unit:main,device:344/service/TemperatureSensor1/CurrentTemperature"}
Switch   StairsMotionArmed "Stairs - Motion Armed" (GDevices,GRoom17) {mios="unit:main,device:344/service/SecuritySensor1/Armed"}
Number   StairsMotionCommFailure "Stairs - Motion Comms Failure [%d]" (GDevices,GRoom17) {mios="unit:main,device:344/service/HaDevice1/CommFailure"}
Switch   StairsMotionStatus "Stairs - Motion Status" (GDevices,GRoom17) {mios="unit:main,device:344/service/SwitchPower1/Status"}
String   StairsMotionCurrentLevel "Stairs - Motion Current Level [%s]" (GDevices,GRoom17) {mios="unit:main,device:344/service/urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel"}
String   StairsMotionArmedTripped "Stairs - Motion FIXME ArmedTripped [%s]" (GDevices,GRoom17) {mios="unit:main,device:344/service/SecuritySensor1/ArmedTripped"}

/* Device - Stairs - Temperature Sensor */
Number   StairsTemperatureSensorId "ID [%d]" (GDevices) {mios="unit:main,device:345/id"}
String   StairsTemperatureSensorDeviceStatus "Stairs - Temperature Sensor Device Status [%s]" (GDevices) {mios="unit:main,device:345/status"}
Contact  StairsTemperatureSensorTripped "Stairs - Temperature Sensor Tripped [%s]" <contact> (GDevices,GRoom17) {mios="unit:main,device:345/service/SecuritySensor1/Tripped"}
String   StairsTemperatureSensorArmedTripped "Stairs - Temperature Sensor FIXME ArmedTripped [%s]" (GDevices,GRoom17) {mios="unit:main,device:345/service/SecuritySensor1/ArmedTripped"}
DateTime StairsTemperatureSensorLastTrip "Stairs - Temperature Sensor Last Trip [%1$ta, %1$tm/%1$te %1$tR]" <calendar> (GDevices,GRoom17) {mios="unit:main,device:345/service/SecuritySensor1/LastTrip"}
Number   StairsTemperatureSensorCurrentTemperature "Stairs - Temperature Sensor Current Temperature [%.1f F]" (GDevices,GRoom17) {mios="unit:main,device:345/service/TemperatureSensor1/CurrentTemperature"}


/* Device - Stairs - Light Sensor */
Number   StairsLightSensorId "ID [%d]" (GDevices) {mios="unit:main,device:346/id"}
String   StairsLightSensorDeviceStatus "Stairs - Light Sensor Device Status [%s]" (GDevices) {mios="unit:main,device:346/status"}
String   StairsLightSensorCurrentLevel "Stairs - Light Sensor Current Level [%s]" (GDevices,GRoom17) {mios="unit:main,device:346/service/urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel"}
Contact  StairsLightSensorTripped "Stairs - Light Sensor Tripped [%s]" <contact> (GDevices,GRoom17) {mios="unit:main,device:346/service/SecuritySensor1/Tripped"}
String   StairsLightSensorArmedTripped "Stairs - Light Sensor FIXME ArmedTripped [%s]" (GDevices,GRoom17) {mios="unit:main,device:346/service/SecuritySensor1/ArmedTripped"}
DateTime StairsLightSensorLastTrip "Stairs - Light Sensor Last Trip [%1$ta, %1$tm/%1$te %1$tR]" <calendar> (GDevices,GRoom17) {mios="unit:main,device:346/service/SecuritySensor1/LastTrip"}

I mean I can do this manually no issues, but there doesn't seem to be a point to have the separate device that Vera needed if the params are in the root object.

Again, could be an easy hand edit.
« Last Edit: February 07, 2015, 10:26:02 pm by AgileHumor »
WMC Leviton:18xVPE06,8xVRS15,3xVRP03-W,2xVRR15,4xVRCS4,2xVRCS2,VP00R,8xVRS15 Aeon:5xDSC06106,4xDSC24,4xDSC25,12xDSB29,2xDSC11,4xDSB54,DSB05,3xDSA22,DSA38,2xDSA03202B,DSB09104,HEM Other:3xYale,12xHSM100v3,7xSP103,45604,WDHA-12,SSA2USR,EVLCD1T,6xWWA02A,7xIPC-HFW2100,URTSI,Hue,Russound,OpenSprinker

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Tools: openHAB Item file generator
« Reply #35 on: February 07, 2015, 09:59:51 pm »
I'm not sure of the comment or the question, so can you restate what you're looking for?

I can see that this "LightSensor" is part of some sort of 3-in-1 (Light, Temp, Motion) and it seems to be repeated (different Device Id's).  During transformation/conversion I don't look at the Device to see if there are "other" things that might also represent it (other devices) as it's fairly common for parent-Devices to have/expose similar services as the child devices (sometimes with the same purpose, and sometimes with a different purpose)

Other than that, the LightSensor will be generated differently in the newer XSLT files.  It's now a Number instead of String.

Offline AgileHumor

  • Hero Member
  • *****
  • Posts: 984
  • Karma: +51/-27
  • KISS
Re: Tools: openHAB Item file generator
« Reply #36 on: February 07, 2015, 10:26:41 pm »
Thanks, just checking.  I removed the additional Vera created devices as it was dupe data.
WMC Leviton:18xVPE06,8xVRS15,3xVRP03-W,2xVRR15,4xVRCS4,2xVRCS2,VP00R,8xVRS15 Aeon:5xDSC06106,4xDSC24,4xDSC25,12xDSB29,2xDSC11,4xDSB54,DSB05,3xDSA22,DSA38,2xDSA03202B,DSB09104,HEM Other:3xYale,12xHSM100v3,7xSP103,45604,WDHA-12,SSA2USR,EVLCD1T,6xWWA02A,7xIPC-HFW2100,URTSI,Hue,Russound,OpenSprinker

Offline bigmonkey70

  • Jr. Member
  • **
  • Posts: 76
  • Karma: +1/-1
Re: Tools: openHAB Item file generator
« Reply #37 on: February 10, 2015, 07:28:10 pm »
I got openHAB setup  on Rasberry Pi with Rasbian 1.6.2.  I turn on the exec bit on these file.  I am doing everything thru putty.

When run sudo bash miosLoad.sh 192.168.0.5
I got
Loading MiOS Unit Metadata from 192.168.0.5...
Failed to load, Check IP Address supplied.

When run http://192.168.0.5:49451/data_request?id=user_data&output_format=xml using browser, I got the xml result.
« Last Edit: February 10, 2015, 07:43:00 pm by bigmonkey70 »

Offline bigmonkey70

  • Jr. Member
  • **
  • Posts: 76
  • Karma: +1/-1
Re: Tools: openHAB Item file generator
« Reply #38 on: February 10, 2015, 07:48:26 pm »
Play around a little more
I am running a vera3 and vera 2 in bridge mode both UI5.
When run bash miosLoad on the vera 3 i got the error failed to load, Check IP Address supplied.  Browser got xml data
When run on the vera 2 i have no error and got the user_data.xml file

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Tools: openHAB Item file generator
« Reply #39 on: February 10, 2015, 07:57:33 pm »
Play around a little more
I am running a vera3 and vera 2 in bridge mode both UI5.
When run bash miosLoad on the vera 3 i got the error failed to load, Check IP Address supplied.  Browser got xml data
When run on the vera 2 i have no error and got the user_data.xml file

The script shouldn't need to be sudo'd or bash'd, it internally has #!/bin/bash script declaration, so it should just need the execution-bit to be set on it. 

The miosLoad.sh script is very simple, so I'm surprised it's failing.  It would be worthwhile checking that the RPi itself can see the Vera3 box (directly) using "ping" and/or by running it's internal commands directly (it's just a wrapper call to curl to fetch the XML)

I've seen cases in past environments where some hosts are visible, and others not, depending upon how the Network was setup (in one case, due to an incorrect NetMask)


Quote
When run bash miosLoad on the vera 3...

I take this to mean you're running the script ON the RaspberryPi AGAINST the Vera 3.  The script itself is not designed to be run ON the Vera 3.

Offline bigmonkey70

  • Jr. Member
  • **
  • Posts: 76
  • Karma: +1/-1
Re: Tools: openHAB Item file generator
« Reply #40 on: February 10, 2015, 08:10:10 pm »
Thank you @guessed

I removed all scripts files.  Recopied them again.  Set the executable bit on the files, then run ./miosLoad.sh <my vera IP> without bash and it worked.

Thanks again

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Tools: openHAB Item file generator
« Reply #41 on: February 12, 2015, 03:08:39 pm »
New version uploaded, this one:

  • Uses the openHAB MAP file "en.map" for all Contact Items it generates - taking a baby-step closer to i18n
  • Uses a new MiOS MAP file "miosDeviceStatusUI.map" to provide more readable strings for use in UI's

NOTE: I've introduced a new MAP file, miosDeviceStatusUI.map, which will need to be installed into OH/configurations/transform, along with the other mios*.map files, if you use this version of the MiOS Item Generator.

The TARball includes a copy of all MiOS Map files, but you can also get them from the standard location:
        https://github.com/openhab/openhab/tree/master/bundles/binding/org.openhab.binding.mios/examples/transform   

Offline synapse007

  • Sr. Newbie
  • *
  • Posts: 21
  • Karma: +0/-0
Re: Tools: openHAB Item file generator
« Reply #42 on: September 20, 2015, 11:36:52 pm »
Wow this guy @guessed is a genius ! I am stumbling through openhab and mios. The item generator is pure magic. Thanks for your time and hardwork.

Offline msebbe

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: Tools: openHAB Item file generator
« Reply #43 on: November 07, 2015, 03:05:43 pm »
text

Hi, I wanna start of by thanking you for this work - This is exactly what I am looking for :)
I have a Vera Edge running UI7. I have installed openhab on my raspberry pi 2. I have low knowledge of linux :((

I get this problem:

Code: [Select]
root@RaspberryVERA:/opt/OH/tools# ./miosTransform.sh house
Transforming MiOS Unit Metadata from user_data.xml...
warning: failed to load external entity "miosTransform.xslt"
cannot parse miosTransform.xslt
Failed to Transform, Check for bogus XML in user_data.xml.

What is wrong? :( Appreciate any help!


Edit: After doublechecking everything I realised that I forgot to copy miosTransform.xslt to my raspberry...

Worked now I think. Will continue tomorrow :)
« Last Edit: November 07, 2015, 03:10:35 pm by msebbe »

Offline guessed

  • Moderator
  • Master Member
  • *****
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Tools: openHAB Item file generator
« Reply #44 on: November 07, 2015, 03:18:51 pm »
@msebbe,
Let me know if you run into issues.  I've done the conversion for a few folks, in order to get sample data, and the biggest one I normally hit is that MiOS emits non-conforming XML.

This most often happens when you have Lua rules, since MiOS/Vera is not escaping "<" "&" etc when exporting the XML content (I've considered exporting is as JSON, and then converting it externally to XML, just to get around their buggy code.

There's a pending review for a revised version of the XSLT file that'll handle a broader array of MiOS Plugins (mostly @lolodomo's RFXTRX Plugin, but others also). 

That'll bubble up in r1.8.


If you find ":serviceId:" strings in your openHAB Items file, after transformation, let me know as I'm looking to handle default mappings for _every_ common plugin out there.