diff --git a/gallery/src/components/demo-card.js b/gallery/src/components/demo-card.js index 3c042dbc1d..186584908f 100644 --- a/gallery/src/components/demo-card.js +++ b/gallery/src/components/demo-card.js @@ -3,7 +3,9 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js'; import JsYaml from 'js-yaml'; import HomeAssistant from '../data/hass.js'; -import demoStates from '../data/demo_dump.js'; +import demoConfig from '../data/demo_config.js'; +import demoResources from '../data/demo_resources.js'; +import demoStates from '../data/demo_states.js'; import createCardElement from '../../../src/panels/lovelace/common/create-card-element.js'; class DemoCard extends PolymerElement { @@ -61,6 +63,9 @@ class DemoCard extends PolymerElement { } const hass = new HomeAssistant(); + hass.config = demoConfig; + hass.resources = demoResources; + hass.language = 'en'; hass.states = demoStates; const el = createCardElement(JsYaml.safeLoad(config.config)[0]); diff --git a/gallery/src/data/demo_config.js b/gallery/src/data/demo_config.js new file mode 100644 index 0000000000..7481664aac --- /dev/null +++ b/gallery/src/data/demo_config.js @@ -0,0 +1,175 @@ +export default { + core: { + elevation: 300, + latitude: 51.5287352, + longitude: -0.381773, + unit_system: { + length: 'km', + mass: 'kg', + temperature: '°C', + volume: 'L' + } + }, + services: { + configurator: [ + 'configure' + ], + tts: [ + 'demo_say', + 'clear_cache' + ], + cover: [ + 'open_cover', + 'close_cover', + 'open_cover_tilt', + 'close_cover_tilt', + 'set_cover_tilt_position', + 'set_cover_position', + 'stop_cover_tilt', + 'stop_cover' + ], + group: [ + 'set', + 'reload', + 'remove', + 'set_visibility' + ], + alarm_control_panel: [ + 'alarm_arm_night', + 'alarm_disarm', + 'alarm_trigger', + 'alarm_arm_home', + 'alarm_arm_away', + 'alarm_arm_custom_bypass' + ], + conversation: [ + 'process' + ], + notify: [ + 'demo_test_target_name', + 'notify' + ], + lock: [ + 'open', + 'lock', + 'unlock' + ], + input_select: [ + 'select_previous', + 'set_options', + 'select_next', + 'select_option' + ], + recorder: [ + 'purge' + ], + persistent_notification: [ + 'create', + 'dismiss' + ], + timer: [ + 'pause', + 'cancel', + 'finish', + 'start' + ], + input_boolean: [ + 'turn_off', + 'toggle', + 'turn_on' + ], + fan: [ + 'set_speed', + 'turn_on', + 'turn_off', + 'set_direction', + 'oscillate', + 'toggle' + ], + climate: [ + 'set_humidity', + 'set_operation_mode', + 'set_aux_heat', + 'turn_on', + 'set_hold_mode', + 'set_away_mode', + 'turn_off', + 'set_fan_mode', + 'set_temperature', + 'set_swing_mode' + ], + switch: [ + 'turn_off', + 'toggle', + 'turn_on' + ], + script: [ + 'turn_off', + 'demo', + 'reload', + 'toggle', + 'turn_on' + ], + scene: [ + 'turn_on' + ], + system_log: [ + 'clear', + 'write' + ], + camera: [ + 'disable_motion_detection', + 'enable_motion_detection', + 'snapshot' + ], + image_processing: [ + 'scan' + ], + media_player: [ + 'media_previous_track', + 'clear_playlist', + 'shuffle_set', + 'media_seek', + 'turn_on', + 'media_play_pause', + 'media_next_track', + 'media_pause', + 'volume_down', + 'volume_set', + 'media_stop', + 'toggle', + 'media_play', + 'play_media', + 'volume_mute', + 'turn_off', + 'select_sound_mode', + 'select_source', + 'volume_up' + ], + input_number: [ + 'set_value', + 'increment', + 'decrement' + ], + device_tracker: [ + 'see' + ], + homeassistant: [ + 'stop', + 'check_config', + 'reload_core_config', + 'turn_on', + 'turn_off', + 'restart', + 'toggle' + ], + light: [ + 'turn_off', + 'toggle', + 'turn_on' + ], + input_text: [ + 'set_value' + ] + } +}; diff --git a/gallery/src/data/demo_resources.js b/gallery/src/data/demo_resources.js new file mode 100644 index 0000000000..f1edb6fd4b --- /dev/null +++ b/gallery/src/data/demo_resources.js @@ -0,0 +1,253 @@ +export default { + en: { + 'state.default.off': 'Off', + 'state.default.on': 'On', + 'state.default.unknown': 'Unknown', + 'state.default.unavailable': 'Unavailable', + 'state.alarm_control_panel.armed': 'Armed', + 'state.alarm_control_panel.disarmed': 'Disarmed', + 'state.alarm_control_panel.armed_home': 'Armed home', + 'state.alarm_control_panel.armed_away': 'Armed away', + 'state.alarm_control_panel.armed_night': 'Armed night', + 'state.alarm_control_panel.armed_custom_bypass': 'Armed custom bypass', + 'state.alarm_control_panel.pending': 'Pending', + 'state.alarm_control_panel.arming': 'Arming', + 'state.alarm_control_panel.disarming': 'Disarming', + 'state.alarm_control_panel.triggered': 'Triggered', + 'state.automation.off': 'Off', + 'state.automation.on': 'On', + 'state.binary_sensor.default.off': 'Off', + 'state.binary_sensor.default.on': 'On', + 'state.binary_sensor.battery.off': 'Normal', + 'state.binary_sensor.battery.on': 'Low', + 'state.binary_sensor.cold.off': 'Normal', + 'state.binary_sensor.cold.on': 'Cold', + 'state.binary_sensor.connectivity.off': 'Disconnected', + 'state.binary_sensor.connectivity.on': 'Connected', + 'state.binary_sensor.door.off': 'Closed', + 'state.binary_sensor.door.on': 'Open', + 'state.binary_sensor.garage_door.off': 'Closed', + 'state.binary_sensor.garage_door.on': 'Open', + 'state.binary_sensor.gas.off': 'Clear', + 'state.binary_sensor.gas.on': 'Detected', + 'state.binary_sensor.heat.off': 'Normal', + 'state.binary_sensor.heat.on': 'Hot', + 'state.binary_sensor.lock.off': 'Locked', + 'state.binary_sensor.lock.on': 'Unlocked', + 'state.binary_sensor.moisture.off': 'Dry', + 'state.binary_sensor.moisture.on': 'Wet', + 'state.binary_sensor.motion.off': 'Clear', + 'state.binary_sensor.motion.on': 'Detected', + 'state.binary_sensor.occupancy.off': 'Clear', + 'state.binary_sensor.occupancy.on': 'Detected', + 'state.binary_sensor.opening.off': 'Closed', + 'state.binary_sensor.opening.on': 'Open', + 'state.binary_sensor.presence.off': 'Away', + 'state.binary_sensor.presence.on': 'Home', + 'state.binary_sensor.problem.off': 'OK', + 'state.binary_sensor.problem.on': 'Problem', + 'state.binary_sensor.safety.off': 'Safe', + 'state.binary_sensor.safety.on': 'Unsafe', + 'state.binary_sensor.smoke.off': 'Clear', + 'state.binary_sensor.smoke.on': 'Detected', + 'state.binary_sensor.sound.off': 'Clear', + 'state.binary_sensor.sound.on': 'Detected', + 'state.binary_sensor.vibration.off': 'Clear', + 'state.binary_sensor.vibration.on': 'Detected', + 'state.binary_sensor.window.off': 'Closed', + 'state.binary_sensor.window.on': 'Open', + 'state.calendar.off': 'Off', + 'state.calendar.on': 'On', + 'state.camera.recording': 'Recording', + 'state.camera.streaming': 'Streaming', + 'state.camera.idle': 'Idle', + 'state.climate.off': 'Off', + 'state.climate.on': 'On', + 'state.climate.heat': 'Heat', + 'state.climate.cool': 'Cool', + 'state.climate.idle': 'Idle', + 'state.climate.auto': 'Auto', + 'state.climate.dry': 'Dry', + 'state.climate.fan_only': 'Fan only', + 'state.climate.eco': 'Eco', + 'state.climate.electric': 'Electric', + 'state.climate.performance': 'Performance', + 'state.climate.high_demand': 'High demand', + 'state.climate.heat_pump': 'Heat pump', + 'state.climate.gas': 'Gas', + 'state.configurator.configure': 'Configure', + 'state.configurator.configured': 'Configured', + 'state.cover.open': 'Open', + 'state.cover.opening': 'Opening', + 'state.cover.closed': 'Closed', + 'state.cover.closing': 'Closing', + 'state.cover.stopped': 'Stopped', + 'state.device_tracker.home': 'Home', + 'state.device_tracker.not_home': 'Away', + 'state.fan.off': 'Off', + 'state.fan.on': 'On', + 'state.group.off': 'Off', + 'state.group.on': 'On', + 'state.group.home': 'Home', + 'state.group.not_home': 'Away', + 'state.group.open': 'Open', + 'state.group.opening': 'Opening', + 'state.group.closed': 'Closed', + 'state.group.closing': 'Closing', + 'state.group.stopped': 'Stopped', + 'state.group.locked': 'Locked', + 'state.group.unlocked': 'Unlocked', + 'state.group.ok': 'OK', + 'state.group.problem': 'Problem', + 'state.input_boolean.off': 'Off', + 'state.input_boolean.on': 'On', + 'state.light.off': 'Off', + 'state.light.on': 'On', + 'state.lock.locked': 'Locked', + 'state.lock.unlocked': 'Unlocked', + 'state.media_player.off': 'Off', + 'state.media_player.on': 'On', + 'state.media_player.playing': 'Playing', + 'state.media_player.paused': 'Paused', + 'state.media_player.idle': 'Idle', + 'state.media_player.standby': 'Standby', + 'state.plant.ok': 'OK', + 'state.plant.problem': 'Problem', + 'state.remote.off': 'Off', + 'state.remote.on': 'On', + 'state.scene.scening': 'Scening', + 'state.script.off': 'Off', + 'state.script.on': 'On', + 'state.sensor.off': 'Off', + 'state.sensor.on': 'On', + 'state.sun.above_horizon': 'Above horizon', + 'state.sun.below_horizon': 'Below horizon', + 'state.switch.off': 'Off', + 'state.switch.on': 'On', + 'state.weather.clear-night': 'Clear, night', + 'state.weather.cloudy': 'Cloudy', + 'state.weather.fog': 'Fog', + 'state.weather.hail': 'Hail', + 'state.weather.lightning': 'Lightning', + 'state.weather.lightning-rainy': 'Lightning, rainy', + 'state.weather.partlycloudy': 'Partly cloudy', + 'state.weather.pouring': 'Pouring', + 'state.weather.rainy': 'Rainy', + 'state.weather.snowy': 'Snowy', + 'state.weather.snowy-rainy': 'Snowy, rainy', + 'state.weather.sunny': 'Sunny', + 'state.weather.windy': 'Windy', + 'state.weather.windy-variant': 'Windy', + 'state.zwave.default.initializing': 'Initializing', + 'state.zwave.default.dead': 'Dead', + 'state.zwave.default.sleeping': 'Sleeping', + 'state.zwave.default.ready': 'Ready', + 'state.zwave.query_stage.initializing': 'Initializing ({query_stage})', + 'state.zwave.query_stage.dead': 'Dead ({query_stage})', + 'state_badge.default.unknown': 'Unk', + 'state_badge.default.unavailable': 'Unavai', + 'state_badge.alarm_control_panel.armed': 'Armed', + 'state_badge.alarm_control_panel.disarmed': 'Disarm', + 'state_badge.alarm_control_panel.armed_home': 'Armed', + 'state_badge.alarm_control_panel.armed_away': 'Armed', + 'state_badge.alarm_control_panel.armed_night': 'Armed', + 'state_badge.alarm_control_panel.armed_custom_bypass': 'Armed', + 'state_badge.alarm_control_panel.pending': 'Pend', + 'state_badge.alarm_control_panel.arming': 'Arming', + 'state_badge.alarm_control_panel.disarming': 'Disarm', + 'state_badge.alarm_control_panel.triggered': 'Trig', + 'state_badge.device_tracker.home': 'Home', + 'state_badge.device_tracker.not_home': 'Away', + 'ui.card.alarm_control_panel.code': 'Code', + 'ui.card.alarm_control_panel.clear_code': 'Clear', + 'ui.card.alarm_control_panel.disarm': 'Disarm', + 'ui.card.alarm_control_panel.arm_home': 'Arm home', + 'ui.card.alarm_control_panel.arm_away': 'Arm away', + 'ui.card.automation.last_triggered': 'Last triggered', + 'ui.card.automation.trigger': 'Trigger', + 'ui.card.camera.not_available': 'Image not available', + 'ui.card.climate.currently': 'Currently', + 'ui.card.climate.on_off': 'On / off', + 'ui.card.climate.target_temperature': 'Target temperature', + 'ui.card.climate.target_humidity': 'Target humidity', + 'ui.card.climate.operation': 'Operation', + 'ui.card.climate.fan_mode': 'Fan mode', + 'ui.card.climate.swing_mode': 'Swing mode', + 'ui.card.climate.away_mode': 'Away mode', + 'ui.card.climate.aux_heat': 'Aux heat', + 'ui.card.cover.position': 'Position', + 'ui.card.cover.tilt_position': 'Tilt position', + 'ui.card.fan.speed': 'Speed', + 'ui.card.fan.oscillate': 'Oscillate', + 'ui.card.fan.direction': 'Direction', + 'ui.card.light.brightness': 'Brightness', + 'ui.card.light.color_temperature': 'Color temperature', + 'ui.card.light.white_value': 'White value', + 'ui.card.light.effect': 'Effect', + 'ui.card.lock.code': 'Code', + 'ui.card.lock.lock': 'Lock', + 'ui.card.lock.unlock': 'Unlock', + 'ui.card.media_player.source': 'Source', + 'ui.card.media_player.sound_mode': 'Sound mode', + 'ui.card.media_player.text_to_speak': 'Text to speak', + 'ui.card.persistent_notification.dismiss': 'Dismiss', + 'ui.card.scene.activate': 'Activate', + 'ui.card.script.execute': 'Execute', + 'ui.card.weather.attributes.air_pressure': 'Air pressure', + 'ui.card.weather.attributes.humidity': 'Humidity', + 'ui.card.weather.attributes.temperature': 'Temperature', + 'ui.card.weather.attributes.visibility': 'Visibility', + 'ui.card.weather.attributes.wind_speed': 'Wind speed', + 'ui.card.weather.cardinal_direction.e': 'E', + 'ui.card.weather.cardinal_direction.ene': 'ENE', + 'ui.card.weather.cardinal_direction.ese': 'ESE', + 'ui.card.weather.cardinal_direction.n': 'N', + 'ui.card.weather.cardinal_direction.ne': 'NE', + 'ui.card.weather.cardinal_direction.nne': 'NNE', + 'ui.card.weather.cardinal_direction.nw': 'NW', + 'ui.card.weather.cardinal_direction.nnw': 'NNW', + 'ui.card.weather.cardinal_direction.s': 'S', + 'ui.card.weather.cardinal_direction.se': 'SE', + 'ui.card.weather.cardinal_direction.sse': 'SSE', + 'ui.card.weather.cardinal_direction.ssw': 'SSW', + 'ui.card.weather.cardinal_direction.sw': 'SW', + 'ui.card.weather.cardinal_direction.w': 'W', + 'ui.card.weather.cardinal_direction.wnw': 'WNW', + 'ui.card.weather.cardinal_direction.wsw': 'WSW', + 'ui.card.weather.forecast': 'Forecast', + 'ui.common.loading': 'Loading', + 'ui.common.cancel': 'Cancel', + 'ui.components.entity.entity-picker.entity': 'Entity', + 'ui.components.relative_time.past': '{time} ago', + 'ui.components.relative_time.future': 'In {time}', + 'ui.components.relative_time.never': 'Never', + 'ui.components.relative_time.duration.second': '{count} {count, plural,\n one {second}\n other {seconds}\n}', + 'ui.components.relative_time.duration.minute': '{count} {count, plural,\n one {minute}\n other {minutes}\n}', + 'ui.components.relative_time.duration.hour': '{count} {count, plural,\n one {hour}\n other {hours}\n}', + 'ui.components.relative_time.duration.day': '{count} {count, plural,\n one {day}\n other {days}\n}', + 'ui.components.relative_time.duration.week': '{count} {count, plural,\n one {week}\n other {weeks}\n}', + 'ui.components.history_charts.loading_history': 'Loading state history...', + 'ui.components.history_charts.no_history_found': 'No state history found.', + 'ui.components.service-picker.service': 'Service', + 'ui.dialogs.more_info_settings.save': 'Save', + 'ui.dialogs.more_info_settings.name': 'Name', + 'ui.duration.second': '{count} {count, plural,\n one {second}\n other {seconds}\n}', + 'ui.duration.minute': '{count} {count, plural,\n one {minute}\n other {minutes}\n}', + 'ui.duration.hour': '{count} {count, plural,\n one {hour}\n other {hours}\n}', + 'ui.duration.day': '{count} {count, plural,\n one {day}\n other {days}\n}', + 'ui.duration.week': '{count} {count, plural,\n one {week}\n other {weeks}\n}', + 'ui.login-form.password': 'Password', + 'ui.login-form.remember': 'Remember', + 'ui.login-form.log_in': 'Log in', + 'ui.notification_toast.entity_turned_on': 'Turned on {entity}.', + 'ui.notification_toast.entity_turned_off': 'Turned off {entity}.', + 'ui.notification_toast.service_called': 'Service {service} called.', + 'ui.notification_toast.service_call_failed': 'Failed to call service {service}.', + 'ui.notification_toast.connection_lost': 'Connection lost. Reconnecting…', + 'ui.sidebar.developer_tools': 'Developer tools', + 'ui.sidebar.log_out': 'Log out', + 'attribute.weather.humidity': 'Humidity', + 'attribute.weather.visibility': 'Visibility', + 'attribute.weather.wind_speed': 'Wind speed', + } +}; diff --git a/gallery/src/data/demo_dump.js b/gallery/src/data/demo_states.js similarity index 100% rename from gallery/src/data/demo_dump.js rename to gallery/src/data/demo_states.js diff --git a/gallery/src/data/media_player_images/media_player.bedroom.jpg b/gallery/src/data/media_player_images/media_player.bedroom.jpg new file mode 100644 index 0000000000..dcf861ea74 Binary files /dev/null and b/gallery/src/data/media_player_images/media_player.bedroom.jpg differ diff --git a/gallery/src/data/media_player_images/media_player.living_room.jpg b/gallery/src/data/media_player_images/media_player.living_room.jpg new file mode 100644 index 0000000000..9f1596ce48 Binary files /dev/null and b/gallery/src/data/media_player_images/media_player.living_room.jpg differ diff --git a/gallery/src/data/media_player_images/media_player.walkman.jpg b/gallery/src/data/media_player_images/media_player.walkman.jpg new file mode 100644 index 0000000000..76c759dd5b Binary files /dev/null and b/gallery/src/data/media_player_images/media_player.walkman.jpg differ diff --git a/gallery/webpack.config.js b/gallery/webpack.config.js index e069836500..91f782c155 100644 --- a/gallery/webpack.config.js +++ b/gallery/webpack.config.js @@ -49,9 +49,12 @@ module.exports = { plugins: [ new CopyWebpackPlugin([ 'public', - { from: '../node_modules/leaflet/dist/leaflet.css', to: `static/images/leaflet/` }, + { from: '../node_modules/leaflet/dist/leaflet.css', to: 'static/images/leaflet/' }, { from: '../node_modules/@polymer/font-roboto-local/fonts', to: 'static/fonts' }, - { from: '../node_modules/leaflet/dist/images', to: `static/images/leaflet/` }, + { from: '../node_modules/leaflet/dist/images', to: 'static/images/leaflet/' }, + { from: './src/data/media_player_images/media_player.bedroom.jpg', to: 'api/media_player_proxy/media_player.bedroom' }, + { from: './src/data/media_player_images/media_player.living_room.jpg', to: 'api/media_player_proxy/media_player.living_room' }, + { from: './src/data/media_player_images/media_player.walkman.jpg', to: 'api/media_player_proxy/media_player.walkman' }, ]), isProd && new UglifyJsPlugin({ extractComments: true,