mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Moon translate (#15498)
* Translate moon * Create strings.moon.json * Update moon.py * Update strings.moon.json * Update test_moon.py
This commit is contained in:
parent
98722e10fc
commit
058081b1f5
@ -50,20 +50,20 @@ class MoonSensor(Entity):
|
|||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
if self._state == 0:
|
if self._state == 0:
|
||||||
return 'New moon'
|
return 'new_moon'
|
||||||
elif self._state < 7:
|
elif self._state < 7:
|
||||||
return 'Waxing crescent'
|
return 'waxing_crescent'
|
||||||
elif self._state == 7:
|
elif self._state == 7:
|
||||||
return 'First quarter'
|
return 'first_quarter'
|
||||||
elif self._state < 14:
|
elif self._state < 14:
|
||||||
return 'Waxing gibbous'
|
return 'waxing_gibbous'
|
||||||
elif self._state == 14:
|
elif self._state == 14:
|
||||||
return 'Full moon'
|
return 'full_moon'
|
||||||
elif self._state < 21:
|
elif self._state < 21:
|
||||||
return 'Waning gibbous'
|
return 'waning_gibbous'
|
||||||
elif self._state == 21:
|
elif self._state == 21:
|
||||||
return 'Last quarter'
|
return 'last_quarter'
|
||||||
return 'Waning crescent'
|
return 'waning_crescent'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
12
homeassistant/components/sensor/strings.moon.json
Normal file
12
homeassistant/components/sensor/strings.moon.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
@ -37,7 +37,7 @@ class TestMoonSensor(unittest.TestCase):
|
|||||||
assert setup_component(self.hass, 'sensor', config)
|
assert setup_component(self.hass, 'sensor', config)
|
||||||
|
|
||||||
state = self.hass.states.get('sensor.moon_day1')
|
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',
|
@patch('homeassistant.components.sensor.moon.dt_util.utcnow',
|
||||||
return_value=DAY2)
|
return_value=DAY2)
|
||||||
@ -53,4 +53,4 @@ class TestMoonSensor(unittest.TestCase):
|
|||||||
assert setup_component(self.hass, 'sensor', config)
|
assert setup_component(self.hass, 'sensor', config)
|
||||||
|
|
||||||
state = self.hass.states.get('sensor.moon_day2')
|
state = self.hass.states.get('sensor.moon_day2')
|
||||||
self.assertEqual(state.state, 'Waning gibbous')
|
self.assertEqual(state.state, 'waning_gibbous')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user