Announcement

Collapse
No announcement yet.

Thinking cleaner HS3 plugin

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

  • bartbakels
    replied
    Thank you all,

    Problem solved, its was the wayvi decleared the dll in the ha3 settings.ini. See my thread in the main hs3 forum.

    Regards and thnx

    Leave a comment:


  • shill
    replied
    The first problem (the one responsible for the immediate error) is that you're passing "recv" to be decoded by the JSON parser, when your text is in "json".

    The next issue you'll have is that you're trying to parse it into a a generic Object, not a customized class, which won't have the properties you need to give a home to your data.

    Try this (written by hand, no guarantees I didn't screw up some syntax):

    Code:
    Imports Newtonsoft.Json
    Imports Newtonsoft.Json.Linq
    
    Class MyObject
    
    	Private _uptime As String
    	Private _version As String
    	Private _sendtime As String
    	Private _senddate As String
    	Private _hostname As String
    	
    	Public Property UpTime As String
    		Get
    			Return _uptime
    		End Get
    		Set (value As String)
    			_uptime = value
    		End Set
    	End Property
    
    	Public Property Version As String
    		Get
    			Return _version
    		End Get
    		Set (value As String)
    			_version = value
    		End Set
    	End Property
    	
    	Public Property SendTime As String
    			Get
    				Return _sendtime
    			End Get
    			Set (value As String)
    				_sendtime = value
    			End Set
    	End Property
    	
    	Public Property SendDate As String
    		Get
    			Return _senddate
    		End Get
    		Set (value As String)
    			_senddate = value
    		End Set
    	End Property
    	
    	Public Property HostName As String
    		Get
    			Return _hostname
    		End Get
    		Set (value As String)
    			_hostname = value
    		End Set
    	End Property
    	
    End Class
    
    Sub Main(params as object)
     
     'Enable Debug Messages Level
    '0=None
    '1=Info
    '2=All
     
    Dim Debug = 2
      
    '===================================================================== 
     
    'JSON
    Dim json As String 'this is the string of json data that needs decoding
    Dim version As String
    Dim obj As New MyObject
     Dim uptime
    Dim version
     
    '======================
    'Decode  status
    '======================
     
    json = '{"UPTIME": "UNKNOWN", "VERSION ": 2.0, "SENDTIME": "03:33:52",  "SENDDATE": "28- 12-2012", "HOSTNAME": "My-PC"}'
    Dim deserializedProduct As Object = JsonConvert.DeserializeObject(Of MyObject)(json)
    obj = JsonConvert.DeserializeObject(json)
    uptime = obj.UpTime
    version = obj.Version
     hs.WriteLog("Thinking cleaner Status", uptime)
    hs.WriteLog("Thinking cleaner Status", version)
      
    end sub 'End Main routine

    Leave a comment:


  • bartbakels
    replied
    Hi,

    I tried this;

    Code:
    Imports Newtonsoft.Json
    Imports Newtonsoft.Json.Linq
     Sub Main(params as object)
     
     'Enable Debug Messages Level
    '0=None
    '1=Info
    '2=All
     
    Dim Debug = 2
      
    '===================================================================== 
     
    'JSON
    Dim json As String 'this is the string of json data that needs decoding
    Dim version As String
    Dim obj As New JObject
     Dim uptime
    Dim version
     
    '======================
    'Decode  status
    '======================
     
    json = '{"UPTIME": "UNKNOWN", "VERSION ": 2.0, "SENDTIME": "03:33:52",  "SENDDATE": "28- 12-2012", "HOSTNAME": "My-PC"}'
    Dim deserializedProduct As Object = JsonConvert.DeserializeObject(Of Object)(json)
    obj = JsonConvert.DeserializeObject(recv)
    uptime = obj.Item("UPTIME").ToString
    version = obj.Item("VERSION").ToString
     hs.WriteLog("Thinking cleaner Status", uptime)
    hs.WriteLog("Thinking cleaner Status", version)
      
    end sub 'End Main routine

    Which still generates these errors;

    Code:
        jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: 'recv' is not declared. It may be inaccessible due to its protection level.    jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: 'JsonConvert' is not declared. It may be inaccessible due to its protection level.    jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: 'JsonConvert' is not declared. It may be inaccessible due to its protection level.    jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: Expression expected.    jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: Local variable 'version' is already declared in the current block.    jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: Type 'JObject' is not defined.    jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: Namespace or type specified in the Imports 'Newtonsoft.Json.Linq' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.    jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: Namespace or type specified in the Imports 'Newtonsoft.Json' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.    jan-15 9:16:05  Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Jsontest.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

    I the newtonsoft.json.dll is in the HS3 bin directory and in the HS3 root, I also added it to the config.ini of HS3. Can someone point me in the right direction? Thanks.



    regards Bart

    Leave a comment:


  • shill
    replied
    I use the Newtonsoft JSON library in my honeywell wifi thermostat plugin, and it's pretty simple. I have a class ("ThermostatDataRaw") defined that has properties for every item in the JSON object structure, then simply take the JSON string ("strJsonData") you get back and do:

    objMyThermDataRaw = Newtonsoft.Json.JsonConvert.DeserializeObject(Of ThermostatDataRaw)(strJsonData)

    then your object will be populated.

    Leave a comment:


  • bartbakels
    replied
    Hi,


    Mine cam ein yesterday and works great with my roomba 500 series

    I am already working on a script to monitor and control, however still have an issue with parsing JSON via scripts. and i dont want to use textfunctions. I am trying the newtonsoft json library, Does someone have a simple example how the paring of json code works in a vb script using this library. I am still getting errors.


    Bart

    Leave a comment:


  • S-F
    replied
    That thing is pricy! I can't imagine the cost of shipping to the U.S.

    Leave a comment:


  • Rien du Pre
    replied
    Originally posted by bartbakels View Post
    Hi,

    I just Bought the Wifi add on from Thinking Cleaner for the Roomba 500 series. This enables me to start and stop my Roomba and send basic commands and readout the status. It even enables me to schedule cleaning on roombas that do not have a scheduler option.



    I was wondering of somebody already uses this solution and is planning to integrate it into HS3 as plugin? It has already plugins for other homeautomation systems. There is an open API available, I think JSON commands;

    http://www.google.nl/url?sa=t&rct=j&...83339334,d.d2s


    Just wondering

    Bart
    Hi Bart,

    I will order a Roomba (630 with Wifi) tomorrow and create a HS3 plug-in.

    Leave a comment:


  • Malosa
    replied
    you already can ,


    http://www.thinkingcleaner.com/setup/api/

    here is the api , it must be easy to make a plugin

    Leave a comment:


  • w.vuyk
    replied
    Bart,

    Looks nice! I have Roomba still on the wishlist. Looking at it it would not be too hard to make it work. Sadly I cannot test it personally, which counts me out for this one. Once I have the Roomba myself I most certainly would look into this.

    Wim

    Leave a comment:


  • bartbakels
    started a topic Thinking cleaner HS3 plugin

    Thinking cleaner HS3 plugin

    Hi,

    I just Bought the Wifi add on from Thinking Cleaner for the Roomba 500 series. This enables me to start and stop my Roomba and send basic commands and readout the status. It even enables me to schedule cleaning on roombas that do not have a scheduler option.



    I was wondering of somebody already uses this solution and is planning to integrate it into HS3 as plugin? It has already plugins for other homeautomation systems. There is an open API available, I think JSON commands;

    http://www.google.nl/url?sa=t&rct=j&...83339334,d.d2s


    Just wondering

    Bart
Working...
X