Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Desmo

Member
  • Posts

    83
  • Joined

  • Last visited

About Desmo

Profile information

  • Country
    United Kingdom
  • Gateway/s
    Home Center 2

Recent Profile Visitors

169 profile views

Desmo's Achievements

Learner

Learner (2/8)

5

Reputation

  1. Glad I found this thread in a search, I've long been wishing for some new features in VD's...I believe they could really add lots to the system as we can create our own custom devices for all sorts of things. Just a few simple things like toggle switches for on/off, text input boxes and maybe different font sizes.
  2. I still couldn't get the "id" working but found that "id_s" has the same value and works fine so I'm all set up. Thanks for your help with this @jgab
  3. This is so strange....I'm absolutely sure that's what I had before but obviously not. I was on the right track but obviously had the syntax slightly wrong somewhere so thanks for tidying that up. Just one remaining problem now...the result is a little odd. The json result shows this... 34646001298457174 But it's turned in to this when I pull it out from the result... 3.4646001298457e+16
  4. OK, that works in the sample but how do I get the double [[ & ]] to each side of my response? Here is my code (with some details extracted) local http = net.HTTPClient(); http:request('https://xxxxxxxxxx/xxx/x/xxxxxxx', { options = { method = "GET", headers = { ["Content-Type"] = "application/json", ['Authorization'] = 'Bearer xxxxxxx' }, }, success = function(response) fibaro:debug(response.data) end, error = function(err) end }) It's the "response.data" I need to collect and add the double square brackets to. I had a quick go but nothing was working. Thanks again.
  5. Just edited post to include the entire string It's the first "id" in the string I need.
  6. So I'm trying to pull a pice of information from a json reply but I need to either use [0] or .. in the string, both of which will not work. I've tried escaping them with a "\" but they still fail. The line can either be response[0].id or response..id This is the entire string... {"response":[{"id":xxxxxxxx,"vehicle_id":xxxxxx,"vin":"xxxxxx","display_name":"xxxxxx","option_codes":"AF00,APF1,APH3,APPB,AU00,BCMB,BP00,BR00,BS00,BTX5,CDM0,CF00,CH04,CW00,DCF0,DRRH,DSH5,DU01,DV2W,FG02,FMP6,FR04,HP00,IDBA,INBPW,IX00,LLP2,LP01,MDLS,ME01,MI01,PF00,PI00,PK00,PPSB,PS01,PSPX4,PX00,QTPW,REEU,RFFG,S32W,SC05,SP01,SR07,ST01,SU01,TM00,TR00,UTSB,WTAS,WXW2,WXW3,X001,X003,X008,X011,X014,X021,X025,X027,X028,X031,X037,X039,X043,YFCC,COGB","color":null,"tokens":["ad3e1f2c1dde342f","1e1a96761a262dbb"],"state":"online","in_service":false,"id_s":"xxxxxxxxx","calendar_enabled":true,"api_version":6,"backseat_token":null,"backseat_token_updated_at":null}],"count":1} Any ideas?
  7. Hi all, I'm really struggling to implement something similar to this for another project. What I'd like to do collect a json result from a URL and store it in a home table. This is the result as returned... {"response":{"battery_heater_on":false,"battery_level":70,"battery_range":200.84,"charge_current_request":24,"charge_current_request_max":24,"charge_enable_request":false,"charge_energy_added":16.04,"charge_limit_soc":90,"charge_limit_soc_max":100,"charge_limit_soc_min":50,"charge_limit_soc_std":90,"charge_miles_added_ideal":51.5,"charge_miles_added_rated":64.5,"charge_port_cold_weather_mode":null,"charge_port_door_open":null,"charge_port_latch":"","charge_rate":0.0,"charge_to_max_range":false,"charger_actual_current":null,"charger_phases":null,"charger_pilot_current":null,"charger_power":null,"charger_voltage":null,"charging_state":"Disconnected","conn_charge_cable":"","est_battery_range":129.57,"fast_charger_brand":"","fast_charger_present":null,"fast_charger_type":"","ideal_battery_range":160.26,"managed_charging_active":false,"managed_charging_start_time":null,"managed_charging_user_canceled":false,"max_range_charge_counter":0,"not_enough_power_to_heat":null,"scheduled_charging_pending":false,"scheduled_charging_start_time":null,"time_to_full_charge":0.0,"timestamp":1555525686244,"trip_charging":null,"usable_battery_level":69,"user_charge_enable_request":null}} How can I put this in to a home table so I can call out any single part of the result at a later date? I've tried all sorts but I don't fully understand what I'm doing with json and the home table. This result/table would be updated multiple times a day.
  8. Thanks guys, that fixed it. Don't think I would have ever looked at doing it this way even after trying lots of different variations.
  9. I'm trying to combine some data from a json response along with some variables in a table. When I debug the result it just shows the combined text rather than the actual result. However when I debug the same text without combining them through the table they work perfectly fine. local result = '{"response":{"battery_heater_on":false,"battery_level":70,"battery_range":200.84,"charge_current_request":24,"charge_current_request_max":24,"charge_enable_request":false,"charge_energy_added":16.04,"charge_limit_soc":90,"charge_limit_soc_max":100,"charge_limit_soc_min":50,"charge_limit_soc_std":90,"charge_miles_added_ideal":51.5,"charge_miles_added_rated":64.5,"charge_port_cold_weather_mode":null,"charge_port_door_open":null,"charge_port_latch":"","charge_rate":0.0,"charge_to_max_range":false,"charger_actual_current":null,"charger_phases":null,"charger_pilot_current":null,"charger_power":null,"charger_voltage":null,"charging_state":"Disconnected","conn_charge_cable":"","est_battery_range":129.57,"fast_charger_brand":"","fast_charger_present":null,"fast_charger_type":"","ideal_battery_range":160.26,"managed_charging_active":false,"managed_charging_start_time":null,"managed_charging_user_canceled":false,"max_range_charge_counter":0,"not_enough_power_to_heat":null,"scheduled_charging_pending":false,"scheduled_charging_start_time":null,"time_to_full_charge":0.0,"timestamp":1555525686244,"trip_charging":null,"usable_battery_level":69,"user_charge_enable_request":null}}' local json = json.decode(result) fibaro:debug("JSON Original : "..json.response.battery_range) ***This shows the correct result from the json above, 200.84*** fibaro:debug("JSON Original : "..json.response.usable_battery_level) ***This shows the correct result from the json above, 69*** -- Add new variables and values to the list below. table = { [1] = "battery_range", [2] = "charge_limit_soc", [3] = "charging_state", [4] = "est_battery_range", [5] = "ideal_battery_range", [6] = "timestamp", [7] = "usable_battery_level", } local apiresult for k,v in ipairs(table) do fibaro:debug("Table : "..v) ***This shows the name from the table OK, eg. "battery_range"*** apiresult = "json.response."..v fibaro:debug("JSON Table : "..apiresult) ***This just shows the name and not the result. eg. "json.response.battery_range" instead of 200.84 from the json above.*** end Any ideas on why this doesn't work? Or if this isn't possible, another work around?
  10. My Tesla control VD is now here....
  11. My Tesla control VD is now here....
  12. Picking my car up in the morning so will be able to test in the week
  13. Hi tortho, Testing is going fine and I'm picking my car up at the end of the month so will do my final testing then but it shouldn't be too long now. I will create a new thread when it is ready and link to it here
  14. Hi Tortho, I know this is a REALLY old thread but I'm working on this at the moment. Taking delivery of my car in a few weeks so can do some final testing but I've got a VD and Scene setup with some basics and once tested and working I can add more commands.
  15. Got this all working now and result is split down to component parts
×
×
  • Create New...