Author Topic: Modification of user_data.json  (Read 245 times)

Offline Catman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Modification of user_data.json
« on: April 21, 2017, 06:46:55 am »
Hi all

Hope this is an appropriate forum. Specifically I am trying to get my Foscam FR4020A2 working on my Vera Plus

They have been working fine on my old Vera Lite which I trued to upgrade to a Vera Plus following the online instructions.  Big mistake.
 
Anyway, having unpaired all the Z-wave devices, reset the Plus and set everything up from scratch, I have a far more reliable system than the old Lite.

The next thing is these Foscams.  They worked fine on the Lite with PTZ and presets, but the wizard to add them now fails.  Vera support talked me through a URL to modify so I have images, but try as I might, I can't get the rest of the functions up and running.  If I fire up the Lite, and use that interface, they work just fine :)

So, being a bit geeky I dug around and eventually found all the devices and scenes hidden away in the /etc/cmh/user_data.json.lzo on the Lite. Copied, unpacked and compared to the version on the Plus I can see there are significant differences.

So to me the simplest thing would be to modify the Plus version to match the Lite version (obvious exceptions like device number, UUID and so on) excluded. This I have done. Recompressed it back into lzo, copied into /etc/cmh on the plus (made a backup first, obviously).  On reboot, though the new version of the files has been overwritten with one matching the file before I modified it. This comes from I know not where.

So I guess either
a) The file I'm modifying is some kind of backup (I can actually see my modified one as user_data.json.lzo.2
b) It's being overwritten on boot with one from some kind of archive.
c) Something else.

Suggestions? Please?

C

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9369
  • Karma: +704/-129
    • RTS Services Plugins
Re: Modification of user_data.json
« Reply #1 on: April 21, 2017, 08:54:17 am »
You need to stop the LuaUPnP process before you edit the file.
It is constantly writing to that file (every 6 minutes) as well as it writes to it when it shuts down.
That way when it restarts ... it has the latest state info.

Offline Catman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Re: Modification of user_data.json
« Reply #2 on: April 21, 2017, 09:19:25 am »
Awesome, thanks.

<dumb question>

How do I gracefully stop LuaUPnP? I can just kill /usr/bin/LuaUPnP from its PID, but that sounds like a not great idea? I can't obviously see an init script to start or stop.

Thanks again!

C

Offline Catman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Re: Modification of user_data.json
« Reply #3 on: April 21, 2017, 10:51:57 am »
Right I am now very confused!

I tracked down /usr/bin/Stop_cmh script which is called in shutdown and ran that to stop LuaUPnP  Seemed to work fine

Copied the new data file into place and rebooted only to lose site of Vera from the portal page. Tracked that down to an un-related USB failure killing Network.log

Anyway started again. Copied the file, rebooted, everything comes up green, but the camera is still the wrong name.

I deliberately changed the name in the data file to make the change easy to track. I've copied and extracted the current version of /etc/cmh/user_data.json.lzo and sure enough:

{ "id": 30, "name": "Kitchen_Modified? ....

but in the UI

device: #30 name: Kitchen Camera

I'm going to delete the camera then recopy the lzo file I think

Any other thoughts, anyone?

C

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9369
  • Karma: +704/-129
    • RTS Services Plugins
Re: Modification of user_data.json
« Reply #4 on: April 21, 2017, 11:39:30 am »
Editing these files is tricky ... if you make any syntax errors it will ignore it and look for the next newest file.

Offline Catman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Re: Modification of user_data.json
« Reply #5 on: April 21, 2017, 11:57:51 am »
Right, that makes sense. Thanks.

Given this is copy / paste the syntax seems unlikely, but it had crossed my mind.  I guess the other thing is converting to text so I could edit in a tex editor (Specifically Mac TexEdit)? Not a good idea?

C