Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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'
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"
}
}
4 changes: 2 additions & 2 deletions tests/components/sensor/test_moon.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_moon_day1(self, mock_request):
assert setup_component(self.hass, 'sensor', config)

state = self.hass.states.get('sensor.moon_day1')
self.assertEqual(state.state, 'Waxing crescent')
self.assertEqual(state.state, 'waxing_crescent')

@patch('homeassistant.components.sensor.moon.dt_util.utcnow',
return_value=DAY2)
Expand All @@ -53,4 +53,4 @@ def test_moon_day2(self, mock_request):
assert setup_component(self.hass, 'sensor', config)

state = self.hass.states.get('sensor.moon_day2')
self.assertEqual(state.state, 'Waning gibbous')
self.assertEqual(state.state, 'waning_gibbous')