Files
mushroom-strategy/src/cards/typedefs.js
Ferry Cools d5066303f3 Code Cleanup (#7)
Refactor the code base from Procedural to Object-Oriented Programming.

The new code base requires webpack (https://webpack.js.org/) to bundle the code into a single javascript file.
Webpack can be installed with npm, using file `package-lock.json` or `package.json`.

File `package.json` contains two script entries:

* `build` for a *release* build (uses file`webpack.config.js`).
* `build-dev` for a *debug* build (uses file `webpack.dev.config.js`).

Both of the scripts will bundle the separate package files into a single javascript file in the `dist` directory.

Includes fixes and changes:

* The release badge in readme now displays the latest release version.
* Optimize function `getStateEntities()`.
* Implement #11.
* Merge Home Assistant and User-defined areas.
* Add contributors to readme.
* Fix getCountTemplate method.  
  The method only counted states which aren't equal to value `off`.
  States are now counted by specifying a comparison operator and value.
* Document default HACS installation.
* Fix overriding sensor card configuration.  
  Having an `entity_config` property in the strategy options resulted in overriding each sensor card.
  Only the cards listed under this property should be overridden.
* Cut redundant properties and constants  
  Method `generateDashboard()` passes redundant values to generateView().
  Writing those values into properties and reading them into constants is removed.
* Fix undefined sensorState.  
  Not all entities (like a RESTful sensor) are bound to a device.
  SensorStates did contain states which meet all following conditions:
    1. The linked entity is linked to the given area or isn't linked to any area.
    2. The linked device is linked to the given area.

  SensorStates now contains states which meet any* of the following conditions:

    1. The linked entity is linked to the given area or isn't linked to any area.
    2. The entity is linked to a device, and the linked device is linked to the given area.
       *) Whichever comes first.
* Add undisclosed area.
* Add ordering of area-cards.  
  Area cards are now ordered by a custom set position first and then by the area name.
* Add global sorting of entities by original_name.
* Add global sorting of areas by order and name.
* Add global sorting of domains by order and title.
* Make production build.

Known Issue: Title cards or chips won't switch entities assigned to the undisclosed area.
2023-06-14 07:29:18 +02:00

138 lines
6.3 KiB
JavaScript

/**
* @namespace typedefs.cards
*/
/**
* @typedef {Object} abstractOptions
* @property {string} [type] The type of the card.
* @property {string} [icon] Icon of the card.
* @property {Object} [double_tap_action] Home assistant action to perform on double_tap.
*/
/**
* @typedef {Object} titleCardOptions Title Card options.
* @property {string} [title] Title to render. May contain templates.
* @property {string} [subtitle] Subtitle to render. May contain templates.
* @property {boolean} [showControls=true] False to hide controls.
* @property {string} [iconOn] Icon to show for switching entities from off state.
* @property {string} [iconOff] Icon to show for switching entities to off state.
* @property {string} [onService=none] Service to call for switching entities from off state.
* @property {string} [offService=none] Service to call for switching entities to off state.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} lightCardOptions Light Card options.
* @property {boolean} [show_brightness_control=true] Show a slider to control brightness
* @property {boolean} [show_color_control=true] Show a slider to control RGB color
* @property {boolean} [use_light_color=true] Colorize the icon and slider according light temperature or color
* @property {{double_tap_action: lightDoubleTapAction}} [action] Home assistant action to perform on double_tap
* @memberOf typedefs.cards
*/
/**
* @typedef {Object} lightDoubleTapAction Home assistant action to perform on double_tap.
* @property {{entity_id: string}} target The target entity id.
* @property {"call-service"} action Calls a hass service.
* @property {"light.turn_on"} service The hass service to call
* @property {{rgb_color: [255, 255, 255]}} data The data payload for the service.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} coverCardOptions Cover Card options.
* @property {boolean} [show_buttons_control=true] Show buttons to open, close and stop cover.
* @property {boolean} [show_position_control=true] Show a slider to control position of the cover.
* @property {boolean} [show_tilt_position_control=true] Show a slider to control tilt position of the cover.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} fanCardOptions Fan Card options.
* @property {boolean} [show_percentage_control=true] Show a slider to control speed.
* @property {boolean} [show_oscillate_control=true] Show a button to control oscillation.
* @property {boolean} [icon_animation=true] Animate the icon when fan is on.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} switchCardOptions Switch Card options.
* @property {{tap_action: switchTapAction}} [action] Home assistant action to perform on tap.
* @memberOf typedefs.cards
*/
/**
* @typedef {Object} switchTapAction Home assistant action to perform on tap.
* @property {"toggle"} action Toggles a hass entity.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} climateCardOptions Climate Card options.
* @property {["off", "cool", "heat", "fan_only"]} [hvac_modes] Show buttons to control target temperature.
* @property {boolean} [show_temperature_control=true] Show buttons to control target temperature.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions} cameraCardOptions Camera Card options.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} personCardOptions Person Card options.
* @property {string} [layout] Layout of the card. Vertical, horizontal, and default layouts are supported.
* @property {("name" | "state" | "last-changed" | "last-updated" | "none")} [primary_info=name] Info to show as
* primary info.
* @property {("name" | "state" | "last-changed" | "last-updated" | "none")} [secondary_info=sate] Info to show as
* secondary info.
* @property {("icon" | "entity-picture" | "none")} [icon_type]=icon Type of icon to display.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} areaCardOptions Area Card options.
* @property {string} [name] The name of the area
* @property {string} [icon] Icon to render. May contain templates.
* @property {string} [icon_color] Icon color to render. May contain templates.
* @property {string} [primary] Primary info to render. May contain templates.
* @property {areaTapAction} [tap_action] Home assistant action to perform on tap.
* @memberOf typedefs.cards
*/
/**
* @typedef {Object} areaTapAction Home assistant action to perform on tap.
* @property {"navigate"} action Toggles a hass entity.
* @property {string} navigation_path The id of the area to navigate to.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} mediaPlayerCardOptions Media Player Card options.
* @property {boolean} [use_media_info=true] Use media info instead of name, state, and icon when a media is playing
* @property {string[]} [media_controls="on_off", "play_pause_stop"] List of controls to display
* (on_off, shuffle, previous, play_pause_stop, next,
* repeat)
* @property {boolean} [show_volume_level=true] Show volume level next to media state when media is playing
* @property {string[]} [volume_controls="volume_mute", "volume_set", "volume_buttons"] List of controls to display
* (volume_mute, volume_set,
* volume_buttons)
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} sensorCardOptions Sensor Card options.
* @property {string} [icon_color=green] Custom color for icon when entity is state is active.
* @property {boolean} [animate=true] Add a reveal animation to the graph.
* @property {string} [line_color=green] Set a custom color for the graph line.
* Provide a list of colors for multiple graph entries.
* @memberOf typedefs.cards
*/
/**
* @typedef {abstractOptions & Object} miscellaneousCardOptions Miscellaneous Card options.
* @property {string} [icon_color=blue-grey] Custom color for icon when entity is state is active.
* @memberOf typedefs.cards
*/