PHP interface for TellStick, HomeAutomation v2.0.2 released!

Moderator: Telldus

Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

Allright, I found the problem. It didn't like the "ö" in the device name. Changing it to only ASCII made it appear when updating from the Tellstick on the devices page.

Some other strange stuff I discovered along the way:

While troubleshooting, I wrote out the $display variable in the beginning of index.php. It contains the value of settings -> defaultpage. But if I changed the value in the database, the variable didn't change. Apparently it stays in the $_SESSION array, even if it is changed in the database. That goes for hoursstatusactive as well, meaning it's not enough to add it to the database, you have to restart your browser as well (restarting the tab is not enough), or destroy the session in some other way.

I have now reinstalled the package three times, and the hoursstatusactive row never appears in the database. The same goes for the debugmode row. Comparing install\install.sql with the settings table in the database gives that they're not equal. There's Swedish names in the install.sql file, but all English in the database. I haven't found where those rows come from.

The deletion of the install directory worked as expected all three times.

The button for deleting the install directory, and the message when it is deleted, are in Swedish, even though my OS, my browser and the rest of the setup process is in English.

I changed the name of the device in TelldusCenter, but it didn't update the registry entries, neither in HKCU nor in HKLM. The SharedDevices setting was set to 1, and TelldusCenter was running elevated. Restarting TelldusCenter made no difference - the registry entries showed one name, and TelldusCenter another. Tdtool.exe showed the same name as the registry entries. Where do TelldusCenter store the value? In the driver's memory space? I solved the problem by changing the registry entries manually, making tdtool.exe use the new name without the "ö".
Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

Now the Tellstick is there, but when trying to turn it on (or off), the debug log says:

Code: Select all

02.12.2010	04:13	hatest	192.168.111.160	Unlocking dongle
02.12.2010	04:13	hatest	192.168.111.160	Locking dongle
02.12.2010	04:13	hatest	192.168.111.160	Command: C:\Progra~2\Telldus\/tdtool.exe --on 3
Output:
Turning on device 3, on - TellStick not found
Running the same command from the console, logged in as the web server user, works fine:

Code: Select all

C:\Program Files (x86)\Telldus>tdtool.exe --off 3
Turning off device 3, off - Success

C:\Program Files (x86)\Telldus>tdtool.exe --on 3
Turning on device 3, on - Success
Just let me know if I lay too much trouble in your knee. :)

/P
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by tom_rosenback »

Pal wrote:Allright, I found the problem. It didn't like the "ö" in the device name. Changing it to only ASCII made it appear when updating from the Tellstick on the devices page.
Ok, haven´t had any problems with that before...
Pal wrote: Some other strange stuff I discovered along the way:

While troubleshooting, I wrote out the $display variable in the beginning of index.php. It contains the value of settings -> defaultpage. But if I changed the value in the database, the variable didn't change. Apparently it stays in the $_SESSION array, even if it is changed in the database. That goes for hoursstatusactive as well, meaning it's not enough to add it to the database, you have to restart your browser as well (restarting the tab is not enough), or destroy the session in some other way.
It is not meant to change the settings directly in the database, all should be done in HomeAutomation. As for $display, it is not same as 'defaultpage', it is what you see in the URL field when you browse the site, if there is no display=xxx in the URL $display will be equal to 'defaultpage'. Same for 'hoursactive', you should NOT edit settings directly in the database, the $_SESSION variable is reloaded when logging in/out and when saving the settings under 'Configuration'.
Pal wrote: I have now reinstalled the package three times, and the hoursstatusactive row never appears in the database. The same goes for the debugmode row. Comparing install\install.sql with the settings table in the database gives that they're not equal. There's Swedish names in the install.sql file, but all English in the database. I haven't found where those rows come from.

The deletion of the install directory worked as expected all three times.

The button for deleting the install directory, and the message when it is deleted, are in Swedish, even though my OS, my browser and the rest of the setup process is in English.
It is not just install.sql that is imported into the database, also update files are imported depending on what version you have. If you can see 'debugmode' as such in the database then it is ok, it should be like this, if not I think there is something screwed up with some encoding somewhere.

What language do you have in your browser under Tools -> Options -> Content -> Languages -> Choose? If you have Swedish here as the top-most language, HomeAutomation also will be in swedish, why it did show you the delete confirmation message in swedish and rest in english I have to investigate.
Pal wrote: I changed the name of the device in TelldusCenter, but it didn't update the registry entries, neither in HKCU nor in HKLM. The SharedDevices setting was set to 1, and TelldusCenter was running elevated. Restarting TelldusCenter made no difference - the registry entries showed one name, and TelldusCenter another. Tdtool.exe showed the same name as the registry entries. Where do TelldusCenter store the value? In the driver's memory space? I solved the problem by changing the registry entries manually, making tdtool.exe use the new name without the "ö".
This is not part of HomeAutomation project, so I suggest you contact Telldus regarding this, but I would say that TelldusCenter use what is stored in the registry.
Pal wrote:Now the Tellstick is there, but when trying to turn it on (or off), the debug log says:

Code: Select all

02.12.2010	04:13	hatest	192.168.111.160	Unlocking dongle
02.12.2010	04:13	hatest	192.168.111.160	Locking dongle
02.12.2010	04:13	hatest	192.168.111.160	Command: C:\Progra~2\Telldus\/tdtool.exe --on 3
Output:
Turning on device 3, on - TellStick not found
Running the same command from the console, logged in as the web server user, works fine:

Code: Select all

C:\Program Files (x86)\Telldus>tdtool.exe --off 3
Turning off device 3, off - Success

C:\Program Files (x86)\Telldus>tdtool.exe --on 3
Turning on device 3, on - Success
Just let me know if I lay too much trouble in your knee. :)

/P
Must be some user permission issue here. I suppose the Update of the devices works, right? But when doing the update tdtool only fetches the registry settings.
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

tom_rosenback wrote:It is not just install.sql that is imported into the database, also update files are imported depending on what version you have. If you can see 'debugmode' as such in the database then it is ok, it should be like this, if not I think there is something screwed up with some encoding somewhere.
There we go, you're on to something! I examined the SQL files a bit further, and found the common denominator. All the missing rows contain values with ÅÄÖ. However, not all ÅÄÖ rows are missing, but the ones that are there doesn't have ÅÄÖ in them anymore. This is what I think have happened.

1. The install.sql files populated the database, EXCEPT rows with values containing ÅÄÖ and similar.
2. The other SQL files updated a bunch of rows, but it can't update rows that are not there, like the ÅÄÖ ones.
3. The setup process created a bunch of the missing rows in settings (without ÅÄÖ), but hoursstatusactive was not one of them.
4. The site won't load since hoursstatusactive is not there.

I tried setting the database collation to latin1_swedich_ci (was utf8_general_ci before) and reinstalled HomeAutomation, but the ÅÄÖ rows are still not created. I'll try fiddling with the PHP encoding settings tonight.
tom_rosenback wrote:Must be some user permission issue here. I suppose the Update of the devices works, right? But when doing the update tdtool only fetches the registry settings.
If you by "update" mean fetching the device by clicking "Update from Tellstick" on the Confiuguration -> Devices page in HomeAutomation - yup, that one works. So it seems that the web server can do a tdtool --list , but not tdtool -on/-off. The same user can do it when logged into a terminal, so the user should have permissions enough.

I'm starting to suspect that it has to do with the Fabulatech stuff. Their driver might by some reason (even though it runs as a service) require the user to be logged into a terminal. I'll dig into that by trying psexec and such tools. tdtool --list only reads from the registry, so it will never be affected by Fabulatech, while tdtool -on/-off talks to the actual Tellstick driver through the Fabulatech service. I'll also try other USB-over-Network solutions.

Fotnotes: My browser goes for English first and Swedish as second. The TelldusCenter behavior is clearly a Telldus issue, just wanted to mention it. I chose $display since it is set to $_SESSION[CFG_SESSION_KEY]["settings"]["defaultpage"] at the beginning of the index.php. You're right about not editing in the database directly, but the changes could come from my wife changing something on the settings page from another computer. I usually keep my browser running for days and sometimes weeks without restarting it, meaning the $_SESSION won't be reloaded and I won't see her changes until weeks later, leading to unexpected results. But on the other hand, this is HomeAutomation, and I guess my installation is one of the very few that will ever be configured by more than one person, so I guess I'll have to solve that problem by improving the mutual communications at home. :D
Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

FYI: I get this when I source the .sql files from within MySQL: ERROR 1366 (HY000): Incorrect string value: '\xE4ndarn...' for column 'label' at row 1

So it is clearly an ÅÄÖ problem. I'll just search and destroy all ÅÄÖ's to get all rows into the database, and continue from there.
Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

That made the installation go smoothly, the settings table is now populated with all sorts of stuff, and the setup process finds all my tellstick devices without problems.

But the tdtool problem i still there. I tried putting tdtool.exe in different places (windows, system32, PHP, homeautomation dir), but still the same error. The web server user have full control of the tdtool.exe in the homeautomation dir, and read/execute to all the other tdtool.exe's. I made the web server user a member of the local administrators group, to no avail. I can execute tdtool.exe (including turning on/off devices) using psexec (when the user is admin, since psexec uses the admin$ share).

Log files says:

Code: Select all

2010-12-06	02:35	pal	192.168.111.160	Unlocking dongle
2010-12-06	02:35	pal	192.168.111.160	Locking dongle
2010-12-06	02:35	pal	192.168.111.160	Command: D:\InetPub\wwwroot\automation\/tdtool.exe --on 5
Output:
Turning on device 5, on - TellStick not found
Trying:

Code: Select all

<?php
system("tdtool.exe --off 5");
?>
gives:

Code: Select all

Turning off device 5, off - TellStick not found
I'll dig further into this tomorrow.
Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

And, funny enough, scheduling works perfectly! It creates the scheduled tasks, and the scheduled tasks do what they're supposed to do.

I think it is some permissions issue that won't allow the tdtool process spawned by PHP to access the network (through the Fabulatech client driver) to talk to the Fabulatech server component.
Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

It suddenly started to work. I couldn't see why, but figured out that I had restarted the web server after adding the web server user as administrator. Removing the user from the admin group and restarting the web server made it stop working again, and vice versa.

I don't want my web server to run as administrator, so I'll try to figure out what permissions it really need. I'll let you know what I find out.
Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

Sidenote: The device types are in Swedish, although everything else (except the "Radera installationsmapp" button/message) is in English. It says things like "Lampa off". :)
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by tom_rosenback »

Pal, it seems like your installation gives you quite a headache.

I have to investigate the ÅÄÖ problem, and why the installation language is mixed up.

Thanks for reporting!
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
Pal
Posts: 25
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by Pal »

The bright side of getting the headache is that I get to know how the thingy is built.

Atm I'm CSS:ing your mobile page to be more finger friendly, to fit devices like Nokia N900 and iPhone, and the next project will be to integrate my Crestron stuff into the setup. The former shouldn't take long, the latter should...
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by tom_rosenback »

We have now started on the implementation of HomeAutomation v2.0 and have now come that far that we would like to have som input from you as a user. What we would like you to test is the edit page of a schedule, check Scheduler for v2.0 and throw us some comments. In the new scheduler you may click as much as you like, you won´t break anything :D If you don´t wan´t to put your comments here throw us an email instead (which can be found on the homepage which is in my signature).

Thanks in advance!

PS. The language in the new scheduler is far from finished, swedish, english and more mixed, we are mostly interested in functionality testing. If you miss something from the new scheduler now would be a good time to point it out. DS.
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
jed
Posts: 17
Joined: Fri Mar 17, 2023 9:45 am

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by jed »

Got my tellstick yesterday and installed home automation as well.
Had some initial problems on my mac mini, but they are solved now (mysql doesnt install a cli client... Had to use mysql workbench and tdtool didnt report any devices since apache runs as _www and not the user I installed telldus center with so home automation didnt find any devices).

Like it a lot and will continue to use it, my wife told me NOT to play with the lights when she is home with the kids since that would freak her out ;)


Showed it to a few collegues and they will also buy a tellstick and install home automation
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by tom_rosenback »

jed wrote:Got my tellstick yesterday and installed home automation as well.
Had some initial problems on my mac mini, but they are solved now (mysql doesnt install a cli client... Had to use mysql workbench and tdtool didnt report any devices since apache runs as _www and not the user I installed telldus center with so home automation didnt find any devices).

Like it a lot and will continue to use it, my wife told me NOT to play with the lights when she is home with the kids since that would freak her out ;)

Showed it to a few collegues and they will also buy a tellstick and install home automation
Nice to hear! Yes I´m afraid it is not so popular to turn on/off lights all the time, or at least so I have heard (read: *shouting* Did you just turn off the lights? ):D
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
tom_rosenback
Posts: 779
Joined: Fri Mar 17, 2023 9:45 am
Contact:

Re: PHP interface for TellStick, HomeAutomation v1.2.2 relea

Post by tom_rosenback »

Merry Christmas & A Happy New Year 2011!

Image
//Tom

Senaste info och release om/av HomeAutomation hittas här http://karpero.mine.nu/ha
Latest info and release of HomeAutomation can be found here http://karpero.mine.nu/ha
Post Reply