Page 3 of 5

Posted: Fri Mar 17, 2023 9:45 am
by to2
Hi again!

I was trying to install the new version of tellit, but I keep getting this warning:

Code: Select all

Warning:  mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/index.php on line 584
Line 584:

Code: Select all

while($lamp=mysql_fetch_assoc($td_lamps)){
I have checked the tellstick.conf file to see that there actiually is units there, and there is ...

Any ideas?

-to2

Posted: Fri Mar 17, 2023 9:45 am
by skorpion
Oops :P

I have added a new column in the table tellit_item
Run this in mysql:
alter table tellit_item add column tdtoolid int(4);

/Niclas

Posted: Fri Mar 17, 2023 9:45 am
by thoberre
Great!

Here is a few bugreports
How does the output from tdtool look in Linux?
The listing function does not work for OS X, as the first line has no. of items in item 0, pos 19 of the returned array.

That makes the section for tdtool around 246 like this:

Code: Select all

//Only used if tdtool is your specified executable
//This code reads your tdtool-list and puts it in the DB so it could be handled by tellit
if (1==1){
//if(stristr($tellstickExecutableFullPath,'tdtool')){
    exec($tellstickExecutableFullPath." -l",$o,$r);
    $td["nums"]=substr($o[0],19);

    for($i=1;$i<=$td["nums"];$i++){
I'm also using this

Code: Select all

$tellstickExecutableFullPath="export DYLD_LIBRARY_PATH=\"\"; /usr/bin/tdtool";
and it does not look like tellit is able to determine

Code: Select all

if(stristr($tellstickExecutableFullPath,'tdtool')) 
out of this?

This is never true for some reason, so no commands are sent to my units:

Code: Select all

    //Switch on and off
    //t_exec syntax: t_exec($t_device,$t_house,$t_number,$t_toggle,$t_debug)
    if(isset($_GET["id"]) && !isset($_GET["remitem"]) && !isset($_GET["edititem"])){
Also on my wishlist:
Could the dimmable units be presented something like this http://www.berreinvest.no/iui/3rd-party ... index.html (a skeleton demo - see lamp 3)

Posted: Fri Mar 17, 2023 9:45 am
by to2
thoberre: the dimmable screen with % from 0 - 100 looks nice!

Skorpion: any scheduler for tellit soon? :)

Posted: Fri Mar 17, 2023 9:45 am
by skorpion
Thoberre: When developing tellit on this version I have developing only on OS X
tdtool output should be the same on OS X and linux
Have you added your user to the sudoers file?
If you create a file like this, what output do you get?
<?php
system("whoami");
?>
the result should be the username that should be in the sudoers file
also the user that you used when you added lamps in TelldusCenter should be in the sudoers file

to2: I will add your scheduler when most bugs are solved

Posted: Fri Mar 17, 2023 9:45 am
by thoberre
I have rights to run tdtool (I currently run the previous version with some mods), and the output is like this from tdtool -l:

Code: Select all

xxxxxx01:~ username$ tdtool -l
Number of devices: 5
10	DESIGN	ON
11	HJORNELAMPEN	ON
12	LAMPETT	OFF
21	LOFT	ON
22     TEST ON
And debugging with this:

Code: Select all

//Only used if tdtool is your specified executable
//This code reads your tdtool-list and puts it in the DB so it could be handled by tellit
if (1==1){
//if(stristr($tellstickExecutableFullPath,'tdtool')){
    exec($tellstickExecutableFullPath." -l",$o,$r);
    $td["nums"]=substr($o[0],-1);
	print_r ($o);
    for($i=1;$i<=substr($o[0],-1;$i++){

//Only used if tdtool is your specified executable
//This code reads your tdtool-list and puts it in the DB so it could be handled by tellit
if(stristr($tellstickExecutableFullPath,'tdtool')){
    exec($tellstickExecutableFullPath." -l",$o,$r);
    $td["nums"]=substr($o[0],-1);
    for($i=1;$i<=(substr($o[0],-1));$i++){

produces this for the array and populates the database correct:

Code: Select all

Array
(
    [0] => Number of devices: 5
    [1] => 10	DESIGN	ON
    [2] => 11	HJORNELAMPEN	ON
    [3] => 12	LAMPETT	OFF
    [4] => 21	LOFT	ON
    [5] => 22	TEST	ON

)
Doesn't look like this is a rights issue - my webserver user does not need sudo rights to run tdtool.

Update: Edited, hiding my lack of knowledge. Was confused by N end of line 2 and start of line 1. So anyhow index 0 of the array must be used on my system for reading no. of items on first line.

Posted: Fri Mar 17, 2023 9:45 am
by skorpion
Hi again
I saw that I had hardcoded one line that should contain a variable.
On line 239
exec("sudo -u niclas tdtool -l",$o,$r);
change to this
exec($cmd_prefix."tdtool -l",$o,$r);

Thoberre: Ok, so if tellit populates the db correctly, thats quite good.
Whatabout setting debugging on
line 47:
$debugMode=2;

then comment out line 57: (i think its line 57 for you too, but it could be different)
#if(!isset($_GET["debug"])){
and the matching }

then add
echo $t_exec." ".$toggle." ".$t_arg;
after (about line 69)
exec($t_exec." ".$toggle." ".$t_arg);

When you turn on/off lamps now, you will first see a JS-popup containing some info.
Some are blank and som contain info.
The last lines looks like this for me

Code: Select all

EXECUTED:
sudo -u niclas/usr/bin/tdtool --on 4 1
dont bother of the last number, in my case 1, its a bug that has nothing to do with the real executed code.
The a new page will be open
What does it say?
Mine says
sudo -u niclas /usr/bin/tdtool --off 4

And for the dimmer-function, it looks very nice, and I will try to add it as soon as most bugs are solved.

/Niclas

Posted: Fri Mar 17, 2023 9:45 am
by thoberre
It looks like ($_GET["id"]) is empty at line 266

Code: Select all

    if(isset($_GET["id"]) && !isset($_GET["remitem"]) && !isset($_GET["edititem"]))
print_f ($_GET); gives an empty array output.

Also debug=2 does not bring up any javastuff at all.

Posted: Fri Mar 17, 2023 9:45 am
by skorpion
thoberre wrote:It looks like ($_GET["id"]) is empty at line 266

Code: Select all

    if(isset($_GET["id"]) && !isset($_GET["remitem"]) && !isset($_GET["edititem"]))
print_f ($_GET); gives an empty array output.

Also debug=2 does not bring up any javastuff at all.
The variable $_GET["id"] is only set when you have pushed one button (on/off)
In the code, there is 2 places that launches this.
1 for dim and rfcmd

Code: Select all

                $t="doTheThing('?id=".$lamp['id']."&dim=".strstr($lamp['name'],"DIM")."');debug('Toggle','".$lamp['id']."','".$lamp['room']."','".$lamp['name']."','".$lamp['device']."','".$lamp['house']."','".$lamp['number']."','".$lamp['dimmer']."','".$cmd_prefix.$tellstickExecutableFullPath." ".$lamp['device']." ".$lamp['house']." ".$lamp['number']."')";
1 for on/off tdtool

Code: Select all

            $t="doTheThing('?id=".$lamp['id']."&dim=".strstr($lamp['name'],"DIM")."');debug('Toggle','".$lamp['id']."','','".$lamp['name']."','','','','','".$cmd_prefix.$tellstickExecutableFullPath." ".$status." ".$lamp["tdtoolid"]."')";
So I cant see why $_GET["id"] should be unset for you. The only thing I can come up with is that you either have JS off in your browser or you dont have the files "myFunc.js" and "httpAjax.js" in the correct directory.

Thanks for the bugreports everyone!!!

Kind Regards
Niclas

Posted: Fri Mar 17, 2023 9:45 am
by thoberre
It was actually all related to

Code: Select all

$tellstickExecutableFullPath="export DYLD_LIBRARY_PATH=\"\"; /usr/bin/tdtool"; 
Changed this to single quotes and it worked, triggering javafunctions again.

Code: Select all

$tellstickExecutableFullPath="export DYLD_LIBRARY_PATH=\'\'; /usr/bin/tdtool"; 
Still the number of devices is read from index 0 in the array (first line of tdtool -l output), so that had to be changed for me.

//Thom

Posted: Fri Mar 17, 2023 9:45 am
by thoberre
A small additional wish:

I would like to add back the edit-function even when using tdtool, and view the panel grouped by room like with rfcmd.

The first to allow for the second :)

Thom

Posted: Fri Mar 17, 2023 9:45 am
by skorpion
Thoberre: I understand that you want those features back
The problem is that I need to find a easy way to edit/write tdtool's config. In OS X & Linux, this is a file & on Windows it's in the registry.
Best way would be if tdtool itself supported this.
>tdtool --del 3
or
>tdtool --add nexa a 1 --id 8

That would be easiest for me to fix.
Maybe someone of you know a better way if doing it?

/Niclas

Posted: Fri Mar 17, 2023 9:45 am
by thoberre
Hi,

I interpret it as Telldus wants us to use TelldusCenter to add/remove devices. Ref http://developer.telldus.se/browser/tru ... s-core.dox.

However we could have the editfunction to edit "configextentions" like Room, Dimcapabilities, maybe a nicer name etc.

It looks like the php-binding would be the correct way in the future since this can return the methods (also dimming).

As a sidenote it would be nice if telldus_core would allow for adding/removing devices, and would be achievable by also exposing a method to list supported devicetypes.

How to get lamp in the db.

Posted: Fri Mar 17, 2023 9:45 am
by Ole
Hi

How to add lamp to the db, in my installation i don´t get a menu item to "add lamp"

OSX 10.6.2 and MAMP

Cheers!

Re: How to get lamp in the db.

Posted: Fri Mar 17, 2023 9:45 am
by skorpion
NEW VERSION OUT!

Things I fixed:
FIXED Problem reading "tdtool --list" on different platforms
FIXED TDTOOL-compability in Debug-mode
FIXED All necessary mySQL-rows weren't defined

Download:
http://skorpion.se/tellit/zip/tellit_0.1.5.zip
Ole wrote:Hi

How to add lamp to the db, in my installation i don´t get a menu item to "add lamp"

OSX 10.6.2 and MAMP

Cheers!
If you are using TDTOOL as your executable you cant add lamps.

If you are using RFCMD, then you should be able to add lamps in "tool-icon" and on one line you should see "Add Lamp" or similar.

/niclas