{"id":13270,"date":"2021-03-18T08:50:15","date_gmt":"2021-03-18T08:50:15","guid":{"rendered":"https:\/\/www.rjt.org.uk\/home\/?post_type=home_assistant_tip&#038;p=13270"},"modified":"2021-03-23T10:23:22","modified_gmt":"2021-03-23T10:23:22","slug":"using-a-rest-service","status":"publish","type":"home_assistant_tip","link":"https:\/\/www.rjt.org.uk\/home\/archives\/home-assistant-tip\/using-a-rest-service\/","title":{"rendered":"Using a Rest Service"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">rest:\n    resource: https:\/\/www.xxxx.com\n    scan_interval: 3600\n    sensor:\n      - name: rubbish\n        value_template: 'OK'\n        json_attributes:\n         - \"GARDEN\"\n          - \"REFUSE\"\n          - \"RECYCLING\"\n\n      - name: rubbish-garden\n        value_template: '{{value_json[\"GARDEN\"]}}'\n      - name: rubbish-recycling\n        value_template: '{{ value_json[\"RECYCLING\"]}}'\n      - name: rubbish-refuse\n        value_template: '{{ value_json[\"REFUSE\"]}}'<\/pre>\n\n\n\n<p><a href=\"https:\/\/www.home-assistant.io\/integrations\/rest\/\">HA Rest Documentation<\/a><\/p>\n\n\n\n<p>The above configuration creates a sensor with 3 attributes, it requests a json file every hour in the format shown below and extracts the 3 dates and creates sensors for each of the 3 values.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\"GARDEN\":\"2021-03-18\",\"RECYCLING\":\"2021-03-19\",\"REFUSE\":\"2021-03-19\"}<\/pre>\n","protected":false},"template":"","class_list":["post-13270","home_assistant_tip","type-home_assistant_tip","status-publish","hentry","comments-off"],"_links":{"self":[{"href":"https:\/\/www.rjt.org.uk\/home\/wp-json\/wp\/v2\/home_assistant_tip\/13270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rjt.org.uk\/home\/wp-json\/wp\/v2\/home_assistant_tip"}],"about":[{"href":"https:\/\/www.rjt.org.uk\/home\/wp-json\/wp\/v2\/types\/home_assistant_tip"}],"wp:attachment":[{"href":"https:\/\/www.rjt.org.uk\/home\/wp-json\/wp\/v2\/media?parent=13270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}