<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Archives des commande - La programmation sur le web</title>
	<atom:link href="https://programmation.surleweb-france.fr/tag/commande/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmation.surleweb-france.fr/tag/commande/</link>
	<description>La programmation gratuite pour tous</description>
	<lastBuildDate>Sun, 21 Nov 2021 11:03:33 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2023/08/cropped-19518430-icone-de-programmation-pour-votre-site-web-mobile-presentation-et-conception-de-logo-gratuit-vectoriel.jpg?fit=32%2C32&#038;ssl=1</url>
	<title>Archives des commande - La programmation sur le web</title>
	<link>https://programmation.surleweb-france.fr/tag/commande/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">176210735</site>	<item>
		<title>Home Assistant, utiliser Alexa</title>
		<link>https://programmation.surleweb-france.fr/home-assistant-utiliser-alexa/</link>
					<comments>https://programmation.surleweb-france.fr/home-assistant-utiliser-alexa/#respond</comments>
		
		<dc:creator><![CDATA[Zigomato]]></dc:creator>
		<pubDate>Fri, 09 Jul 2021 14:39:09 +0000</pubDate>
				<category><![CDATA[Domotique]]></category>
		<category><![CDATA[alexa]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[commande]]></category>
		<category><![CDATA[domotique]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[skill]]></category>
		<category><![CDATA[vocale]]></category>
		<guid isPermaLink="false">https://programmation.surleweb-france.fr/?p=1037</guid>

					<description><![CDATA[<p>Mise en place du contrôle vocal de Home Assistant sans le cloud payant avec Alexa. Commande vocale Alexa enfin disponible.</p>
<p class="continue-reading-button"> <a class="continue-reading-link" href="https://programmation.surleweb-france.fr/home-assistant-utiliser-alexa/">Continuer la lecture<i class="crycon-right-dir"></i></a></p>
<p>L’article <a href="https://programmation.surleweb-france.fr/home-assistant-utiliser-alexa/">Home Assistant, utiliser Alexa</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Nous allons voir comment utiliser Alexa pour commander à la voix sa box domotique. D&rsquo;ailleurs, note dès maintenant que cette configuration est  fastidieuse, longue. Tu n&rsquo;auras pas besoin de grandes connaissances mais tu auras besoin de méthodologie.</p>



<p>En passant, il est possible d&rsquo;utiliser Home Assistant Cloud, la configuration sera automatique et bien plus simple mais ce service coutera 5 dollars par mois.</p>



<p>Pour écrire cet article, j&rsquo;ai suivi la documentation de <a href="https://www.home-assistant.io/integrations/alexa.smart_home/" target="_blank" rel="noreferrer noopener">Home Assistant</a> ainsi que la <a href="https://github.com/mike-grant/haaska/wiki/Setting-up-haaska" target="_blank" rel="noreferrer noopener">documentation Haaska</a>. Ce sera plus une traduction dans laquelle, j&rsquo;incorporai des captures ainsi que des commentaires.</p>



<p>Il y a deux parties ici, la première très grosse concerne la mise en place et configuration, la seconde, bien plus courte (si tout fonctionne) pour le test de la communication entre Home Assistant, Alexa (en gros, toute la partie Haaska, fonction et skill).</p>



<h2 class="wp-block-heading">Mise en place</h2>



<h3 class="wp-block-heading">Les pré-requis</h3>



<p>Afin de pouvoir mettre en place Alexa, il faut que Home Assistant soit ouvert à l&rsquo;extérieur en utilisant un certificat SSL. SI ce n&rsquo;est pas fait, tu peux suivre cet article : <a href="https://programmation.surleweb-france.fr/un-peu-de-securite-sur-le-home-assistant/" target="_blank" rel="noreferrer noopener">mise en place de HTTPS</a>.</p>



<p>Il te faudra deux comptes (nous allons voir la création ensuite) :</p>



<ul class="wp-block-list"><li>un compte développeur Amazon</li><li>un compte des services web Amazon (AWS)</li></ul>



<h3 class="wp-block-heading">Création du compte développeur Amazon</h3>



<p>Tout d&rsquo;abord, si cela n&rsquo;est pas encore fait, va te créer un compte développeur sur <a href="https://developer.amazon.com/fr/" target="_blank" rel="noreferrer noopener">cette page</a>.</p>



<p>Une fois l&rsquo;inscription réalisée, rends toi sur <a href="https://developer.amazon.com/alexa/console/ask" target="_blank" rel="noreferrer noopener">cette page</a>, c&rsquo;est sur cette page que les skills Alexa seront.</p>



<p>Crées une nouvelle skill : </p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="961" height="205" src="//i3.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-1.png" alt="" class="wp-image-1039" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-1.png?w=961&amp;ssl=1 961w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-1.png?resize=300%2C64&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-1.png?resize=768%2C164&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-1.png?resize=150%2C32&amp;ssl=1 150w" sizes="(max-width: 900px) 100vw, 900px" /></figure></div>



<p>Maintenant donne un nom à ton skill (par exemple « Home Assistant ») et sélectionnes la langue par défaut :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" width="513" height="377" src="//i2.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-3.png" alt="" class="wp-image-1041" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-3.png?w=513&amp;ssl=1 513w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-3.png?resize=300%2C220&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-3.png?resize=150%2C110&amp;ssl=1 150w" sizes="(max-width: 513px) 100vw, 513px" /></figure></div>



<p>Pour finir, tu sélectionnes « Smart Home » et « Provision your own » :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" width="831" height="517" src="//i3.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-4.png" alt="" class="wp-image-1042" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-4.png?w=831&amp;ssl=1 831w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-4.png?resize=300%2C187&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-4.png?resize=768%2C478&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-4.png?resize=150%2C93&amp;ssl=1 150w" sizes="(max-width: 831px) 100vw, 831px" /></figure></div>



<p>Tu peux enfin cliquer sur <strong>créer ta skill</strong> en haut à droite.</p>



<p>Dans la nouvelle page, assures-toi que la version « v3 » est bien cochée :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="572" height="174" src="//i3.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-5.png" alt="" class="wp-image-1043" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-5.png?w=572&amp;ssl=1 572w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-5.png?resize=300%2C91&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-5.png?resize=150%2C46&amp;ssl=1 150w" sizes="auto, (max-width: 572px) 100vw, 572px" /></figure></div>



<p>Maintenant que la base de ta skill est créée, tu peux garder la page ouverte, on y reviendra.</p>



<h2 class="wp-block-heading">Création du compte des services web Amazon (AWS)</h2>



<p>Après avoir créer ton compte AWS <a href="https://console.aws.amazon.com/console/home" target="_blank" rel="noreferrer noopener">ici</a>, nous allons pouvoir commencer la parties plus profonde de la préparation. Alexa Smart Home va venir déclencher notre fonction que nous allons mettre en place dans cette longue partie.</p>



<p>Nous allons utiliser le dépôt contenant haaska, la dernière version est disponible en suivant <a href="https://github.com/mike-grant/haaska/archive/refs/heads/master.zip" target="_blank" rel="noreferrer noopener">ce lien</a> (que tu peux dès maintenant télécharger).</p>



<h3 class="wp-block-heading">Création du rôle</h3>



<p>Rends toi sur cette page pour <a href="https://console.aws.amazon.com/iam/home#/home" target="_blank" rel="noreferrer noopener">la création du rôle</a>.</p>



<p>Ensuite, dans la colonne de droite, cliques sur « <strong><em>Role</em></strong> » et « <strong><em>Créer un rôle</em></strong> » :</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="//i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-6-1024x194.png" alt="" class="wp-image-1044" width="840" height="159" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-6.png?resize=1024%2C194&amp;ssl=1 1024w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-6.png?resize=300%2C57&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-6.png?resize=768%2C145&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-6.png?resize=150%2C28&amp;ssl=1 150w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-6.png?w=1285&amp;ssl=1 1285w" sizes="auto, (max-width: 840px) 100vw, 840px" /></figure></div>



<p>Sélectionnes « <strong><em>Services AWS</em></strong>« , « <strong><em>Lambda</em></strong> » et cliques sur « <strong><em>Autorisations</em></strong> » :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1004" height="535" src="//i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-7.png" alt="" class="wp-image-1045" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-7.png?w=1004&amp;ssl=1 1004w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-7.png?resize=300%2C160&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-7.png?resize=768%2C409&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-7.png?resize=150%2C80&amp;ssl=1 150w" sizes="auto, (max-width: 900px) 100vw, 900px" /></figure></div>



<p>Sur la nouvelle page, dans le champs de recherche, tapes « <strong><em>Basic</em></strong> » et sélectionnes « <strong><em>AWSLambdaBasicExecutionRole</em></strong>« , pour finir, cliques sur le boutons d&rsquo;étape suivante :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1008" height="216" src="//i3.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-8.png" alt="" class="wp-image-1046" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-8.png?w=1008&amp;ssl=1 1008w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-8.png?resize=300%2C64&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-8.png?resize=768%2C165&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-8.png?resize=150%2C32&amp;ssl=1 150w" sizes="auto, (max-width: 900px) 100vw, 900px" /></figure></div>



<p>Sur la page des balises, tu peux directement cliquer sur « <strong><em>Vérifications</em></strong>« .</p>



<p>Dans la dernière page, saisie le nom du rôle « <strong><em>lambda_basic_execution</em></strong> » et cliques sur « <strong><em>Créer un rôle</em></strong>« .</p>



<p>Maintenant que le rôle est créé, reviens à l&rsquo;<a href="https://eu-central-1.console.aws.amazon.com/console/home?region=eu-central-1" target="_blank" rel="noreferrer noopener">accueil de AWS</a> en cliquant sur l&rsquo;icone en haut à gauche.</p>



<h3 class="wp-block-heading">Sélection du langage</h3>



<p>Voici une étape importante pour la suite, tu dois sélectionner la région « <strong>eu-west-1</strong> » (pourquoi sélectionner celle-ci ??? Parce que Amazon le dit sur <a href="https://developer.amazon.com/fr-FR/docs/alexa/smarthome/develop-smart-home-skills-in-multiple-languages.html#deploy" target="_blank" rel="noreferrer noopener">cette page</a>) : </p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="391" height="579" src="//i2.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-9.png" alt="" class="wp-image-1047" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-9.png?w=391&amp;ssl=1 391w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-9.png?resize=203%2C300&amp;ssl=1 203w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-9.png?resize=101%2C150&amp;ssl=1 101w" sizes="auto, (max-width: 391px) 100vw, 391px" /></figure></div>



<h3 class="wp-block-heading">Configuration de la fonction AWS (partie 1)</h3>



<p>Toujours sur la page AWS, dans la barre de recherche, tapes « <strong><em>calcul</em></strong> » et clique sur « <strong><em>Lambda</em></strong> » :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="744" height="408" src="//i1.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-10.png" alt="" class="wp-image-1048" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-10.png?w=744&amp;ssl=1 744w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-10.png?resize=300%2C165&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-10.png?resize=150%2C82&amp;ssl=1 150w" sizes="auto, (max-width: 744px) 100vw, 744px" /></figure></div>



<p>Sur la nouvelle page, cliques sur « <strong><em>Créer une fonction</em></strong>« .</p>



<p>Dans la nouvelle page, sélectionner « Créer à partir de zéro » ensuite complétes comme cela :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="531" height="525" src="//i3.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-11.png" alt="" class="wp-image-1049" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-11.png?w=531&amp;ssl=1 531w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-11.png?resize=300%2C297&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-11.png?resize=150%2C148&amp;ssl=1 150w" sizes="auto, (max-width: 531px) 100vw, 531px" /></figure></div>



<p>Voici les informations :</p>



<ul class="wp-block-list"><li>Nom de la fonction  : <strong>haaska</strong></li><li>Execution : <strong>Python 3.6</strong> (à l&rsquo;heure de l&rsquo;ériture de cet article, la documentation du dépôt demandée cette version)</li><li>Ensuite, utilises un rôle existant en sélectionnant « <strong>lambda_basic_execution</strong>« </li></ul>



<p>Tu peux cliquer sur « <strong><em>Créer une fonction</em></strong>« .</p>



<h3 class="wp-block-heading">Configuration de la fonction AWS (partie 2)</h3>



<p>Avant de passer à cette partie, assures toi que la région soit bien définie, si tu as un doute reviens un peu en arrière.</p>



<p>Nous allons configurer le déclencheur pour la fonction, pour cela, clique sur « <strong><em>Ajouter un déclencheur</em></strong>« , sur la page de ta fonction Lambda nouvellement créer :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="799" height="326" src="//i2.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-12.png" alt="" class="wp-image-1050" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-12.png?w=799&amp;ssl=1 799w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-12.png?resize=300%2C122&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-12.png?resize=768%2C313&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-12.png?resize=150%2C61&amp;ssl=1 150w" sizes="auto, (max-width: 799px) 100vw, 799px" /></figure></div>



<p>Sur la nouvelle fenêtre, dans le premier champs, sélectionnes « <strong><em>Alexa Smart Home</em></strong>« , dans le champs<strong><em> Id Application</em></strong>, tu dois coller le <strong>Skill ID</strong> (présent sur la console développeur), l&rsquo;ID est de cette forme : <em>amzn1.ask.skill.57bc7e6f-da92-47a9-9609-6406d56886e7</em>. Pour finir, cliques sur <strong><em>Ajouter </em></strong>:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="744" height="494" src="//i2.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-13.png" alt="" class="wp-image-1051" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-13.png?w=744&amp;ssl=1 744w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-13.png?resize=300%2C199&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-13.png?resize=150%2C100&amp;ssl=1 150w" sizes="auto, (max-width: 744px) 100vw, 744px" /></figure></div>



<p>Nous allons charger le code Haasska (que tu as déjà dû télécharger avant, re-voici <a href="https://github.com/mike-grant/haaska/archive/refs/heads/master.zip" target="_blank" rel="noreferrer noopener">ce lien</a>). Restont sur la configuration de notre fonction, dans l&rsquo;onglet Code de la fen^tre, cliques sur Charger depuis puis Fichier.zip, sélectionnes le fichier Zip que tu as téléchargé : </p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="261" src="//i1.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-14-1024x261.png" alt="" class="wp-image-1052" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-14.png?resize=1024%2C261&amp;ssl=1 1024w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-14.png?resize=300%2C76&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-14.png?resize=768%2C196&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-14.png?resize=150%2C38&amp;ssl=1 150w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-14.png?w=1244&amp;ssl=1 1244w" sizes="auto, (max-width: 900px) 100vw, 900px" /></figure></div>



<p>Nous allons modifier le gestionnaire pour le paramètre d&rsquo;éxecution par « haaska.event_handler », ce cadre est disponible en dessous de la partie code :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="458" height="135" src="//i1.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-15.png" alt="" class="wp-image-1053" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-15.png?w=458&amp;ssl=1 458w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-15.png?resize=300%2C88&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-15.png?resize=150%2C44&amp;ssl=1 150w" sizes="auto, (max-width: 458px) 100vw, 458px" /></figure></div>



<h3 class="wp-block-heading">Récupération du jeton long durée de Home Assistant</h3>



<p>Rends toi sur ton Home assistant, cliques sur l&rsquo;avatar devant ton nom, puis défile la page jusqu&rsquo;à tomber sur « <strong><em>Jetons d&rsquo;accès de longue durée</em></strong>« , cliques sur « <strong><em>Créer un jeton</em></strong>« , nommes-le et valides. Copies ce code, il ne sera plus visible après.</p>



<h3 class="wp-block-heading">Configuration de la fonction Haaska</h3>



<p>Dans la section code de la fonction, double-cliques sur « <strong><em>config.json</em></strong>« , remplaces l&rsquo;URL par celui qui permet d&rsquo;accéder à ton assistant, par exemple <em>https://my-hass.example.com:8123</em> .</p>



<p>Ensuite, pour la variable « <strong><em>bearer_token</em></strong>« , copies le jeton longue durée que tu as récupéré plus tôt.</p>



<p>Toujours dans la fenêtre du code, cliques sur <strong><em>« File</em></strong> » et « <strong><em>Save All »</em></strong>.</p>



<p>Copie l&rsquo;ARN de la fonction qui doit avoir cette forme : <em>arn:aws:lambda:eu-west-1:4730256486332:function:haaska</em>.</p>



<h3 class="wp-block-heading">Récupération des identifiants de connexion avec Amazon</h3>



<p>Nous allons besoin de récupérer les identifiants pour se connecter avec Amazon, pour cela, rends toi sur <a href="https://developer.amazon.com/loginwithamazon/console/site/lwa/overview.html" target="_blank" rel="noreferrer noopener">cette page</a>, puis cliques sur « <strong><em>Afficher l&rsquo;ID et le secret du client</em></strong> » :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="516" height="344" src="//i2.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-17.png" alt="" class="wp-image-1055" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-17.png?w=516&amp;ssl=1 516w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-17.png?resize=300%2C200&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-17.png?resize=150%2C100&amp;ssl=1 150w" sizes="auto, (max-width: 516px) 100vw, 516px" /></figure></div>



<h3 class="wp-block-heading">Lien entre la fonction et la skill</h3>



<p>Retournes sur la console développeur Alexa, sur la page de ta skill, colles l&rsquo;ARN précédemment copiée dans le champs « <strong><em>Default endpoint</em></strong>« , sélectionnes ta région puis colles de nouveau l&rsquo;ARN sur le champs correspondant, fini par cliquer sur « <strong><em>SAVE</em></strong> » :</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="999" height="361" src="//i3.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-16.png" alt="" class="wp-image-1054" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-16.png?w=999&amp;ssl=1 999w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-16.png?resize=300%2C108&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-16.png?resize=768%2C278&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2021/07/image-16.png?resize=150%2C54&amp;ssl=1 150w" sizes="auto, (max-width: 900px) 100vw, 900px" /></figure></div>



<h3 class="wp-block-heading">Lien entre la Skill et la connexion Amazon</h3>



<p>Dans la fenêtre de la Skill, cliques sur « <strong><em>ACCOUNT LINKING</em></strong>« , puis saisies les champs comme suit :</p>



<figure class="wp-block-table"><table><thead><tr><th>Champ</th><th>Setting</th></tr></thead><tbody><tr><td>Authorization URI</td><td><code>https://www.amazon.com/ap/oa</code></td></tr><tr><td>Access Token URI</td><td><code>https://api.amazon.com/auth/o2/token</code></td></tr><tr><td>Client ID</td><td><em>ID LOGIN WITH AMAZON</em></td></tr><tr><td>Client Secret</td><td><em>SECRET LOGIN WITH AMAZON</em></td></tr><tr><td>Client Authentication Scheme</td><td>HTTP Basic (Recommended)</td></tr><tr><td>Scope</td><td><em>Click&nbsp;<code>+ Add Scope</code>&nbsp;and enter:</em>&nbsp;<code>profile</code></td></tr><tr><td>Domain List</td><td><em>Not used</em></td></tr><tr><td>Default Access Token Expiration Time</td><td><em>Not used</em></td></tr></tbody></table></figure>



<p>Une fois les champs mis à jour, cliques sur « <strong><em>SAVE</em></strong>« .</p>



<p>Copier la liste de redirection du bas de la page.</p>



<p>Retourner sur la page de « Login With Amazon (par <a href="https://developer.amazon.com/loginwithamazon/console/site/lwa/overview.html" target="_blank" rel="noreferrer noopener">ici</a>), puis sur le profil, cliquer sur l&rsquo;engrenage et choisir « <strong><em>Paramètre web</em></strong>« , ajoutes tes trois liens de retour autorisés.</p>



<h3 class="wp-block-heading">Conclusion de la mise en place</h3>



<p>Voilà que la grosse première partie est finie, nous allons maintenant procéder au test.</p>



<h2 class="wp-block-heading">Test d&rsquo;Haaska</h2>



<p>Reviens (ou restes) sur la page de la fonction Lambda que tu as créé, dans l&rsquo;onglet code, déroule le bouton « <strong><em>Test</em></strong> » et crées un nouveau test, nommes-le, et colle dans la partie du code ci-dessous, modifie « <strong><em>access-token-from-skill</em></strong> » par ton jeton longue durée provenant de Home Assistant et sauves : </p>



<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
  "directive": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover",
      "payloadVersion": "3",
      "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
    },
    "payload": {
      "scope": {
        "type": "BearerToken",
        "token": "access-token-from-skill"
      }
    }
  }
}</pre>



<p>Une fois cela fait, cliques sur <strong><em>Deploy</em></strong> et lances le test, si aucun message apparaît, je suis ravi pour toi.</p>



<p>Cela devrait te retourner un JSON répertoriant les appareils exposés via Home Assistant.</p>



<p>Dans mon cas, j&rsquo;ai eu plusieurs erreurs (toutes résolues) :</p>



<ul class="wp-block-list"><li>Dans le fichier <strong><em>config.json</em></strong>, j&rsquo;avais fait une petite erreur sur l&rsquo;URL</li><li>Toujours dans le même fichier, ma clé longue durée n&rsquo;était pas correcte, je l&rsquo;ai réactualisé</li></ul>



<h3 class="wp-block-heading">Conclusion du test</h3>



<p>Si tu as tout suivi, tu n&rsquo;as pas dû avoir de soucis. On va passer à l&rsquo;intégration proprement dite dans Home Assistant.</p>



<h2 class="wp-block-heading">Configuration finale</h2>



<h3 class="wp-block-heading">Activation de la Skill dans l&rsquo;application Alexa</h3>



<p>Maintenant que cette partie est effective, rends toi sur l&rsquo;application <strong><em>Alexa </em></strong>de ton smartphone, puis <strong><em>Skill et jeux</em></strong>, ensuite <strong><em>Vos Skills</em></strong>. Tu devrais voir apparaître ta skill, clique dessus et active-la. Une fois activée, Alexa recherchera des appareils à connecter.</p>



<h3 class="wp-block-heading">Configuration de Home Assistant</h3>



<p>Maintenant, cela se passe dans Home assistant, avec File Editor, allez dans<strong><em> configuration.yaml </em></strong>et modifies comme suit :</p>



<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="">alexa:
  smart_home:
    locale: fr-FR
    endpoint: https://api.amazonalexa.com/v3/events
    client_id: YOUR_SKILL_CLIENT_ID
    client_secret: YOUR_SKILL_CLIENT_SECRET</pre>



<p>Bien entendu, remplace les éléments par les tiens, ils permettent une connexion à Amazon.</p>



<p>Redémarrer le serveur.</p>



<h2 class="wp-block-heading">Conclusion finale</h2>



<p>Voilà après tout ça, tout devrait fonctionner. J&rsquo;ai simplement découvert un point important,le nommage des éléments de mon systèmes est super important.</p>
<p>L’article <a href="https://programmation.surleweb-france.fr/home-assistant-utiliser-alexa/">Home Assistant, utiliser Alexa</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmation.surleweb-france.fr/home-assistant-utiliser-alexa/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1037</post-id>	</item>
		<item>
		<title>Informations sur le temps d&#8217;une tâche</title>
		<link>https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/</link>
					<comments>https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/#respond</comments>
		
		<dc:creator><![CDATA[Zigomato]]></dc:creator>
		<pubDate>Fri, 19 Mar 2021 17:24:23 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Raspberry]]></category>
		<category><![CDATA[commande]]></category>
		<category><![CDATA[durée]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pv]]></category>
		<category><![CDATA[raspberry]]></category>
		<category><![CDATA[tâche]]></category>
		<category><![CDATA[temps]]></category>
		<guid isPermaLink="false">https://programmation.surleweb-france.fr/?p=823</guid>

					<description><![CDATA[<p>Ce paquet est PV pour Pipe Viewer, Il peut être inséré dans n'importe quel pipe normal, entre deux processus pour donner une indication visuelle de la rapidité avec laquelle les données transitent..</p>
<p class="continue-reading-button"> <a class="continue-reading-link" href="https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/">Continuer la lecture<i class="crycon-right-dir"></i></a></p>
<p>L’article <a href="https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/">Informations sur le temps d&rsquo;une tâche</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Voici un petit paquet pouvant être utile afin d&rsquo;avoir des informations sur l&rsquo;exécution du tâche lancée dans le terminal.</p>



<p>Ce paquet est PV pour Pipe Viewer, Il peut être inséré dans n&rsquo;importe quel pipe normal, entre deux processus pour donner une indication visuelle de la rapidité avec laquelle les données transitent..</p>



<h2 class="wp-block-heading">Installation du paquet</h2>



<p>Pour l&rsquo;installer, rien de plus simple, à partir du terminal (sur un debian ou dérivé) :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo apt-get install pv</pre>



<p>L&rsquo;installation ne prend que quelques secondes.</p>



<h2 class="wp-block-heading">Utilisation de PV</h2>



<p>Utilisation : pv [OPTIONS] [FICHIER]&#8230;<br>Concatène FICHIER(s), ou l&rsquo;entrée standard, sur la sortie standard<br>avec monitorage.<br>De manière simple, c&rsquo;est équivalent à la commande <strong>cat</strong> avec une barre de progression<br>-p, &#8211;progress affiche la barre de progression<br>-t, &#8211;timer affiche le temps écoulé<br>-e, &#8211;eta affiche l&rsquo;heure approximative de l&rsquo;achèvement de<br>la tâche<br>-r, &#8211;rate affiche le taux de tranfert des données<br>-a, &#8211;average-rate show data transfer average rate counter<br>-b, &#8211;bytes affiche le nombre d&rsquo;octets transférés<br>-f, &#8211;force imprime vers la sortie d&rsquo;erreur même si ce n&rsquo;est<br>pas un terminal<br>-n, &#8211;numeric imprime en pourcentage, pas les informations<br>visuelles<br>-q, &#8211;quiet n&rsquo;afficher aucune information de transfert<br>-c, &#8211;cursor utiliser les séquences d&rsquo;échappements de<br>positionnement de curseur<br>-W, &#8211;wait ne rien afficher avant qu&rsquo;au moins un octet soit<br>tranféré<br>-s, &#8211;size TAILLE ajuste la taille estimée des données à TAILLE<br>octets<br>-l, &#8211;line-mode compte les lignes au lieu des octets<br>-i, &#8211;interval SEC mise-à-jour toute les SEC secondes<br>-w, &#8211;width LARGEUR présumer la largeur du terminal à LARGEUR<br>caractères<br>-H, &#8211;height HAUTEUR présumer la hauteur du terminal à HAUTEUR lignes<br>-N, &#8211;name NOM préfixer les informations visuelles avec NOM<br>-L, &#8211;rate-limit TAUX limite le taux de transfer à TAUX octets par<br>seconde<br>-B, &#8211;buffer-size OCTETS Utiliser une mémoire tampon de OCTETS octets<br>-R, &#8211;remote PID mettre-à-jour la configuration du processus PID<br>-h, &#8211;help afficher cette aide puis quitter<br>-V, &#8211;version afficher la version puis quitter</p>



<h2 class="wp-block-heading">Exemple d&rsquo;utilisation</h2>



<h3 class="wp-block-heading">Création d’une clé bootable</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pv image.iso | dd of=/dev/sdb &amp;&amp; sync</pre>



<p>Qui rendra : </p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1,46GiO 0:00:17 [  86MiB/s] [==============================================================================>] 100%            
3062144+0 enregistrements lus
3062144+0 enregistrements écrits
1567817728 bytes (1,6 GB, 1,5 GiB) copied, 13,8749 s, 113 MB/s</pre>



<h3 class="wp-block-heading">Sauvegarde d’une base de données MariaDB</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">mysqldump mybdd | pv > mybdd.sql</pre>



<h3 class="wp-block-heading">Création d’une archive</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">tar -czf - dossier | pv > dossier.tar.gz</pre>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Voici un petit utilitaire qui même si il ne va pas te révolutionner la vie, te donnera une petite idée sur ce qui est en train de se passer</p>
<p>L’article <a href="https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/">Informations sur le temps d&rsquo;une tâche</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">823</post-id>	</item>
	</channel>
</rss>
