Live Data
Points take their text, colour and even their position from Home Assistant, and rules change points and objects as entities change. None of it rebuilds the scene: a label or a colour changes in place, a point moves on the next frame.
A point's entity
entity on a point is that point's own entity: its label templates read it, its colour maps follow its state, and its actions act on it. Use it for a point that stands for a device: a light, a switch, a phone.
- Label templates read it as
entity({entity.state},{entity.attributes.friendly_name}). - Colour state maps on the point and its text fields follow its state, with the card's
state_classification. more-infoandtoggleactions without anentityact on it, and a position can come from its attributes.
type: custom:lcards-astrometrics-card
height: 280
camera:
views:
top:
target: [0, 0, 0]
tilt: 70
distance: 120
points:
- id: lamp
entity: switch.demo_switch
xyz: [-20, 0, 0]
marker: square
style: major
# follows the switch: tap to toggle it
color:
active: var(--lcars-orange)
inactive: var(--lcars-blue)
text:
label:
content: "{entity.attributes.friendly_name}"
state:
content: "{entity.state}"
position: bottom-right
font_size: 11
tap_action:
action: toggle
objects:
- type: grid
shape: plane
size: 100
line_spacing: 10| Key | Type | Default | Description |
|---|---|---|---|
entity | string | - | The point's entity: templates read it, state colour maps follow it, more-info and toggle act on it, positions can come from it |
color | colour / state map | by style | The point's colour, a state map by this entity: see Markers |
Positions from entities
xyz, polar, latlon and altaz take numbers, or entity to read them from an entity's attributes: a phone on a globe, the sun on a sky dome. The point moves when they change, and paths, rings and beams that use it follow.
- The entity defaults to the point's own
entity. - Each form reads attributes by default names:
latitudeandlongitude(a person, a device tracker, a zone),azimuthandelevation(sun.sun),x,yandz, ordistanceandbearing. Change them with the form's own keys;stateas a name reads the entity's state. - A point is hidden while one of its numbers is missing or not a number.
type: custom:lcards-astrometrics-card
height: 320
camera:
views:
v:
target: [0, 10, 0]
yaw: 160
tilt: 20
distance: 190
points:
# the sun from sun.sun's azimuth and elevation, on the dome
- id: sun
altaz:
entity: sun.sun
object: sky
marker: dot
color: var(--lcars-yellow)
label: SOL
# home from zone.home's latitude and longitude, on the globe
- id: home
latlon:
entity: zone.home
object: earth
marker: reticle
label: HOME
objects:
- type: grid
id: sky
shape: dome
radius: 80
line_spacing_deg: 15
- type: sphere
id: earth
at: [0, 20, 0]
radius: 15
image: builtin:earth_blue_marbleMore about positions from entities
- A probe from a sensor's attributes: a point with
entity: sensor.probe_trackandpolar: { attributes: [range, heading] }reads its distance from the sensor'srangeattribute and its bearing fromheading.
| Key | Type | Default | Description |
|---|---|---|---|
latlon.entity | string | the point's entity | The entity to read: a person, a device tracker, a zone |
latlon.latitude | string | latitude | The attribute holding the latitude |
latlon.longitude | string | longitude | The attribute holding the longitude |
altaz.entity | string | the point's entity | The entity to read, such as sun.sun |
altaz.azimuth | string | azimuth | The attribute holding the azimuth |
altaz.altitude | string | elevation | The attribute holding the altitude |
xyz.entity | string | the point's entity | The entity to read |
xyz.attributes | list | [x, y, z] | The three attributes holding x, y and z |
polar.entity | string | the point's entity | The entity to read |
polar.attributes | list | [distance, bearing] | The two attributes holding the distance and the bearing |
Templates
Label content takes the four template types as on every card: {entity.state} tokens, [[[ JavaScript ]]], {{ Jinja2 }} (evaluated by Home Assistant) and {ds:name} data sources. Besides entity, states, config, variables and theme, label templates can read the sun and moon (sky) and the point's own config (point).
- A template is evaluated again only when something it reads changes: its entities, a data source, or the sky.
- The sky values update every minute, and work in all four types:
{sky.moon.illumination},[[[ return Math.round(sky.sun.altitude) ]]],{{ sky.moon.illumination }}. - The angles have one decimal; for whole degrees, round in JavaScript:
[[[ return 'SOL ' + Math.round(sky.sun.altitude) + '°' ]]].
type: custom:lcards-astrometrics-card
height: 300
camera:
views:
sky:
target: [0, 20, 0]
yaw: 180
tilt: 20
distance: 190
points:
- id: sun
sky: sun
object: dome
marker: dot
label: "SOL {sky.sun.altitude}°"
color: var(--lcars-yellow)
- id: moon
sky: moon
object: dome
marker: moon_phase
label: "LUNA {sky.moon.illumination}%"
objects:
- type: grid
id: dome
shape: dome
radius: 80
line_spacing_deg: 15More about templates
- JavaScript templates may read any state, so they run again on every change the card tracks.
- Template off:
template: falseon a field shows itscontentas written.
| Name | Type | What it is |
|---|---|---|
sky.sun.azimuth | number | The sun now, degrees to one decimal (from sun.sun when it exists) |
sky.sun.altitude | number | The sun's height above the horizon, degrees to one decimal |
sky.moon.azimuth | number | The moon now, degrees to one decimal (computed from the time and your location) |
sky.moon.altitude | number | The moon's height above the horizon, degrees to one decimal |
sky.moon.illumination | number | How much of the moon is lit, whole percent |
sky.moon.waxing | boolean | true while it grows |
point | object | The point's own config ({point.id}) |
Settings from entities
Any number on a point or object can follow an entity instead of holding still: a shield bubble's opacity follows the shields, a glow's size follows the power. Write the key as entity with an input range and an output range, the same words as map_range in animations and the rules' map_range_cond.
- A light's brightness:
attribute: brightness_pctgives 0 to 100 % (0 while it is off), as in the other cards;brightnessis 0 to 255. - A light, a switch or a player followed by its state (no
attribute) reads as the high end ofinputwhile it is active (on, playing, home) and the low end while it is not, so it opens or closes a setting fully; followbrightnessfor the steps in between, or give each state its own value (Settings by state). - A value outside
inputstays at the end ofoutput, unlessclamp: false. No value (unavailable, not a number, a light's brightness while it is off) givesdefault, else the key's own default. - Templates work too:
spin: "[[[ return states['input_number.lcards_test_power'].state / 10 ]]]", or{{ }}and{entity.state}. - An object's
opacity,radius,sizeandspinease to their new value without rebuilding anything; most other keys rebuild that one object or point, at most four times a second, and step.
type: custom:lcards-astrometrics-card
height: 300
camera:
views:
v:
target: [0, 0, 0]
yaw: 20
tilt: 20
distance: 160
objects:
- type: sphere
id: shields
at: [-35, 0, 0]
radius: 30
fill:
color: var(--lcars-blue)
# shields 0 to 100 % gives an opacity of 0 to 0.6
opacity:
entity: input_number.lcards_test_shields
output: [0, 0.6]
- type: glow
id: core
at: [40, 0, 0]
color: var(--lcars-orange)
# power 0 to 100 % gives a glow 10 to 60 across, easing over 1 s;
# 10 while the helper is unavailable
size:
entity: input_number.lcards_test_power
input: [0, 100]
output: [10, 60]
default: 10
smooth: 1000More about settings from entities
- What else changes in place: some types take more keys of their own that ease without a rebuild: a belt's
radius(each side too),thicknessandcount(the band widens or thins round the same rocks); a comet'snucleus.size,coma.size,tail.lengthandglow; a nebula'sdrift(each side too: the clouds speed up or slow down from where they are) anddensity; a crystalline entity'sglowandopacity. A colour of any object crossfades to its new value (see Colours from entities). Any other key (a deformation'samplitude, a galaxy'sarms.count, a point'salt) rebuilds that one object or point. - A bound belt
countbuilds for the top of itsoutputand draws fewer, so keepoutputno higher than you need. - Pairs: a setting that takes
[a, b](a belt's[inner, outer]radius and[smallest, largest]rock size, a grid's or image's[w, d]size, a ring's ellipse, a nebula's drift) can have either side follow an entity of its own:radius: [{ entity: input_number.lcards_test_shields, output: [40, 70] }, 90]. A wholeradiusbound to one entity gives one number (for a belt, the outer edge with the inner at 0.8 of it) and scales in place; a bound side rebuilds the object, except a belt's radius and a nebula's drift, which ease. In the Astrometrics Studio each box of a pair has its own link button. - Whole numbers: how-many settings (a belt's
count, a galaxy'sarms.countandstars.count, a nebula'scount, a lightning object'sbranches, a wobble'slobes, a polar grid'sspoke_count,num_octaves,major.row_intervalandmajor.col_interval) take the mapped value rounded, socount: { entity: input_number.lcards_test_power, output: [100, 500] }gives 233 rocks at 33.3 %, and the object rebuilds only when the whole number changes. - Not bound: lists of three (
[x, y, z],rotation) do not follow entities, and aseedtakes only a plain number (a new pattern would rebuild the object). - On the card:
time_scale,warp_factor,clock.rateandclock.datefollow entities the same way (clock: { date: { entity: input_datetime.lcards_test_date } }shows the planets on the date in a helper). Positions follow entities their own way: see Positions from entities.
| Key | Type | Default | Description |
|---|---|---|---|
entity | string | required | The entity to follow |
attribute | string | - | Read this attribute instead of the state. brightness_pct reads a light's brightness as 0 to 100 % (0 while off; brightness itself is 0 to 255). Without one (and without state keys), an active entity (on, playing, home) reads as the high end of input and an inactive one as the low end |
input | [low, high] | the entity's min and max, else [0, 100] | The range of the entity's value. min and max are an input_number's attributes |
output | [low, high] | - | The range of the setting the input maps to. Left out: the entity's number as it is |
clamp | boolean | true | false: a value outside input carries on past the ends of output |
default | number | the key's own default | The setting's value when no state key matches and the entity has no number: unavailable, or a light that is off (it has no brightness) |
smooth | number | 600 | How long a change eases, ms, for a key that changes in place. 0 steps |
Settings by state
A number can take a value per state instead of a range: a glow wide while a player is playing, a shield bubble clear while the doors are open. The keys are the state colour words, each with a number: active, inactive, unavailable, zero, non_zero, ranges (above:80, below:20, between:20:80) and any state of the entity (playing, home, heat).
- The first key that matches wins, in the order the state colours use: the exact state (or the
attribute's value),zero, a range (above,at_least,below,at_most,between,between_exclusive; the narrowest wins),non_zero, thenactive,inactiveorunavailable. - No key matching, a number is still mapped by
inputandoutputwhen the binding has them; elsedefaultapplies. - The value eases like any other:
smoothworks the same way.
type: custom:lcards-astrometrics-card
height: 300
camera:
views:
v:
target: [0, 0, 0]
yaw: 20
tilt: 20
distance: 160
objects:
- type: sphere
id: bubble
at: [-35, 0, 0]
radius: 30
fill:
color: var(--lcars-blue)
# the toggle on: a clear bubble; off: a solid one
opacity:
entity: input_boolean.lcards_test_toggle
active: 0.15
inactive: 0.6
- type: glow
id: beacon
at: [40, 0, 0]
color: var(--lcars-orange)
# a size per mode, 5 for any other state
size:
entity: input_select.lcards_test_mode
alpha: 15
beta: 35
gamma: 60
default: 5
smooth: 800More about settings by state
- Active and inactive follow the card's state classification, the same as the state colours: on, open, playing, home, heat and the other running states are active, anything else is inactive, and unavailable or unknown is
unavailable. A card'sstate_classificationchanges them. - With an attribute, exact keys and ranges match the attribute's value (
attribute: brightnesswithbelow:50: 1). - In the Astrometrics Studio, the panel of a number that follows an entity switches between Range (entity low and high, the setting's values there) and By state: the state list the other cards use for state colours, with a number per state (quick-add Default, Active, Inactive, Unavailable, Zero and Non zero, type any state of the entity, or add a range condition). Switching drops the other way's keys. A colour that follows an entity uses the same list with a colour per state. For a light the attribute list offers
brightness_pct. - Misspelt words read as states: the checker warns about a key close to one of the binding words (
smoth: 800). onandoffas keys need quotes ("on": 1): Home Assistant's YAML editor reads them bare as true and false.activeandinactivecover them without quotes, and more states besides.
| Key | Type | Default | Description |
|---|---|---|---|
active | number | - | The value while the entity is active (on, playing, home, open) |
inactive | number | - | The value while the entity is inactive (off, idle, not_home, closed) |
unavailable | number | - | The value while the entity is unavailable or unknown |
zero | number | - | The value when the entity's value is the number 0 |
non_zero | number | - | The value when the entity's value is any other number |
above:N, at_least:N, below:N, at_most:N, between:A:B, between_exclusive:A:B | number | - | The value when the entity's value is in that range |
<state> | number | - | The value in that state (playing, home, heat) |
default | number | the key's own default | The value when nothing else gives one |
Colours from entities
Any colour on an object can follow an entity or a template too: its color, a part's color (such as edges.color or core.color), each colour in a colors list, and the colours of a fill.effect. Write it as a state map with the entity it reads, using the same state words as the other cards.
- With no key matching, a value that is itself a colour is used, so
color: { entity: light.desk, attribute: rgb_color }follows a light's colour. - A colour change crossfades that object to the new colour in place over a moment, with no rebuild: its motion carries on.
- A point's colour already follows the point's own entity: see A point's entity.
type: custom:lcards-astrometrics-card
height: 320
camera:
views:
v:
target: [0, 0, 0]
yaw: 20
tilt: 35
distance: 220
objects:
- type: grid
id: deck
shape: plane
size: 120
# the lines turn orange while the toggle is on
color:
entity: input_boolean.lcards_test_toggle
active: var(--lcars-orange)
inactive: var(--lcars-gray)
# the frame turns red above 80 % power
edges:
color:
entity: input_number.lcards_test_power
"above:80": var(--lcars-red)
default: var(--lcars-blue)
- type: nebula
id: cloud
at: [0, 25, 0]
radius: 50
# two clouds placed by hand take the colours in order:
# the first stays blue, the second follows the mode
clouds:
- xyz: [-28, 0, 0]
radius: 24
- xyz: [28, 0, 0]
radius: 24
colors:
- var(--lcars-blue)
- entity: input_select.lcards_test_mode
alpha: var(--lcars-violet)
beta: var(--lcars-orange)
default: var(--lcars-red)More about colours from entities
- Templates:
color: "[[[ return states['input_boolean.lcards_test_toggle'].state === 'on' ? 'var(--lcars-red)' : 'var(--lcars-blue)' ]]]", or{{ }}. The result is a colour ([r, g, b]works too). - Nothing matching, and no
default: the colour the key has when it is left out. - How often: a colour change crossfades at most four times a second; under reduced motion it changes at once. A model, whose look comes from its file, is built again instead.
| Key | Type | Default | Description |
|---|---|---|---|
entity | string | required | The entity to follow |
attribute | string | - | Match this attribute's value instead of the state |
<state> | colour | - | The colour for that exact state or attribute value (heat, alpha) |
active | colour | - | The colour while the entity is on, with the card's state_classification |
inactive | colour | - | The colour while the entity is off |
unavailable | colour | - | The colour while the entity is unavailable or unknown |
zero | colour | - | The colour when the value is the number 0 |
non_zero | colour | - | The colour when the value is any other number |
above:N | colour | - | The colour when the value is above N |
below:N | colour | - | The colour when the value is below N |
between:A:B | colour | - | The colour when the value is between A and B |
default | colour | - | The colour when nothing else matches |
A guided tour
camera.view can follow an entity: the camera flies to views[n] when the entity's value is n (counting from 0), or to the view an input_select's option names. Step the number from an automation, a script or buttons (input_number.increment), and the card flies from stop to stop.
- A number is rounded and held to the list, so a value past the last stop stays on the last.
- A stop can set the scene clock too:
view, withdateandrate. - Leave
viewsout when the entity's state is the view's name.
type: custom:lcards-astrometrics-card
height: 320
camera:
view:
entity: input_number.lcards_test_stage
views:
- wide
- planet
- moon
views:
wide:
target: [0, 0, 0]
yaw: 20
tilt: 35
distance: 170
planet:
target: planet
yaw: 40
tilt: 20
distance: 60
moon:
target: moon
yaw: 200
tilt: 15
distance: 25
points:
# each tap sets the stage, and the camera follows it
- id: home
xyz: [-50, 0, 0]
marker: diamond
label: STAGE 0 (TAP)
tap_action:
action: perform-action
perform_action: input_number.set_value
target:
entity_id: input_number.lcards_test_stage
data:
value: 0
- id: planet
xyz: [20, 0, 0]
label: STAGE 1 (TAP)
tap_action:
action: perform-action
perform_action: input_number.set_value
target:
entity_id: input_number.lcards_test_stage
data:
value: 1
- id: moon
xyz: [45, 4, 10]
label: STAGE 2 (TAP)
tap_action:
action: perform-action
perform_action: input_number.set_value
target:
entity_id: input_number.lcards_test_stage
data:
value: 2
objects:
- type: sphere
at: planet
radius: 12
fill:
effect:
preset: gas_giant
- type: sphere
at: moon
radius: 3
color: var(--lcars-gray)
- type: grid
shape: disc
radius: 70
pattern: polar
line_spacing: 10
spoke_count: 12
opacity: 0.4| Key | Type | Default | Description |
|---|---|---|---|
camera.view.entity | string | required | The entity whose value picks the view |
camera.view.attribute | string | - | Read this attribute instead of the state |
camera.view.views | list | - | The stops in order: a view name, or view with date and rate |
camera.view.views[].view | string | required | The named view to fly to |
camera.view.views[].date | string | - | Set the scene date there: now or an ISO date |
camera.view.views[].rate | number / string | - | Set the date's rate there: live, days per second, or with a unit (1 h/s, 30 d/s, 1 y/s) |
Rules
Points and objects with an id are rule targets, as MSD overlays are: a rule's apply.overlays patches them with their own keys. Use it to recolour, relabel, hide or move points and objects while an entity is in some state.
- When the rule stops matching, the point or object goes back to its config.
- A patched point label is rebuilt on its own; the rest of the scene stays. An object whose patch changes only colours crossfades in place, and other keys build that object again, nothing else.
- Ids are page-wide: two cards with a point
solboth match a rule onsol. Use distinct ids, or tags, when a dashboard has several astrometrics or MSD cards.
type: custom:lcards-astrometrics-card
height: 300
camera:
views:
top:
target: [0, 0, 0]
tilt: 70
distance: 130
labels:
styles:
hostile:
font_size: 16
font_weight: bold
color: var(--lcars-alert-red)
points:
# tap to toggle the alert
- id: alert_switch
xyz: [-35, 0, 25]
marker: square
label: RED ALERT (TAP)
tap_action:
action: toggle
entity: input_boolean.lcards_test_toggle
- id: warbird
xyz: [20, 0, -10]
marker: triangle
label: CONTACT
- id: escort
xyz: [-10, 0, -20]
marker: dot
tags:
- patrol
label: ESCORT
objects:
- type: ring
id: neutral_zone
radius: 45
color: var(--lcars-blue)
rules:
- id: red_alert_contacts
when:
entity: input_boolean.lcards_test_toggle
state: "on"
apply:
overlays:
# a point
warbird:
style: hostile
label: HOSTILE CONTACT
# every point or object tagged patrol
"tag:patrol":
color: var(--lcars-alert-red)
# an object
neutral_zone:
visible: falseMore about rules
- Selectors: an id,
tag:<name>(points and objects taketags),type:astrometrics-pointortype:astrometrics-object,pattern:<regex>,all. - Point keys a rule can patch:
label,text,style,color,marker,priority,overlap,visible,opacity, the distance keys (fade,min_distance,max_distance),tap_action,cardand the placement forms (a rule can move a point). - Object keys: any of their keys.
visibleand the distance keys change it without a rebuild. - MSD-style patches:
style: { color: var(--lcars-red) }patches the colour. A plain stringstyleis the label style.
| Key | Type | Default | Description |
|---|---|---|---|
rules | list | - | The card's rules |
apply.overlays | object | - | Patches by selector: a point or object id, tag:<name>, type:astrometrics-point, type:astrometrics-object, pattern:<regex> or all |
tags | list | - | On a point or object: names for tag:<name> selectors |
Fly-to from other cards and automations
Give the astrometrics card an id, then any LCARdS card can fly its camera with a fly-to action naming it in card, with a view or a point. From an automation, the lcards.fly_to action does the same on every open dashboard (or only the devices and users you target).
- The camera of every open card with that id flies, in the same browser.
- The two examples below work together: the button flies the camera of the card above it.
# the card to fly: its id is galaxy
type: custom:lcards-astrometrics-card
id: galaxy
height: 280
camera:
views:
wide:
target: [0, 0, 0]
yaw: 20
tilt: 40
distance: 170
backdrop:
stars:
count: 2000
points:
- id: earth
polar: [45, 120]
marker: dot
label: EARTH
objects:
- type: grid
shape: disc
radius: 70
pattern: polar
line_spacing: 10
spoke_count: 12type: custom:lcards-button
preset: lozenge
text:
name:
content: EARTH
show: true
style:
card:
color:
background:
default: var(--lcars-orange)
tap_action:
action: fly-to
card: galaxy # the astrometrics card's id
point: earth # or view: <a camera view>
duration: 2500 # optional, ms
warp: true # optional: streak the stars on the way (false: never)More about flying from outside
- Browser console:
window.lcards.cards.astrometricshasgetAll(),get(id)andflyTo(id, view or { point }, { duration, warp }). - The scene date:
set-clocktakescardthe same way: see Scene actions.
| Key | Type | Default | Description |
|---|---|---|---|
id | string | - | On the astrometrics card: the name other cards and automations use |
card | string | required | On the action: the astrometrics card's id |
point | string | - | A point id to fly to. Wins over view |
view | string | - | A named view (camera.views) to fly to |
duration | number | camera.fly_duration | How long the flight takes, ms |
warp | boolean | the view's warp, else camera.warp | true streaks the stars on the way, false never |