I am controlling a smart light bulbs and publishing their status in UI dashboard, as a status I am getting a string data of "ON" and "OFF", but instead of this string data I want to get an integer data of 1 and 0, is there anyway I can convert this string data into integer data using JSON module in Python Dictionary.
Some of The API code of my smart Bulbs is here:
if (_deviceUrl.getcode() == 200):
data = _deviceUrl.read().decode("utf-8")
# Use the json module to load the string data into a dictionary
_theJSON = json.loads(data)
# 1. status
devicedata['on'] = self.on_dict[_theJSON["action"]['on']]
# 2. brightness convert to %
devicedata["bri"] = int(round(float(_theJSON["action"]["bri"]) * 100 / 255, 0))
int()function: i.e.int("123")->123.