{"id":580,"date":"2018-09-29T20:14:38","date_gmt":"2018-09-29T19:14:38","guid":{"rendered":"http:\/\/perso.cisko.fr\/wordpress\/?p=580"},"modified":"2018-09-29T20:14:38","modified_gmt":"2018-09-29T19:14:38","slug":"jeedom-sonoff-pow-r2-tasmota-mqtt-adaptation-du-firmware","status":"publish","type":"post","link":"https:\/\/cisko.fr\/?p=580","title":{"rendered":"Jeedom, Sonoff Pow R2, Tasmota, MQTT : adaptation du firmware (Obsol\u00e8te)"},"content":{"rendered":"<p>Cet article pr\u00e9sente un petite adaptation du firmware Tasmota pour que les trames MQTT&nbsp; de rel\u00e8ve de la consommation envoy\u00e9 par mes Sonoff Pow R2 soient correctement trait\u00e9es par mon serveur Jeedom.<\/p>\n<p><!--more--><\/p>\n<p>EDIT : Cette modification est a pr\u00e9sent obsol\u00e8te car j&rsquo;ai utiliser un autre plugin jMQTT. J&rsquo;ai fait un nouvel article explication la d\u00e9marche \u00e0 suivre&nbsp;<a href=\"http:\/\/perso.cisko.fr\/wordpress\/?p=587\">http:\/\/perso.cisko.fr\/wordpress\/?p=587<\/a><\/p>\n<h1>Le pourquoi ?<\/h1>\n<p>J&rsquo;utilise le plugin MQTT de Lunarok : <a href=\"https:\/\/jeedom.com\/doc_old\/documentation\/plugins\/MQTT\/fr_FR\/MQTT\">https:\/\/jeedom.com\/doc_old\/documentation\/plugins\/MQTT\/fr_FR\/MQTT<\/a><\/p>\n<p>Ce plugin cr\u00e9er automatiquement des objets par rapport aux trames qu&rsquo;il recoit. Le probl\u00e8me est que les donn\u00e9es envoy\u00e9 par Tasmota ne sont pas trait\u00e9s car MQTT ne g\u00e8re pas des objets imbriqu\u00e9s.<\/p>\n<p>Par d\u00e9faut, Tasmota envoi ses trames MQTT sous ce format :<br \/>\n{\u00ab\u00a0Time\u00a0\u00bb:\u00a0\u00bb2018-09-29T19:47:17&Prime;,\u00a0\u00bbENERGY\u00a0\u00bb:{\u00ab\u00a0Total\u00a0\u00bb:0.370,\u00a0\u00bbYesterday\u00a0\u00bb:0.000,\u00a0\u00bbToday\u00a0\u00bb:0.370,\u00a0\u00bbPeriod\u00a0\u00bb:1,\u00a0\u00bbPower\u00a0\u00bb:53,\u00a0\u00bbFactor\u00a0\u00bb:0.87,\u00a0\u00bbVoltage\u00a0\u00bb:236,\u00a0\u00bbCurrent\u00a0\u00bb:0.259}}<\/p>\n<p>N&rsquo;ayant pas d&rsquo;int\u00e9ret \u00e0 avoir le timestamp pour mon Sonoff Pow et ne traitant que les donn\u00e9es en temps r\u00e9el, j&rsquo;ai modifier le firmware pour \u00e9mettre sous la forme :<br \/>\n{\u00ab\u00a0Total\u00a0\u00bb:0.370,\u00a0\u00bbYesterday\u00a0\u00bb:0.000,\u00a0\u00bbToday\u00a0\u00bb:0.370,\u00a0\u00bbPeriod\u00a0\u00bb:1,\u00a0\u00bbPower\u00a0\u00bb:53,\u00a0\u00bbFactor\u00a0\u00bb:0.87,\u00a0\u00bbVoltage\u00a0\u00bb:236,\u00a0\u00bbCurrent\u00a0\u00bb:0.259}<\/p>\n<p><strong>Attention<\/strong>, je n&rsquo;utilise que la fonction ENERGY donc j&rsquo;ai modifier que cette fonction. La modif peut avoir un impact sur d&rsquo;autres fonctions que je n&rsquo;utilise pas.<\/p>\n<p>De plus, en cas de mise \u00e0 jour OTA, je pense que la modification sera \u00e9cras\u00e9e.<\/p>\n<h1>Les modifications :<\/h1>\n<p>Prendre les source sur <a href=\"https:\/\/github.com\/arendst\/Sonoff-Tasmota\">https:\/\/github.com\/arendst\/Sonoff-Tasmota<\/a><\/p>\n<p>Dans le fichier sonoff.ino, trouver la fonction :<br \/>\nboolean MqttShowSensor()<\/p>\n<p>Commenter les lignes :<br \/>\n\/\/ snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(\u00ab\u00a0%s{\\\u00a0\u00bb\u00a0\u00bb D_JSON_TIME \u00ab\u00a0\\\u00a0\u00bb:\\\u00a0\u00bb%s\\\u00a0\u00bb\u00a0\u00bb), mqtt_data, GetDateAndTime(DT_LOCAL).c_str());<br \/>\n[&#8230;]<br \/>\n\/\/ snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(\u00ab\u00a0%s}\u00a0\u00bb), mqtt_data);<\/p>\n<p>Dans le fichier xdrv_03_energy.ino, trouver la ligne :<br \/>\n\/\/ snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(\u00ab\u00a0%s,\\\u00a0\u00bb\u00a0\u00bb D_RSLT_ENERGY \u00ab\u00a0\\\u00a0\u00bb:{\\\u00a0\u00bb\u00a0\u00bb D_JSON_TOTAL \u00ab\u00a0\\\u00a0\u00bb:%s,\\\u00a0\u00bb\u00a0\u00bb D_JSON_YESTERDAY \u00ab\u00a0\\\u00a0\u00bb:%s,\\\u00a0\u00bb\u00a0\u00bb D_JSON_TODAY \u00ab\u00a0\\\u00a0\u00bb:%s%s,\\\u00a0\u00bb\u00a0\u00bb D_JSON_POWERUSAGE \u00ab\u00a0\\\u00a0\u00bb:%s\u00a0\u00bb),<\/p>\n<p>Et remplacer la ligne complete par :<br \/>\nsnprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(\u00ab\u00a0%s{\\\u00a0\u00bb\u00a0\u00bb D_JSON_TOTAL \u00ab\u00a0\\\u00a0\u00bb:%s,\\\u00a0\u00bb\u00a0\u00bb D_JSON_YESTERDAY \u00ab\u00a0\\\u00a0\u00bb:%s,\\\u00a0\u00bb\u00a0\u00bb D_JSON_TODAY \u00ab\u00a0\\\u00a0\u00bb:%s%s,\\\u00a0\u00bb\u00a0\u00bb D_JSON_POWERUSAGE \u00ab\u00a0\\\u00a0\u00bb:%s\u00a0\u00bb),<\/p>\n<h1>Resultat<\/h1>\n<p><a href=\"https:\/\/cisko.fr\/wp-content\/uploads\/2018\/09\/Sonoff-PowR2-resultat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-582\" src=\"https:\/\/cisko.fr\/wp-content\/uploads\/2018\/09\/Sonoff-PowR2-resultat-300x201.png\" alt=\"\" width=\"300\" height=\"201\" srcset=\"https:\/\/cisko.fr\/wp-content\/uploads\/2018\/09\/Sonoff-PowR2-resultat-300x201.png 300w, https:\/\/cisko.fr\/wp-content\/uploads\/2018\/09\/Sonoff-PowR2-resultat-1024x686.png 1024w, https:\/\/cisko.fr\/wp-content\/uploads\/2018\/09\/Sonoff-PowR2-resultat-768x514.png 768w, https:\/\/cisko.fr\/wp-content\/uploads\/2018\/09\/Sonoff-PowR2-resultat.png 1411w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Voila, les infos sont a pr\u00e9sent bien trait\u00e9es,&nbsp; il y a plus qu&rsquo;\u00e0 param\u00e9trer le Jeedom.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cet article pr\u00e9sente un petite adaptation du firmware Tasmota pour que les trames MQTT&nbsp; de rel\u00e8ve de la consommation envoy\u00e9 par mes Sonoff Pow R2 soient correctement trait\u00e9es par mon serveur Jeedom.<\/p>\n","protected":false},"author":1,"featured_media":582,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[41,47,62,67],"class_list":["post-580","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-maison-domotique","tag-jeedom","tag-mqtt","tag-sonoff","tag-tasmota"],"_links":{"self":[{"href":"https:\/\/cisko.fr\/index.php?rest_route=\/wp\/v2\/posts\/580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cisko.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cisko.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cisko.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cisko.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=580"}],"version-history":[{"count":0,"href":"https:\/\/cisko.fr\/index.php?rest_route=\/wp\/v2\/posts\/580\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cisko.fr\/index.php?rest_route=\/wp\/v2\/media\/582"}],"wp:attachment":[{"href":"https:\/\/cisko.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cisko.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cisko.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}