{"id":4411,"date":"2023-05-30T12:45:22","date_gmt":"2023-05-30T10:45:22","guid":{"rendered":"https:\/\/www.sigalou-domotique.fr\/?p=4411"},"modified":"2026-04-26T11:48:55","modified_gmt":"2026-04-26T09:48:55","slug":"je-voudrais-savoir-si-nous-sommes-le-jour-ou-la-nuit","status":"publish","type":"post","link":"https:\/\/www.sigalou-domotique.fr\/en\/je-voudrais-savoir-si-nous-sommes-le-jour-ou-la-nuit","title":{"rendered":"I would like to know if we are day or night"},"content":{"rendered":"<h3>Objective<\/h3>\r\n<p>My original aim was to turn on the external lights when the portal opens but <strong>only<\/strong> at night!<!--more--><\/p>\r\n<h3>Testing<\/h3>\r\n<p>I tested several integrations:<\/p>\r\n<ul>\r\n<li><a href=\"https:\/\/www.home-assistant.io\/integrations\/sun\/\" target=\"_blank\" rel=\"noopener\">Sun<\/a><\/li>\r\n<li><a href=\"https:\/\/www.home-assistant.io\/integrations\/workday\/\" target=\"_blank\" rel=\"noopener\">WorkDay<\/a> of which I speak in the Retex <a href=\"https:\/\/www.sigalou-domotique.fr\/en\/ecole-demain\/\" target=\"_blank\" rel=\"noopener\">School tomorrow?<\/a><\/li>\r\n<li><a href=\"https:\/\/www.home-assistant.io\/integrations\/tod\/\" target=\"_blank\" rel=\"noopener\">Times of the Day<\/a><\/li>\r\n<\/ul>\r\n<h3>I create a binary _sensor <strong>It's dark<\/strong><\/h3>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4418\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit.png\" alt=\"\" width=\"1051\" height=\"104\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit.png 1051w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit-600x59.png 600w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit-300x30.png 300w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit-1024x101.png 1024w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit-768x76.png 768w\" sizes=\"auto, (max-width: 1051px) 100vw, 1051px\" \/><\/p>\r\n<p>Obviously, this binary _sensor takes two values:<\/p>\r\n<ul>\r\n<li>on: when it's dark<\/li>\r\n<li>off: when it's daylight<\/li>\r\n<\/ul>\r\n<p>The most purists (who seek the difficulties) will be able to enjoy themselves and create a second binary _sensor for the \"it is daylight\". \ud83d\ude09<\/p>\r\n<p>Simplissime code of this binary_sensor, to be created in binary_sensor.yaml thinking that it has been declared in configuration.yaml:<\/p>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\">- platform: tod name: \"It's Night\" unique _id: binary_sensor.nuit after: sunset after_offset: \"-00:10\" before: sunrise before _offset: \"+00:10\"<\/pre>\r\n<p>after_offset and before_offset at 10min, it is not for the sake of perfection, it is to remember the syntax of this parameter that I want to adjust it in the future.<\/p>\r\n<ul>\r\n<li>Thank you @\u1f36\u10f0\u10db#6938 for the helping hand.<\/li>\r\n<\/ul>\r\n<h3>Use of this binary _sensor in a condition<\/h3>\r\n<p>My objective is to switch on the external lights when the gate opens ONLY when it takes night, so here is the added condition:<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4423\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit2.png\" alt=\"\" width=\"1083\" height=\"125\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit2.png 1083w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit2-600x69.png 600w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit2-300x35.png 300w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit2-1024x118.png 1024w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/05\/ilfaitnuit2-768x89.png 768w\" sizes=\"auto, (max-width: 1083px) 100vw, 1083px\" \/><\/p>\r\n<p>I do not put the condition on the closure, because if there is an adventurous day between the opening and the closing, the lights would remain on.<\/p>","protected":false},"excerpt":{"rendered":"<p>Objectif Mon objectif originel \u00e9tait de vouloir allumer les lumi\u00e8res ext\u00e9rieures quand le portail s&rsquo;ouvre mais uniquement la nuit !<\/p>","protected":false},"author":1,"featured_media":4416,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14,53,166],"tags":[81],"class_list":["post-4411","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-domotique","category-home-assistant","category-retex","tag-developpement"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/posts\/4411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/comments?post=4411"}],"version-history":[{"count":1,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/posts\/4411\/revisions"}],"predecessor-version":[{"id":11285,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/posts\/4411\/revisions\/11285"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/media\/4416"}],"wp:attachment":[{"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/media?parent=4411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/categories?post=4411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/tags?post=4411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}