{"id":13285,"date":"2021-03-21T13:44:15","date_gmt":"2021-03-21T13:44:15","guid":{"rendered":"https:\/\/www.rjt.org.uk\/home\/?post_type=home_assistant_tip&#038;p=13285"},"modified":"2021-03-22T12:58:47","modified_gmt":"2021-03-22T12:58:47","slug":"setting-attributes-from-windows-using-curl","status":"publish","type":"home_assistant_tip","link":"https:\/\/www.rjt.org.uk\/home\/archives\/home-assistant-tip\/setting-attributes-from-windows-using-curl\/","title":{"rendered":"Setting Attributes from Windows using curl"},"content":{"rendered":"<p>Create a Long Access Token in \/Profile and replace <em>long_access_token<\/em> below.<\/p>\n<p>On Windows you can not use single quotes around the json so all single quotes must be escaped.<\/p>\n<p>Replace <em>entity_name <\/em>with the name of the entitiy you want to set.<\/p>\n<p>The whole lot must have no new line characters if using at batch or powershell call.<br \/>\n[cc]curl -X POST<br \/>\n-H &#8220;Authorization: Bearer <em>long_access_token<\/em>&#8221;<br \/>\n-H &#8220;Content-Type: application\/json&#8221;<br \/>\n-d &#8220;{\\&#8221;state\\&#8221;: \\&#8221;on\\&#8221;, \\&#8221;attributes\\&#8221;: {\\&#8221;backup-a\\&#8221;: \\&#8221;ok\\&#8221;}}&#8221;<br \/>\nhttp:\/\/homeassistant.local:8123\/api\/states\/<em>entity_name<\/em>[\/cc]<br \/>\nFor more information see <a href=\"https:\/\/developers.home-assistant.io\/docs\/api\/rest\/\">https:\/\/developers.home-assistant.io\/docs\/api\/rest\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Another option is to use the Powershell invoke-restmethod option see<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-gb\/powershell\/module\/microsoft.powershell.utility\/invoke-restmethod?view=powershell-7.1\">https:\/\/docs.microsoft.com\/en-gb\/powershell\/module\/microsoft.powershell.utility\/invoke-restmethod?view=powershell-7.1<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"template":"","class_list":["post-13285","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\/13285","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=13285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}