Announcement

Collapse
No announcement yet.

Is possible to read from mysql and put the value in a device

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rutger
    replied
    I suggest to strip the script as short as possible.
    Attached the same script where the JSON part will be skipped.
    You can do the same for:

    If myData.HasRows Then
    While myData.Read
    Dim address_PEUGEOT = MyData("address")


    and use only one 1 MyData object and remove the rest from the script.
    If this is working you can extend the script again, which will also not be an issue to overwrite other virtual devices (because write data to HS is done via static device-references).
    Attached Files

    Leave a comment:


  • deanrparry
    replied
    Thank you for helping but i think i will leave it as it is very complicated and i am fighting a losing battle i feel

    Looks great though and maybe one day it will be easier for a stupid idiot like me

    Leave a comment:


  • Rutger
    replied
    The JSON part is only necessary for the Attributes fields, so If you comment the JSOn files in the top of the script and the script lines between line 193 and 248 you should be able to run at least the script.

    Leave a comment:


  • Rutger
    replied
    In \Bin oke, but not in a subfolder like "Scripting". I don't know if this make sense. Even in settings.ini I don't have a full file path.

    Leave a comment:


  • deanrparry
    replied
    Originally posted by Rutger View Post
    I'm not sure. Did you added the dll files to the settings.ini file in the Config folder from Homeseer(and restarted Homeseer)?
    Something like this: ScriptingReferences=Newtonsoft.Json;Newtonsoft.Json.dll

    I've added the dll in the root of Homeseer, but with newer plugins the dll file should be placed in the Bin folder as written in the last few sentences of my blog post.
    yes mysql in root and newton in bin/scripting

    Newtonsoft.Json;C:\Program Files (x86)\HomeSeer HS3\Bin\Scripting\Newtonsoft.Json.dll

    Leave a comment:


  • Rutger
    replied
    I'm not sure. Did you added the dll files to the settings.ini file in the Config folder from Homeseer(and restarted Homeseer)?
    Something like this: ScriptingReferences=Newtonsoft.Json;Newtonsoft.Json.dll

    I've added the dll in the root of Homeseer, but with newer plugins the dll file should be placed in the Bin folder as written in the last few sentences of my blog post.

    Leave a comment:


  • deanrparry
    replied
    https://pastebin.com/ciG5AYqA

    If that means anything to you? still fighting with this stupid webinterface!

    Leave a comment:


  • Rutger
    replied
    A Windows reboot for changing the conf file is not necessary I guess, but the Traccar service has to be restarted, because it will load the new config file.

    The error will be probably related to the "Attributes" column from the Traccar "positions" table. Not every GPS track provide the same information.

    Leave a comment:


  • deanrparry
    replied
    I have tried that but not yet restarted machine so doing that as we speak... hopefully web interface will work again should do i thing!

    Next challenge is homeseer is chucking up loads of errors relating to the script so will see if it can read the data properly after this restart

    Getting closer lol

    Cannot believe i spent HOURS yesterday basing my assumption of failure purely on web interface not working i feel so STUPID!

    Leave a comment:


  • Rutger
    replied
    Perfect!!. I'm not sure, but I think web.enable is standard enabled. But you have the option to change the port ofcourse. Afterwards the Windows service has to be restarted.

    <entry key='web.enable'>true</entry>
    <entry key='web.port'>1234</entry>
    <entry key='web.path'>C:\Program Files (x86)\Traccar\web</entry>

    Leave a comment:


  • deanrparry
    replied
    It has been working after all! I checked the tables and database the web interface has broken since for Traccar but i am guessing i need to change the web.path to something else to make it work?

    Leave a comment:


  • deanrparry
    replied
    close but giving up tonight have a database think i have sorted privileges... newton in bin/scripting! wish i knew more about this drives me mad!

    Leave a comment:


  • Rutger
    replied
    the part of the "traccar.xml" file in the Traccar\Conf folder, is changed to:

    <entry key='database.driver'>com.mysql.jdbc.Driver</entry>
    <entry key='database.url'>jdbc:mysql://localhost:3306/traccar?allowMultiQueries=true&amp;autoReconnect=true&amp;us eUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=ANSI_QUOTES</entry>
    <entry key='database.user'>root</entry>
    <entry key='database.password'>xxxxxx</entry>


    - Where database.user: in my case "root" . A user which is created in the MySQL environment.
    - Where database.password: the password for above created user.
    - Because you have it running too on the same server, the database.url can be unchanged to "localhost"

    You should create the database "traccar" manually, and after the config file is changed, and the Traccar service is started, it should create all the tables automatically in the MySQL database.

    Leave a comment:


  • deanrparry
    replied
    Originally posted by Rutger View Post
    Maybe it's possible to get the data from SQL as well in Homeseer, but I never tried that.
    There are probably some examples over here on the board or on the internet to achieve this.

    I'm not using the default SQL DB from Traccar, but (as you can see in the Traccar documentation), MySQL is support too, but you need to have a MySQL environment for that ofcourse.
    In my case I do have such an environment, because I save/update also all my HS device values into MySQL, and store temperature changes, timesheets(based on gps), etc, so the change in Traccar from SQL to MySQL was almost mandatory for me. Based on MySQL it's easier from me to get the Traccar data into Homeseer.
    https://www.traccar.org/mysql/
    thank you kind sir i will research this as i did not know you could use mysql with it hence my confusion but you have cleared it up very quickly

    Leave a comment:


  • Rutger
    replied
    Maybe it's possible to get the data from SQL as well in Homeseer, but I never tried that.
    There are probably some examples over here on the board or on the internet to achieve this.

    I'm not using the default SQL DB from Traccar, but (as you can see in the Traccar documentation), MySQL is support too, but you need to have a MySQL environment for that ofcourse.
    In my case I do have such an environment, because I save/update also all my HS device values into MySQL, and store temperature changes, timesheets(based on gps), etc, so the change in Traccar from SQL to MySQL was almost mandatory for me. Based on MySQL it's easier from me to get the Traccar data into Homeseer.
    https://www.traccar.org/mysql/

    Leave a comment:

Working...
X