I'm in the process of trying to implement JSON Patch as a way to cut the
chatter down between my various home automation systems. In particular,
since I've implemented a SignalR-all-the-things web interface I want to
push updates across to the browser as efficiently as possible. I also
want to make communication with mobile devices as efficient as possible.
To this end my home automation server now maintains a state for each
mobile device or browser session for all the objects that browser or
mobile connection is currently displaying. When things change it filters
the changes according to what's on the display and sends down the full
or partial objects accordingly. But now I plan to calculate a set of
JSON Patch differences and send them down as things change rather than
sending the whole object. This should dramatically reduce how much data
is being sent.
To that end I started writing an implementation of JSON Patch tonight.
The first part is concerned with calculating a patch as a difference of
two objects. Tomorrow night I'll implement the apply method that applies
a patch to an existing object.
Anyway, here's tonight's code in case anyone else wants to do this.
Digital Twin are an online representation of a real world object, a copy of its properties in the digital world and a way to send updated and commands to it. In effect I've been making them for years but now they have a trendy name.
Several years ago we did a major remodel. I did all of the finish electrical myself and supervised all of the rough-in electrical. I also put in all of the electrical system and water in our barn. I have opinions ...