{"id":1101,"date":"2022-12-10T07:35:59","date_gmt":"2022-12-10T06:35:59","guid":{"rendered":"http:\/\/lesmrdtrucs.mataf35400.fr\/?page_id=1101"},"modified":"2022-12-10T07:41:27","modified_gmt":"2022-12-10T06:41:27","slug":"lua-time-script_time_sunset_sunrise-txt","status":"publish","type":"page","link":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/lua-time-script_time_sunset_sunrise-txt\/","title":{"rendered":"LUA Time script_time_sunset_sunrise.txt"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1101\" class=\"elementor elementor-1101\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-657dcb31 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"657dcb31\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-268ae53f\" data-id=\"268ae53f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-c775c6f elementor-widget elementor-widget-text-editor\" data-id=\"c775c6f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><span style=\"color: #339966;\"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; Script : script_time_sunset_sunrise.lua<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; Objectif : Update virtual devices (Text) with sunrise and sunset values<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Permet d&rsquo;afficher l&rsquo;heure du lev\u00e9 et du couch\u00e9 du soleil<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; Auteur : Raphael<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; Date : 19\/03\/2017<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; Version : 1.0<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; Script parameters<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>Debug = \u00ab\u00a0NO\u00a0\u00bb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 <span style=\"color: #339966;\">\u00a0&#8212; Turn debugging on (\u00ab\u00a0YES\u00a0\u00bb) or off (\u00ab\u00a0NO\u00a0\u00bb)<\/span><\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0<span style=\"color: #339966;\">&#8212; YES to force Sunrise<\/span><\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; Script functions<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>local function WhichSeason() <span style=\"color: #339966;\">&#8212; Calcul de la saison<\/span><\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0local tNow = os.date(\u00ab\u00a0*t\u00a0\u00bb)<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0local dayofyear = tNow.yday<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0local season<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0if (dayofyear &gt;= 79) and (dayofyear &lt; 172) then season = \u00ab\u00a0Printemps\u00a0\u00bb<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0elseif (dayofyear &gt;= 172) and (dayofyear &lt; 266) then season = \u00ab\u00a0Ete\u00a0\u00bb<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0elseif (dayofyear &gt;= 266) and (dayofyear &lt; 355) then season = \u00ab\u00a0Automne\u00a0\u00bb<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0else season = \u00ab\u00a0Hiver\u00a0\u00bb<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0end<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0return season<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>end<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>local function IsWeekend()\u00a0 <span style=\"color: #339966;\">&#8212; [0-6 = Sunday-Saturday]<\/span><\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0local dayNow = tonumber(os.date(\u00ab\u00a0%w\u00a0\u00bb))<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0local weekend<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0if (dayNow == 0) or (dayNow == 6) then weekend = \u00ab\u00a0True\u00a0\u00bb else weekend = \u00ab\u00a0False\u00a0\u00bb end<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0 \u00a0return weekend<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>end<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; IDX of virtual devices<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>local sunrise_idx = &lsquo;5&rsquo; <span style=\"color: #339966;\">&#8212; Heure du lever du soleil<\/span><\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>local sunset_idx = &lsquo;6&rsquo;\u00a0 <span style=\"color: #339966;\">&#8212; Heure du coucher du soleil<\/span><\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212; CommandArray<\/em><\/span><br \/><span style=\"color: #339966;\"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>commandArray = {}<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0time = os.date(\u00ab\u00a0*t\u00a0\u00bb)<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0<span style=\"color: #339966;\">&#8212; Trigger at 00:05 everyday<\/span><\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0if (time.hour == 0 and time.min == 5) or Debug==\u00a0\u00bbYES\u00a0\u00bb then<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0local val1 = timeofday[&lsquo;SunriseInMinutes&rsquo;]<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0local sunrise_txt = string.format(&lsquo;%02d:%02d&rsquo;, math.floor(val1 \/ 60), val1 % 60)<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0commandArray[1] = { [&lsquo;UpdateDevice&rsquo;] = sunrise_idx .. &lsquo;|0|&rsquo; .. sunrise_txt }<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0local val2 = timeofday[&lsquo;SunsetInMinutes&rsquo;]<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0local sunset_txt = string.format(&lsquo;%02d:%02d&rsquo;, math.floor(val2 \/ 60), val2 % 60)<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0commandArray[2] = { [&lsquo;UpdateDevice&rsquo;] = sunset_idx .. &lsquo;|0|&rsquo; .. sunset_txt }<\/em><\/span><br \/><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if Debug==\u00a0\u00bbYES\u00a0\u00bb then\u00a0 <span style=\"color: #339966;\">&#8212; Affichage des infos si Mode Debug = YES<\/span><\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0local season\u00a0 = WhichSeason();<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0print (&lsquo;saison &lsquo;..season)<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0print(&lsquo;Leve du soleil: &lsquo;..sunrise_txt..&rsquo; \/ Couche du soleil: &lsquo;..sunset_txt)<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if IsWeekend==\u00a0\u00bbTrue\u00a0\u00bb then print \u00ab\u00a0Samedi Dimanche\u00a0\u00bb else print \u00ab\u00a0Lundi Mardi Mercredi Jeudi Vendredi \u00a0\u00bb end<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0end<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>\u00a0\u00a0 \u00a0end<\/em><\/span><br \/><span style=\"color: #0000ff;\"><em>return commandArray <\/em><\/span><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8212; Script : script_time_sunset_sunrise.lua&#8212;&#8212; Objectif : Update virtual devices (Text) with sunrise and sunset values&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0Permet d&rsquo;afficher l&rsquo;heure du lev\u00e9 et du couch\u00e9 du soleil&#8212;&#8212; Auteur : Raphael&#8212; Date : 19\/03\/2017&#8212; Version : 1.0&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8212; Script parameters&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-Debug = \u00ab\u00a0NO\u00a0\u00bb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&#8212; Turn debugging on (\u00ab\u00a0YES\u00a0\u00bb) or off (\u00ab\u00a0NO\u00a0\u00bb)\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&#8212; YES to force [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","footnotes":""},"class_list":["post-1101","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/wp-json\/wp\/v2\/pages\/1101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/wp-json\/wp\/v2\/comments?post=1101"}],"version-history":[{"count":4,"href":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/wp-json\/wp\/v2\/pages\/1101\/revisions"}],"predecessor-version":[{"id":1109,"href":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/wp-json\/wp\/v2\/pages\/1101\/revisions\/1109"}],"wp:attachment":[{"href":"https:\/\/lesmrdtrucs.mataf35400.fr\/index.php\/wp-json\/wp\/v2\/media?parent=1101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}