You can run this script in the Python Script Editor in QGIS and it will symbolise your layer with a colour ramp based on values in the storeys
field.
To automate it, it could be put inside a function and then connected to the lyr.layerModified
signal. It will refresh the symbology when a feature is added, even with a new value.
lyr_name = 'my layer' # the layer you want to symbolise
ramp_name = 'RdGy' # can be any of the named colour ramps in QGIS (making a custom ramp is also possible)
value_field = 'storeys' # the field holding the number of storeys
# get the layer
lyr = QgsProject.instance().mapLayersByName(lyr_name)[0]
# get the 'storeys' field index
idx = lyr.fields().indexFromName(value_field)
# build a colour ramp
default_style = QgsStyle().defaultStyle()
color_ramp = default_style.colorRamp(ramp_name)
color_ramp.invert() # with the RdGy colour ramp give low number of storeys grey and high number red
# instantiate a default symbol for the layer type
symbol = QgsSymbol.defaultSymbol(lyr.geometryType())
# empty list to store the categorised renderer categories
categories = []
# get a sorted list of unique values from the storeys field and iterate through them
for u in sorted(lyr.uniqueValues(idx)):
# make a render category for each value (category value, symbol, category label)
cat = QgsRendererCategory(u, symbol, str(u))
# append it to the list of categories
categories.append(cat)
# make a categorised renderer with the list of categories
renderer = QgsCategorizedSymbolRenderer(value_field, categories)
# apply the colour ramp to the renderer
renderer.updateColorRamp(color_ramp)
# apply the renderer to the layer
lyr.setRenderer(renderer)
# refresh the symbology
lyr.triggerRepaint()