Author Topic: In Lieu Of A WeatherCat Plugin For Indigo Domotics Home Automation Software  (Read 800 times)

DaveHawk

  • Gentle Breeze
  • **
  • Posts: 10
    • EW1712
    • KOHCANAL12
  • Station Details: Davis Vantage Pro 2
I am a long time user of both WeatherCat and Indigo. I have been getting my WC data with applelscript to create variables within Indigo. But  Indigo, in the next release, is dropping support for applescript. However, a plugin for Indigo (Ghost XML) creates variables from either a JSON or XML feed - file or web interface.  I would like to query WC with a list of tags and populate a file in either JSON or XML format to feed to the Indigo plugin.  I have no web experience and have no idea how this can be done.  I am wondering if anyone has any ideas that will help me out?

Thanks.

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 5257
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
WeatherCat web tags could create XML (Re: In Lieu Of A WeatherCat Plugin)
« Reply #1 on: December 19, 2018, 11:07:09 PM »
Dear DaveHawk and WeatherCat troubleshooters,

Since this is your first posting on the WeatherCat forum, let me welcome you here!

I am a long time user of both WeatherCat and Indigo. I have been getting my WC data with applelscript to create variables within Indigo. But  Indigo, in the next release, is dropping support for applescript. However, a plugin for Indigo (Ghost XML) creates variables from either a JSON or XML feed - file or web interface.  I would like to query WC with a list of tags and populate a file in either JSON or XML format to feed to the Indigo plugin.  I have no web experience and have no idea how this can be done.  I am wondering if anyone has any ideas that will help me out?

WeatherCat can generate HTML pages that replace WeatherCat tags with actual data.  XML is extremely similar to HTML and you could create your own XML files very easily using WeatherCat's tag generation facility.  Here is a tiny XML file:

Code: [Select]
<note>
    <to>Tove</to>
   <from>Jani</from>
   <heading>Reminder</heading>
   <body>Don't forget me this weekend!</body>
</note>

The example is from this page:

https://www.w3schools.com/xml/xml_examples.asp

There is a full tutorial on this page:

https://www.w3schools.com/xml/default.asp

The idea is to generalize what HTML is like where data types are like HTML tags.  So in the example above the overall data type is a note.  Inside are 4 types of data: the from person the to person the heading and the message body.  These are arbitrary.  In your case you would choose data type names that would match the variables you are trying to import into Indigo. 

It might take a little horsing around, but you should be able to get WeatherCat's web template tool to make the files you need.  Take a look at the documentation for Custom web that you will find starting on page 102 of the current WeatherCat manual.

If you have additional questions don't hesitate to ask.  We have a number of power HTML users, they should be able to help you get an XML file that will satisfy your plugin.

Cheers, Edouard


DaveHawk

  • Gentle Breeze
  • **
  • Posts: 10
    • EW1712
    • KOHCANAL12
  • Station Details: Davis Vantage Pro 2
Elagache,

Thank you for your answer and suggestions - it looks like I have my work cut out for me. I have ordered books from the library and will look into the links you provided. For my clarification: it seems if I am going to use the Indigo plugin I mentioned, I will have to write my code in XML and then I will have XML files that I can use for input to the plugin.  Am I on the right track, or have I gone off the track?

Thanks again.

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 5257
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Dear DaveHawk and WeatherCat scripters,

Thank you for your answer and suggestions - it looks like I have my work cut out for me. I have ordered books from the library and will look into the links you provided. For my clarification: it seems if I am going to use the Indigo plugin I mentioned, I will have to write my code in XML and then I will have XML files that I can use for input to the plugin.  Am I on the right track, or have I gone off the track?

I don't think it is as hard as you are imagining it.  WeatherCat can generate HTML files, but doesn't have any awareness of HTML.  It simply replaces the tags that are described in the section I mentioned with the actual values.  So WeatherCat can produce the files without you doing any coding.  What you'll need is an example of the XML file that the Indigo plugin is expecting.  It should look like the example I posted earlier with the names referring to the variables that you want to import into Indigo.  Once you know which names to use, WeatherCat can populate the XML files with the data.  You need to learn a bit more about how WeatherCat creates custom web files.  You don't need to have the files uploaded to a server.  WeatherCat leaves the generated files in a folder on your Mac.  All you need to do is point the Indigo plugin at those files and it should work.

Don't hesitate to ask more questions.  I've never done anything in XML but the concept should work okay.

Cheers, Edouard

DaveHawk

  • Gentle Breeze
  • **
  • Posts: 10
    • EW1712
    • KOHCANAL12
  • Station Details: Davis Vantage Pro 2
Dear elagache thank you yet again,

Here is an example of a XML file downloaded from WeatherLink 2.0 that can be used for input to the Indigo plugin. If someone could provide a snippet of the code needed to generate the same format from WC, it would be appreciated.



Code: [Select]
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<current_observation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:noNamespaceSchemaLocation="http://www.weather.gov/view/current_observation.xsd">
<credit>Davis Instruments Corp.</credit>
<credit_URL>http://www.davisnet.com</credit_URL>
<disclaimer_url>http://www.davisnet.com/about/terms.asp</disclaimer_url>
<copyright_url>http://www.davisnet.com/about/terms.asp</copyright_url>
<privacy_policy_url>http://www.davisnet.com/about/privacy.asp</privacy_policy_url>
<image>
<url>
http://www.weatherlink.com/images/Logo_Davis_reflxblu.jpg
</url>
<title>Davis WeatherLink</title>
<link>http://www.weatherlink.com</link>
</image>
<suggested_pickup>15 minutes after the hour</suggested_pickup>
<suggested_pickup_period>60</suggested_pickup_period>
<dewpoint_c>3.3</dewpoint_c>
<dewpoint_f>38.0</dewpoint_f>
<dewpoint_string>38.0 F (3.3 C)</dewpoint_string>
<heat_index_c>4.4</heat_index_c>
<heat_index_f>40.0</heat_index_f>
<heat_index_string>40.0 F (4.4 C)</heat_index_string>
<location>Canal Winchester, OH, USA</location>
<latitude>39.82098</latitude>
<longitude>-82.80009</longitude>
<observation_time>Last Updated on Dec 21 2018, 9:12 am EST</observation_time>
<observation_time_rfc822>Fri, 21 Dec 2018 09:12:46 -0500</observation_time_rfc822>
<pressure_in>29.359</pressure_in>
<pressure_mb>994.2</pressure_mb>
<pressure_string>994.2 mb</pressure_string>
<relative_humidity>93</relative_humidity>
<station_id>XXXXXXXX</station_id>
<temp_c>4.4</temp_c>
<temp_f>39.9</temp_f>
<temperature_string>39.9 F (4.4 C)</temperature_string>
<wind_degrees>342</wind_degrees>
<wind_dir>North-northwest</wind_dir>
<wind_kt>3.5</wind_kt>
<wind_mph>4.0</wind_mph>
<windchill_c>2.8</windchill_c>
<windchill_f>37.0</windchill_f>
<windchill_string>37.0 F (2.8 C)</windchill_string>
<davis_current_observation>
<DID>001D0A005FE1</DID>
<station_name>Hawks Nest</station_name>
<observation_age>30</observation_age>
<dewpoint_day_high_f>41</dewpoint_day_high_f>
<dewpoint_day_high_time>12:00am</dewpoint_day_high_time>
<dewpoint_day_low_f>38</dewpoint_day_low_f>
<dewpoint_day_low_time>6:32am</dewpoint_day_low_time>
<dewpoint_month_high_f>53</dewpoint_month_high_f>
<dewpoint_month_low_f>11</dewpoint_month_low_f>
<dewpoint_year_high_f>81</dewpoint_year_high_f>
<dewpoint_year_low_f>-12</dewpoint_year_low_f>
<heat_index_day_high_f>42</heat_index_day_high_f>
<heat_index_day_high_time>12:00am</heat_index_day_high_time>
<heat_index_month_high_f>63</heat_index_month_high_f>
<heat_index_year_high_f>112</heat_index_year_high_f>
<pressure_day_high_in>29.382</pressure_day_high_in>
<pressure_day_high_time>8:00am</pressure_day_high_time>
<pressure_day_low_in>29.313</pressure_day_low_in>
<pressure_day_low_time>12:36am</pressure_day_low_time>
<pressure_month_high_in>30.650</pressure_month_high_in>
<pressure_month_low_in>29.313</pressure_month_low_in>
<pressure_tendency_string>Steady</pressure_tendency_string>
<pressure_year_high_in>30.775</pressure_year_high_in>
<pressure_year_low_in>29.313</pressure_year_low_in>
<rain_day_in>0.1000</rain_day_in>
<rain_month_in>2.9000</rain_month_in>
<rain_rate_day_high_in_per_hr>0.1100</rain_rate_day_high_in_per_hr>
<rain_rate_day_high_time>1:37am</rain_rate_day_high_time>
<rain_rate_hour_high_in_per_hr>0.0000</rain_rate_hour_high_in_per_hr>
<rain_rate_in_per_hr>0.0000</rain_rate_in_per_hr>
<rain_rate_month_high_in_per_hr>0.4600</rain_rate_month_high_in_per_hr>
<rain_rate_year_high_in_per_hr>82.2900</rain_rate_year_high_in_per_hr>
<rain_storm_in>0.6200</rain_storm_in>
<rain_storm_start_date>12/4/2018</rain_storm_start_date>
<rain_year_in>54.0700</rain_year_in>
<relative_humidity_day_high>96</relative_humidity_day_high>
<relative_humidity_day_high_time>12:00am</relative_humidity_day_high_time>
<relative_humidity_day_low>93</relative_humidity_day_low>
<relative_humidity_day_low_time>6:32am</relative_humidity_day_low_time>
<relative_humidity_month_high>98</relative_humidity_month_high>
<relative_humidity_month_low>44</relative_humidity_month_low>
<relative_humidity_year_high>98</relative_humidity_year_high>
<relative_humidity_year_low>24</relative_humidity_year_low>
<relative_humidity_in>31</relative_humidity_in>
<relative_humidity_in_day_high>31</relative_humidity_in_day_high>
<relative_humidity_in_day_high_time>1:22am</relative_humidity_in_day_high_time>
<relative_humidity_in_day_low>30</relative_humidity_in_day_low>
<relative_humidity_in_day_low_time>12:00am</relative_humidity_in_day_low_time>
<relative_humidity_in_month_high>37</relative_humidity_in_month_high>
<relative_humidity_in_month_low>22</relative_humidity_in_month_low>
<relative_humidity_in_year_high>56</relative_humidity_in_year_high>
<relative_humidity_in_year_low>20</relative_humidity_in_year_low>
<sunrise>7:49am</sunrise>
<sunset>5:10pm</sunset>
<temp_day_high_f>41.5</temp_day_high_f>
<temp_day_high_time>12:00am</temp_day_high_time>
<temp_day_low_f>39.6</temp_day_low_f>
<temp_day_low_time>7:54am</temp_day_low_time>
<temp_month_high_f>65.0</temp_month_high_f>
<temp_month_low_f>13.2</temp_month_low_f>
<temp_year_high_f>94.0</temp_year_high_f>
<temp_year_low_f>-8.0</temp_year_low_f>
<temp_in_day_high_f>70.1</temp_in_day_high_f>
<temp_in_day_high_time>8:55am</temp_in_day_high_time>
<temp_in_day_low_f>67.2</temp_in_day_low_f>
<temp_in_day_low_time>4:48am</temp_in_day_low_time>
<temp_in_f>70.1</temp_in_f>
<temp_in_month_high_f>71.8</temp_in_month_high_f>
<temp_in_month_low_f>64.2</temp_in_month_low_f>
<temp_in_year_high_f>80.0</temp_in_year_high_f>
<temp_in_year_low_f>60.0</temp_in_year_low_f>
<wind_day_high_mph>17.0</wind_day_high_mph>
<wind_day_high_time>4:56am</wind_day_high_time>
<wind_month_high_mph>26.0</wind_month_high_mph>
<wind_ten_min_avg_mph>8.0</wind_ten_min_avg_mph>
<wind_ten_min_gust_mph>13.0</wind_ten_min_gust_mph>
<wind_year_high_mph>39.0</wind_year_high_mph>
<windchill_day_low_f>34</windchill_day_low_f>
<windchill_day_low_time>4:40am</windchill_day_low_time>
<windchill_month_low_f>10</windchill_month_low_f>
<windchill_year_low_f>-18</windchill_year_low_f>
</davis_current_observation>
<time_to_generate>0.010426 seconds</time_to_generate>
</current_observation>

xairbusdriver

  • Storm
  • *****
  • Posts: 2320
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.14.4/WC 3.0.4
First, while WC can create some very simple HTML pages, I don't think this is what you really need/want. Since you already know what I believe the place to looIndigo needs are XML files, you simply need to use the files you have without the values.

What you need to do is to create "blank" XML file (or files) for each one you want and then insert the WC "Web-Tags" where you want the actual value to be. Those "tags" are listed in the Manual starting around page 196 (for WC v3). Below I will take parts of the code you posted and show how to replace the values with WC tags:

Code: [Select]
...
<suggested_pickup>15 minutes after the hour</suggested_pickup>
<suggested_pickup_period>60</suggested_pickup_period>
<!--dewpoint_c--><!--3.3--><!--/dewpoint_c-->
<!--dewpoint_f--><!--38.0--><!--/dewpoint_f-->
<dewpoint_string>CD$<!--38.0 F (3.3 C)--></dewpoint_string>
<!--heat_index_c--><!--4.4--><!--/heat_index_c-->
<!--heat_index_f--><!--40.0 F (4.4 C)--><!--/heat_index_f-->
<heat_index_string>STAT_$_HEATINDEX:CURRENT_$_TEMPUNITS_$<!--40.0 F (4.4 C)--></heat_index_string>
...
<!--pressure_in--><!--29.359--><!--/pressure_in-->
<!--pressure_mb--><!--994.2--><!--/pressure_mb-->
<pressure_string>CP$</pressure_string>
<relative_humidity>STAT$EXTHUMIDITY:CURRENT$ %</relative_humidity>
...
"<!--" and "-->" are what I hope are the 'comment' labels. There is no need to change the constant values such as LAT/LON, etc.

You will note that some WC tags produce the same display in the format you want ["CD$" and "CP$"]. Others can be displayed using tags that need additional parameters ["STAT$EXTHUMIDITY:CURRENT$ %"] the "%" is just plain text for whatever units you want. Lastly, some may not be exact matches to what you currently have: WC has you set the units such as mm or inches, mph or kph, etc. but not both at the same time.

Hopefully you can use the tags in the appendix and place them where needed in the XML files.

Then, you simply add these files to the WC prefs->On-Line->Custom Web->Additional Files. WC will, then 'grab' those files and replace the tags in them with the data gathered from your weather station hardware.

The real experts here can help with the other tags and parameters that I have neglected to provide. Just tell them what you need and they will be exceedingly helpful. ThU5:-)

DaveHawk

  • Gentle Breeze
  • **
  • Posts: 10
    • EW1712
    • KOHCANAL12
  • Station Details: Davis Vantage Pro 2
Dear X-Air,

I should have thanked you earlier, but with Christmas and all I have been pretty busy. Your post was exactly on target!  I have been able to successfully generate the XML data needed for my Indigo plugin.

Thanks again.

xairbusdriver

  • Storm
  • *****
  • Posts: 2320
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.14.4/WC 3.0.4
"Busy"? Who's busy?! If you are alive, you're busy or need to be!! cmu:-) I'm sure you could have figured things out without any input from me, but I'm glad it helped! :) The real experts here are the really busy ones! ThU32:-)

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 5257
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Congratulations! (Re: In Lieu Of A WeatherCat Plugin)
« Reply #8 on: December 30, 2018, 11:02:46 PM »
Dear DaveHawk, X-Air and WeatherCat tinkerers,

I should have thanked you earlier, but with Christmas and all I have been pretty busy. Your post was exactly on target!  I have been able to successfully generate the XML data needed for my Indigo plugin.

Glad to hear it!  :)  Everybody likes a happy ending!  [bounce]

Cheers, Edouard  [cheers1]

Blicj11

  • Storm
  • *****
  • Posts: 3215
    • EW3808
    • KUTHEBER6
    • Timber Lakes Utah
  • Station Details: Davis Vantage Pro2 Plus | WeatherLinkIP™ Data Logger | iMac (late 2013), 3.5 GHz Intel Core i7, 24 GB RAM, macOS Mojave | Sharx SCNC2900 Webcam | Supportive Wife
Every once in a while Xairbusdriver is correct about something. Glad to see he knocked it out of the park this time. Hahaha. Congratulations to both of you on a job well done.
 ;)
Blick


xairbusdriver

  • Storm
  • *****
  • Posts: 2320
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.14.4/WC 3.0.4
 cmu:-)