LINUX Raspberry:Creating the file tellstick.conf

Moderator: Telldus

Post Reply
Jean-Julien
Posts: 34
Joined: Fri Mar 17, 2023 9:45 am

LINUX Raspberry:Creating the file tellstick.conf

Post by Jean-Julien »

Si les modules a commander sont dans une base de données, il est possible de creer automatiquement le fichier tellstick.conf
Modifier le nom de la table et des champs en fonction de vos données.

If the modules order are in a database, it is possible to create automatically the file tellstick.conf
Change the name of the table and the fields based on your data.

Code: Select all

<?php
// Creation du fichier (Creating the file) tellstick.conf 
// Auparavant créer le dossier (Previously to create the folder) config (mkdir config) dans /home/pi. Donner les droits sur ce dossier et sur le fichier par (Give permissions on this folder and the file by) chmod 777
// dans fichier (in file)  /etc/fstab ajouter a la fin la ligne (at the end add the line): /etc/tellstick.conf        /home/pi/config/tellstick.conf   none   bind 0 0
// ensuite (then) sudo mount -a (pour la prise en compte du fichier) (for the taking into account of the file)

include 'bd.php'; // connexion a la table (connection to the table)

// La table modules doit contenir les champs suivants: (The table modules must contain the following fields)
// num_module : numero du module (module number)
// nom_module : nom du module (name of the module)
// code_r : code du module (A, B, C... ou 123564)
// code_t : second code du module (1, 2, 3... ou 1, 10)
// config : 1 pour selflearning-switch, 2 pour codeswitch, 3 pour selflearning-dimmer
// charger la table modules
$requete = mysqli_query($cnx, "SELECT * FROM `modules` WHERE config > '0'"); // modifier le nom de la table 

$cron = fopen('/home/pi/config/tellstick.conf', 'w'); // ouverture fichier txt
    fputs ($cron, "user = \"nobody\"\n");
	fputs ($cron, "group = \"plugdev\"\n");
	fputs ($cron, "ignoreControllerConfirmation = \"false\"\n");
	
// lecture des donnees et copie dans le fichier txt
while( $result = mysqli_fetch_object( $requete ) )
{ 
    $id = $result->num_module; 
    $nom = $result->nom_module;
    $code_r = $result->code_r;
    $code_t = $result->code_t;
    $config = $result->config;
	fputs ($cron, "device {\n");
	fputs ($cron, "id = ".$id."\n");
	fputs ($cron, "name = \"".$nom."\"\n");
	fputs ($cron, "protocol = \"ARCTECH\"\n");
	if ($config == 2){
	fputs ($cron, " model = \"codeswitch\"\n");
	}
	elseif ($config == 3){
	  fputs ($cron, " model = \"selflearning-dimmer\"\n");
	}
	else {
	   fputs ($cron, " model = \"selflearning-switch\"\n");
	}
	fputs ($cron, "parameters {\n");
	fputs ($cron, "house = \"".$code_r."\"\n");
	fputs ($cron, "unit = \"".$code_t."\"\n");
	fputs ($cron, "}\n");
	fputs ($cron, "}\n");
}
mysqli_free_result($requete);
fclose($cron); // fermeture fichier txt
?>
<table style="background-color: rgb(215, 185, 123); width: 100%; text-align: left; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="2">
  <tbody>
    <tr><td>Dans un terminal, prise en compte du nouveau fichier avec la commande (In a terminal, taking account of the new file with the command): sudo /etc/init.d/telldusd restart</td></tr>
    <tr><td colspan='1' rowspan='1' style="height: 40px; width: 5%; text-align: center; font-weight: bold;"><a href="do_index_0.php">Retour</a></td><tr>
  </tbody>
</table>
stive951
Posts: 2
Joined: Fri Mar 17, 2023 9:45 am

Re: LINUX Raspberry:Creating the file tellstick.conf

Post by stive951 »

Hi,
I 've just installed the telldus center via synaptic in my ubuntu distribution.
The tellstick center works but I can't activate the live.
Post Reply