Q:

On conflict, update if json value is different in PostgreSQL? 

I would like to update the 'info' column in the "raw_data" table, if it differs from existing. 
Where "info" is JSON datatype. 
For example, if the "info" data exist, DO NOTHING, otherwise UPDATE. 
Code and attempts:
If I use the following code:
cursor = connection.cursor()

postgres_insert_query = 
"""
INSERT INTO raw_data (Timestamp, IMIE, info) VALUES (%s,%s,%s)
ON CONFLICT (Timestamp)
DO UPDATE SET
info = EXCLUDED.info 
WHERE raw_data.info IS DISTINCT FROM EXCLUDED.info;"""

record_to_insert = (int(timestamp), int(imei), json_file)
cursor.execute(postgres_insert_query, record_to_insert)
connection.commit()

Error:
Then I would receive the following error:

psycopg2.errors. InFailedSqlTransaction: current transaction is
  aborted, commands ignored until end of transaction block

Sample/Pseudo code:
DO NOTHING Case:
If Current "info" = {someData: 'ON'} 
Existing "info" = {someData: 'ON'} 
Then Do Nothing

UPDATING Case:
If Current "info" = {someData: 'OFFFFFFFFFFF'} 
Existing "info" = {someData: 'ON'} 

UPDATE the "info"

A:

You can't compare JSON values with = or <> (which is what is distinct from uses in the background).  If you want to compare the complete JSON value you have to change the data type of that column to jsonb, e.g. the following works just fine.  
Using this sample table:
create table raw_data ("timestamp" timestamp primary key, imie text, info jsonb);

You can then run this:
INSERT INTO raw_data ("timestamp", imie, info) 
VALUES (timestamp '2019-07-22 00:00:00', '1234', '{"x": 1, "someData": "on"}')
ON CONFLICT ("timestamp")
DO UPDATE 
  SET info = EXCLUDED.info 
WHERE raw_data.info IS DISTINCT FROM EXCLUDED.info;

Online example: https://rextester.com/IOYXB82745
But it looks like you don't actually want to compare the complete JSON value, but only one key.  Then you can do the following, which also works with json:
INSERT INTO raw_data ("timestamp", imie, info) 
VALUES (timestamp '2019-07-22 00:00:00', '1234', '{"x": 1, "someData": "on"}')
ON CONFLICT ("timestamp")
DO UPDATE 
  SET info = EXCLUDED.info 
WHERE raw_data.info ->> 'someData' IS DISTINCT FROM EXCLUDED.info ->> 'someData';

Online example: https://rextester.com/VML98935

