Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions homeassistant/components/sensor/moon.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ def name(self):
def state(self):
"""Return the state of the device."""
if self._state == 0:
return 'New moon'
return 'new moon'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although we can use whitespaces in translation file keys, I'm not sure if we want this wild mix of " ", "_". "-" for states

elif self._state < 7:
return 'Waxing crescent'
return 'waxing crescent'
elif self._state == 7:
return 'First quarter'
return 'first quarter'
elif self._state < 14:
return 'Waxing gibbous'
return 'waxing gibbous'
elif self._state == 14:
return 'Full moon'
return 'full moon'
elif self._state < 21:
return 'Waning gibbous'
return 'waning gibbous'
elif self._state == 21:
return 'Last quarter'
return 'Waning crescent'
return 'last quarter'
return 'waning crescent'

@property
def icon(self):
Expand Down
12 changes: 12 additions & 0 deletions homeassistant/components/sensor/strings.moon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"state": {
"new moon": "New moon",
"waxing crescent": "Waxing crescent",
"first quarter": "First quarter",
"waxing gibbous": "Waxing gibbous",
"full moon": "Full moon",
"waning gibbous": "Waning gibbous",
"last quarter": "Last quarter",
"waning crescent": "Waning crescent"
}
}