There are two frames where the electric and magnetic fields and interactions are modeled, the classical one with Maxwell's equations describing the behavior of charged matter, and quantum mechanical ones where classical light equations can be shown to emerge from the superposition of photons(which are quantum entities)
In the classical frame, all accelerating charges radiate light. This carried out in the quantum frame says that all accelerating charged particles will emit photons. The energy for this is given by the force that induces the acceleration.
In addition, quantum mechanically, the transition of electrons to lower energy levels goes through the emission of photons , as you have stated, but not only electrons. In solids and liquids there are other energy levels involved that will allow in general charged particles moving in the electric fields of each other , to produce a plethora of photons from these accelerations, which may be just vibrations and rotations, i.e. changing energy levels in much more complicated solutions.
The temperature of the material follows from a radiation curve in most cases approximately fitted by a black body radiation curve, and this radiation is given off from the complex quantum mechanical interaction of the atoms and molecules involved.
So in lamp light, for example, there are both effects, the atomic and molecular spectrum transitions , and the tail of the black body radiation curve where a continuum of optical frequencies exist, and which dominates.