וַיֵּ֗לֶךְ וַֽיַּעֲבֹד֙ אֱלֹהִ֣ים אֲחֵרִ֔ים וַיִּשְׁתַּ֖חוּ לָהֶ֑ם וְלַשֶּׁ֣מֶשׁ ׀ א֣וֹ לַיָּרֵ֗חַ א֛וֹ לְכָל־צְבָ֥א הַשָּׁמַ֖יִם אֲשֶׁ֥ר לֹא־צִוִּֽיתִי׃
qui soit allé servir d’autres divinités et se prosterner devant elles, ou devant le soleil ou la lune, ou quoi que ce soit de la milice céleste, contrairement à ma loi:
Rashi
אשר לא צויתי [AND HATH GONE AND SERVED OTHER GODS … EITHER THE SUN, OR MOON, OR ANY OF THE HOST OF HEAVEN] WHICH I HAVE NOT COMMANDED to worship them (Megillah 9b).
Ibn Ezra
The grammatical properties of the word worshiped are discussed in my book Sefer Hayyǝsod. other gods denotes man-made idols, as opposed to
Sforno
אלוהים אחרים, independent ones, having no relation to Hashem whatsoever, but disembodied beings. ולשמש או לירח, which are physical bodies;