diff --git a/atom.xml b/atom.xml index e2b923446e..67decefe53 100644 --- a/atom.xml +++ b/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/announcements/atom.xml b/blog/categories/announcements/atom.xml index 8ba85fb1fd..6f199b0350 100644 --- a/blog/categories/announcements/atom.xml +++ b/blog/categories/announcements/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Announcements | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/community/atom.xml b/blog/categories/community/atom.xml index e40e5323a4..4b3a847b62 100644 --- a/blog/categories/community/atom.xml +++ b/blog/categories/community/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Community | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/device-tracking/atom.xml b/blog/categories/device-tracking/atom.xml index b83289211a..c673c2cbf2 100644 --- a/blog/categories/device-tracking/atom.xml +++ b/blog/categories/device-tracking/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Device-Tracking | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/esp8266/atom.xml b/blog/categories/esp8266/atom.xml index 39a6d5f624..0b111c0f8a 100644 --- a/blog/categories/esp8266/atom.xml +++ b/blog/categories/esp8266/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: ESP8266 | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/how-to/atom.xml b/blog/categories/how-to/atom.xml index 3cdd1a159d..86e278eb34 100644 --- a/blog/categories/how-to/atom.xml +++ b/blog/categories/how-to/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: How-To | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/ibeacons/atom.xml b/blog/categories/ibeacons/atom.xml index cef4758336..fff64520c7 100644 --- a/blog/categories/ibeacons/atom.xml +++ b/blog/categories/ibeacons/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: iBeacons | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/internet-of-things/atom.xml b/blog/categories/internet-of-things/atom.xml index 365f81ac94..4f14886454 100644 --- a/blog/categories/internet-of-things/atom.xml +++ b/blog/categories/internet-of-things/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Internet-of-Things | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/iot-data/atom.xml b/blog/categories/iot-data/atom.xml index 3cec7cbddb..94fe300522 100644 --- a/blog/categories/iot-data/atom.xml +++ b/blog/categories/iot-data/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: IoT-Data | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/media/atom.xml b/blog/categories/media/atom.xml index f5d6001793..275e2d19cb 100644 --- a/blog/categories/media/atom.xml +++ b/blog/categories/media/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Media | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/merchandise/atom.xml b/blog/categories/merchandise/atom.xml index b0bda879d6..f7f0d8310f 100644 --- a/blog/categories/merchandise/atom.xml +++ b/blog/categories/merchandise/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Merchandise | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/micropython/atom.xml b/blog/categories/micropython/atom.xml index 7946d698b7..3d1d52b9c2 100644 --- a/blog/categories/micropython/atom.xml +++ b/blog/categories/micropython/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Micropython | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/mqtt/atom.xml b/blog/categories/mqtt/atom.xml index 8baaf1450c..b2256e8280 100644 --- a/blog/categories/mqtt/atom.xml +++ b/blog/categories/mqtt/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: MQTT | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/organisation/atom.xml b/blog/categories/organisation/atom.xml index 23869fc0de..fe75231771 100644 --- a/blog/categories/organisation/atom.xml +++ b/blog/categories/organisation/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Organisation | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/owntracks/atom.xml b/blog/categories/owntracks/atom.xml index bbfc39675d..b9448d9e27 100644 --- a/blog/categories/owntracks/atom.xml +++ b/blog/categories/owntracks/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: OwnTracks | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/presence-detection/atom.xml b/blog/categories/presence-detection/atom.xml index a1cf0015d8..9e2c6216a3 100644 --- a/blog/categories/presence-detection/atom.xml +++ b/blog/categories/presence-detection/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Presence-Detection | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/public-service-announcement/atom.xml b/blog/categories/public-service-announcement/atom.xml index 8a20ed05a7..1e9fe3b61e 100644 --- a/blog/categories/public-service-announcement/atom.xml +++ b/blog/categories/public-service-announcement/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Public-Service-Announcement | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/release-notes/atom.xml b/blog/categories/release-notes/atom.xml index 7715f34fa0..4eb5547fdb 100644 --- a/blog/categories/release-notes/atom.xml +++ b/blog/categories/release-notes/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Release-Notes | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/survey/atom.xml b/blog/categories/survey/atom.xml index f286b3b073..c18d87cdb6 100644 --- a/blog/categories/survey/atom.xml +++ b/blog/categories/survey/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Survey | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/talks/atom.xml b/blog/categories/talks/atom.xml index 6d4b0584b4..17585e38d7 100644 --- a/blog/categories/talks/atom.xml +++ b/blog/categories/talks/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Talks | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/technology/atom.xml b/blog/categories/technology/atom.xml index 233dab632c..bd16fce2ec 100644 --- a/blog/categories/technology/atom.xml +++ b/blog/categories/technology/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Technology | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/user-stories/atom.xml b/blog/categories/user-stories/atom.xml index 2f09c5a444..57ad547aee 100644 --- a/blog/categories/user-stories/atom.xml +++ b/blog/categories/user-stories/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: User-Stories | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/video/atom.xml b/blog/categories/video/atom.xml index e5e1d373cf..5467166357 100644 --- a/blog/categories/video/atom.xml +++ b/blog/categories/video/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Video | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/blog/categories/website/atom.xml b/blog/categories/website/atom.xml index 8ea4fc99c8..8ba6afc5f7 100644 --- a/blog/categories/website/atom.xml +++ b/blog/categories/website/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Website | Home Assistant]]> - 2017-12-03T22:24:59+00:00 + 2017-12-04T00:16:53+00:00 https://home-assistant.io/ diff --git a/components/sensor.rest/index.html b/components/sensor.rest/index.html index 6c1c647df8..419f715249 100644 --- a/components/sensor.rest/index.html +++ b/components/sensor.rest/index.html @@ -104,6 +104,7 @@
  • username (Optional): The username for accessing the REST endpoint.
  • password (Optional): The password for accessing the REST endpoint.
  • headers (Optional): The headers for the requests.
  • +
  • json_attributes (Optional): A list of keys to extract values from a JSON dictionary result and then set as sensor attributes. Default is an empty list.
  • Make sure that the URL exactly matches your endpoint or resource. @@ -116,8 +117,7 @@ Make sure that the URL exactly matches your endpoint or resource.

    Examples

    In this section you find some real life examples of how to use this sensor.

    External IP address

    -

    You can find your external IP address using the service JSON Test at their http://ip.jsontest.com/ endpoint.

    -

    To display the IP address, the entry for a sensor in the configuration.yaml file will look like this.

    +

    You can find your external IP address using the service JSON Test at their http://ip.jsontest.com/ URL.

    sensor:
       - platform: rest
         resource: http://ip.jsontest.com
    @@ -127,7 +127,6 @@ Make sure that the URL exactly matches your endpoint or resource.
     

    Single value from a local Glances instance

    The glances sensor is doing the exact same thing for all exposed values.

    -

    Add something similar to the entry below to your configuration.yaml file:

    sensor:
       - platform: rest
         resource: http://IP_ADRRESS:61208/api/2/mem/used
    @@ -184,6 +183,58 @@ User-Agent: Home Assistant
           User-Agent: Home Assistant REST sensor
     
    +

    Fetch multiple JSON values and present them as attibutes

    +

    JSON Test returns the current time, date and milliseconds since epoch from http://date.jsontest.com/.

    +
    sensor:
    +  - platform: rest
    +    name: JSON time
    +    json_attributes:
    +      - date
    +      - milliseconds_since_epoch
    +    resource: http://date.jsontest.com/
    +    value_template: '{{ value_json.time }}'
    +  - platform: template
    +    sensors:
    +      date:
    +        friendly_name: 'Date'
    +        value_template: '{{ states.sensor.json_time.attributes["date"] }}'
    +      milliseconds:
    +        friendly_name: 'milliseconds'
    +        value_template: '{{ states.sensor.json_time.attributes["milliseconds_since_epoch"] }}'
    +
    +
    +

    This sample fetches a weather report from OpenWeatherMap, maps the resulting data into attributes of the RESTful sensor and then creates a set of template sensors that monitor the attributes and present the values in a usable form.

    +
    sensor:
    +  - platform: rest
    +    name: OWM_report
    +    json_attributes: 
    +      - main
    +      - weather
    +    value_template: '{{ value_json["weather"][0]["description"].title() }}'
    +    resource: http://api.openweathermap.org/data/2.5/weather?zip=80302,us&APPID=VERYSECRETAPIKEY
    +  - platform: template
    +    sensors:
    +      owm_weather:
    +        value_template: '{{ states.sensor.owm_report.attributes.weather[0]["description"].title() }}'
    +        icon_template: '{{ "http://openweathermap.org/img/w/"+states.sensor.owm_report.attributes.weather[0]["icon"]+".png" }}'
    +        entity_id: sensor.owm_report
    +      owm_temp:
    +        friendly_name: 'Outside temp'
    +        value_template: '{{ states.sensor.owm_report.attributes.main["temp"]-273.15 }}'
    +        unit_of_measurement: "°C"
    +        entity_id: sensor.owm_report
    +      owm_pressure:
    +        friendly_name: 'Outside pressure'
    +        value_template: '{{ states.sensor.owm_report.attributes.main["pressure"] }}'
    +        unit_of_measurement: "hP"
    +        entity_id: sensor.owm_report
    +      owm_humidity:
    +        friendly_name: 'Outside humidity'
    +        value_template: '{{ states.sensor.owm_report.attributes.main["humidity"] }}'
    +        unit_of_measurement: "%"
    +        entity_id: sensor.owm_report
    +
    +