twrecked/hass-virtual
Über uns
Virtual devices, mock hardware, and physics simulation engines (HVAC, Solar, Energy Dashboard) for Home Assistant.
Wissenschaft und TechnikGemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +2
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
OriginalVirtual Devices for Home Assistant
Virtual is a custom integration for Home Assistant that provides in-memory virtual entities and devices for testing, development, and complex automation prototyping.
![]()
Virtual provides support for 18 distinct entity platforms:
- Alarm Control Panels: Virtual security panels with arming/trigger delays and PIN codes.
- Binary Sensors: Motion, presence, door, window, smoke, and moisture sensors.
- Buttons: Stateless push-buttons to trigger automations and actions.
- Cameras: Security and CCTV cameras with snapshot images, fallback test cards, and live HLS stream playback.
- Climate: Virtual thermostats and HVAC units with target setpoints, presets, and dynamic heating/cooling action calculation.
- Covers: Timed position-based blinds, garage doors, shutters, and shades.
- Device Trackers: GPS coordinates and named location zones.
- Fans: Multi-speed, oscillating, and reversible fans.
- Lights: Dimmable, RGB color (HS), color temperature, and animated effects.
- Locks: Lockable doors with optional locking duration and jamming tests.
- Media Players: Virtual TVs, speakers, and receivers for silent TTS announcement and automation testing.
- Numbers: Configurable sliders and numeric inputs with custom ranges and units.
- Selects: Dropdown selectors for modes, states, and presets.
- Sensors: Environmental (temperature, humidity, pressure), power, energy, and battery monitors.
- Sirens: Manual alarm sirens and automatic timed warning chimes with duration auto-off and tone selection.
- Switches: Simple on/off switches and power outlets.
- Texts: Configurable text input fields with string length and regex pattern constraints.
- Valves: Timed water and gas valves with position reporting.
⚠️ Virtual
v0.10.0-betaNoticeVirtual v0.10 modernizes the integration with native Home Assistant entity models, an interactive web-based Visual Device Editor, and non-blocking asynchronous state storage.
This is an active beta release — community testing and feedback are welcome!
If you encounter issues, regressions, or unexpected behavior, please open a GitHub issue.
Legacy
0.9.xdocumentation is archived in docs/README_v9.md, and0.8.xdocumentation is in version-0.8.x.
Table Of Contents
- Introduction
- What's New in v0.10
- Installing the Integration
- Adding the Integration
- Visual Device Editor
- Entity Configuration & File Layout
- Physics Simulation Engines
- Legacy YAML Configuration
- Services
Introduction
Virtual devices act like real physical devices in Home Assistant, allowing you to test automations, simulate presence and sensor triggers, mock complex devices, and verify dashboard setups without physical hardware.
All entity states are maintained in-memory and can persist cleanly across Home Assistant restarts.
What's New in v0.10
- Visual Device Editor:
- A dedicated web application for building and managing your virtual devices and entities visually.
- Hosted in the cloud at https://virtual-dot-twrecked-tools.nn.r.appspot.com or runnable locally on your home network.
- Options Flow & Webhook Sync:
- Clicking Configure on any Virtual group in Home Assistant launches the visual editor preloaded with your YAML.
- Clicking Save & Return in the editor writes your changes to disk and reloads the integration automatically via an authenticated webhook.
- Major Platform Expansion (18 Supported Platforms):
- Added native support for
alarm_control_panel,button,camera,climate,media_player,number,select,siren,text, andvalveentities with standard Home Assistant device classes, units, and services.
- Added native support for
- Strict Home Assistant & Python Modernization:
- Entities now directly inherit from core entity classes (
NumberEntity,SensorEntity), eliminating threadpool worker overhead. - State persistence and storage use Home Assistant's managed non-blocking
Storehelper and async executor, eliminating the externalaiofilesdependency. - Full modern typing (
from __future__ import annotations), unified global device-class units, and hardened state restoration against null or invalid values across restarts.
- Entities now directly inherit from core entity classes (
Installing the Integration
HACS (Recommended)
Virtual is available in the default HACS store. Search for "Virtual Components" under Integrations and download the latest release.
Manual Installation
Copy the custom_components/virtual directory into your Home Assistant /config/custom_components/ directory and restart Home Assistant.
Adding the Integration
- In Home Assistant, navigate to Settings -> Devices & Services.
- Click Add Integration and search for Virtual Components.
- Enter a Group Name (e.g.
Main Virtual Devices) and the path to your YAML file (defaults to/config/virtual.yaml). - Click Submit. If the file does not exist, an initial file will be created automatically.
You can add multiple integration entries to separate different groups of devices into different files (e.g., lighting.yaml, sensors.yaml).
Visual Device Editor
The Virtual Device Editor provides a visual tree interface for adding, configuring, and organizing devices and child entities without editing YAML by hand.
Hosted version: https://virtual-dot-twrecked-tools.nn.r.appspot.com
┌────────────────────────────────────────────────────────────────────────┐
│ Virtual Device Editor [Templates] [Save & Return] │
├────────────────────────────────────────────────────────────────────────┤
│ ▼ Living Room Motion 2 entities [Delete]│
│ ├── [BINARY_SENSOR] Motion Detector (class: motion, initial: off) │
│ └── [SENSOR] Battery Level (class: battery, unit: %) │
│ │
│ ▶ Ceiling Fan 1 entity [Delete]│
└────────────────────────────────────────────────────────────────────────┘
1. One-Click Sync via Home Assistant (Recommended)
- In Home Assistant, go to Settings -> Devices & Services -> Virtual.
- Click Configure on any virtual group.
- Click the Open Virtual Device Editor link to open your devices in the editor.
- Make your changes visually (add devices, apply templates, tweak attributes).
- Click Save & Return in the editor. The editor POSTs your updated configuration to Home Assistant, updates your file on disk, and automatically reloads the integration.
- Click Submit in Home Assistant to close the options dialog.
2. Manual Copy-Paste / Offline Fallback (No Webhooks Needed)
If your Home Assistant instance is not accessible from the browser or you prefer not to use webhooks:
- Open the editor: https://virtual-dot-twrecked-tools.nn.r.appspot.com.
- Click Import YAML and paste your current
virtual.yamlcontent (or start fresh with templates). - Edit your devices visually with real-time schema validation.
- Click Copy in the top bar to copy the generated YAML to your clipboard (or click Download to save
virtual.yaml). - Open your
/config/virtual.yamlfile in Home Assistant (using File Editor, Studio Code Server, Samba, or SSH) and paste the updated content. - In Home Assistant, go to Settings -> Devices & Services -> Virtual, click the three dots, and select Reload.
3. Running the Editor Locally on Your LAN
If you want the convenience of one-click sync without any cloud traffic:
- Start the editor locally on your machine or home server:
The editor starts atcd virtual-device-editor pip install -r requirements.txt python main.pyhttp://localhost:8080(and on your local network IP). - In Home Assistant, click Configure on your Virtual group.
- Change Editor URL to your local address (e.g.
http://127.0.0.1:8080orhttp://192.168.1.X:8080) and click Submit. - Click the link to open your local editor with one-click local webhook sync.
4. Device Templates & Collapsible Cards
- Collapsible Cards: Click the chevron next to any device title to collapse or expand it. Use the Collapse All / Expand All button in the top bar when working with large device lists.
- Quick-Add Templates:
- Motion Sensor (
binary_sensormotion +sensorbattery) - Contact Sensor (
binary_sensordoor +sensorbattery) - Dimmable Light & RGB Color Light
- Ceiling Fan (multi-speed, direction, oscillation)
- Window Blind (timed position cover)
- Water Valve (timed position valve)
- Power Outlet (
switch+ power & energy sensors) - Weather Station (temperature, humidity, atmospheric pressure)
- Motion Sensor (
Entity Configuration & File Layout
File Structure & ADR-0007 Entity Naming
A standard virtual.yaml file defines devices, each containing one or more entity platforms. hass-virtual adheres to Home Assistant's modern entity naming architecture (_attr_has_entity_name = True, ADR-0007):
- Single-Entity Devices (Primary Entity): Omit
nameentirely. The entity automatically inherits the device's name without repetition or stuttering. - Multi-Entity Devices (Sub-Entities): Specify concise names for secondary entities (e.g.,
Battery,Motion,Temperature). Home Assistant automatically formats the display name as<Device Name> <Entity Name>(e.g.Front Door Lock Battery), and sets the entity ID to{domain}.{device_slug}_{entity_slug}. - Backward Compatibility: If legacy configurations still supply
name: "Front Door Lock Battery",hass-virtualcleanly strips the redundant device name prefix to prevent double-prefixing.
Examples
version: 1
devices:
# 1. Clean Single-Entity Device (name omitted -> friendly name: "Living Room Dimmer")
Living Room Dimmer:
- platform: light
initial_value: "off"
support_brightness: true
# 2. Multi-Entity Device (Primary lock entity + concise sub-entities)
Front Door Lock:
- platform: lock
initial_value: "locked"
locking_time: 2
- platform: sensor
name: Battery
class: battery
unit_of_measurement: "%"
initial_value: "100"
- platform: binary_sensor
name: Low Battery
class: battery
linked_battery_sensor: "Battery"
low_battery_threshold: 15
- Device Groupings: Entities listed under a device name share the same parent device in Home Assistant's Device Registry.
Common Attributes
All entity types support the following common configuration options:
| Attribute | Type | Default | Description |
|---|---|---|---|
name |
string | Optional | Friendly name for the entity. |
initial_value |
any | Platform default | Value assigned on first creation or if state is not restored. |
persistent |
boolean | true |
When true, the entity state is saved across Home Assistant restarts. |
initial_availability |
boolean | true |
When false, the entity starts in an unavailable state. |
Alarm Control Panels
Simulates virtual alarm systems with customizable PIN codes and exit/entry delays.
House Alarm:
- platform: alarm_control_panel
initial_value: disarmed
code: "1234"
code_arm_required: false
arming_time: 10
trigger_time: 10
code: Optional PIN code (e.g."1234"). When defined, entering the code is required to disarm.code_arm_required: Defaultfalse. Iftrue, entering the code is also required to arm.arming_time: Optional exit delay in seconds (transitions througharmingbefore becoming armed).trigger_time: Optional entry delay in seconds (transitions throughpendingbefore becomingtriggered).- Controllable via native
alarm_control_panel.alarm_arm_home,alarm_control_panel.alarm_arm_away,alarm_control_panel.alarm_arm_night,alarm_control_panel.alarm_arm_vacation,alarm_control_panel.alarm_disarm, andalarm_control_panel.alarm_triggerservices.
Climate
Simulates virtual thermostats and HVAC units. Automatically computes hvac_action (heating, cooling, idle, off) dynamically based on ambient room temperature vs. target temperature setpoints.
Living Room Thermostat:
- platform: climate
initial_value: heat
initial_temperature: 21
initial_current_temperature: 19.5
min_temp: 10
max_temp: 32
target_temperature_step: 0.5
hvac_modes:
- off
- heat
- cool
- auto
preset_modes:
- none
- eco
- comfort
- away
initial_value: Initial HVAC mode (off,heat,cool,auto).initial_temperature: Target temperature setpoint.initial_current_temperature: Initial ambient room temperature.min_temp/max_temp: Bounds for temperature adjustment.target_temperature_step: Temperature step increment (default0.5).- Controllable via native
climate.set_temperature,climate.set_hvac_mode,climate.set_preset_mode, andclimate.set_fan_modeservices. - Simulate ambient room temperature changes using the custom
virtual.set_current_temperatureservice.
Physics Simulation Engines (simulations/)
Complex multi-device physics simulations live cleanly in the dedicated simulations/ package, leaving Home Assistant entity platforms lightweight and standard. Simulations are declared in a top-level simulations: block in YAML.
1. Solar Inverter & Energy Hub (type: solar_inverter)
Simulates hybrid solar inverters (such as Sol-Ark, Deye, Sunsynk, SolarEdge, Tesla Powerwall, or Enphase) bridged into Home Assistant via Solar Assistant or MQTT. The engine runs a brand-agnostic physics loop that continuously balances solar generation, house loads, battery storage, and the electricity grid:
$$\text{House Load} = \text{Solar (PV)} + \text{Battery Power} + \text{Grid Power}$$
version: 1
simulations:
- type: solar_inverter
name: "Sol-Ark Energy Manager"
battery_strategy: "backup" # "backup" (holds battery at 100% float for outages) or "self_consumption" (daily cycle)
peak_solar_power: 11000 # 11 kW peak at noon
base_load: 250 # Inverter self-consumption + standby draw (W)
battery_capacity: 15.0 # 15 kWh pack
battery_min_soc: 20 # 20% minimum discharge reserve
battery_max_power: 5000 # 5 kW max charge/discharge rate
sim_speed: 1.0 # Simulation acceleration multiplier
# Linked Sensors in this file:
pv_power_sensor: "Sol-Ark PV Power"
pv_energy_sensor: "Sol-Ark PV Energy"
load_power_sensor: "Sol-Ark Load Power"
load_energy_sensor: "Sol-Ark Load Energy"
base_load_power_sensor: "Sol-Ark Base Load Power"
base_load_energy_sensor: "Sol-Ark Base Load Energy"
grid_power_sensor: "Sol-Ark Grid Power"
grid_energy_in_sensor: "Sol-Ark Grid Energy In"
grid_energy_out_sensor: "Sol-Ark Grid Energy Out"
battery_power_sensor: "Sol-Ark Battery Power"
battery_soc_sensor: "Sol-Ark Battery SoC"
battery_voltage_sensor: "Sol-Ark Battery Voltage"
battery_energy_in_sensor: "Sol-Ark Battery Energy In"
battery_energy_out_sensor: "Sol-Ark Battery Energy Out"
# External appliances in your house to sum into the load:
linked_loads:
- "Television"
- "Amplifier"
- "Chest Freezer"
- "Washing Machine"
- "Tumble Dryer"
- "Water Heater Power"
- "Main HVAC Power"
devices:
Sol-Ark Inverter:
- platform: sensor
name: Sol-Ark Grid Voltage
class: voltage
unit_of_measurement: "V"
initial_value: "240.0"
- platform: sensor
name: Sol-Ark Grid Power
class: power
unit_of_measurement: "W"
- platform: sensor
name: Sol-Ark Grid Energy In
class: energy
unit_of_measurement: "kWh"
initial_value: "100.0"
- platform: sensor
name: Sol-Ark Grid Energy Out
class: energy
unit_of_measurement: "kWh"
initial_value: "50.0"
- platform: sensor
name: Sol-Ark Load Power
class: power
unit_of_measurement: "W"
initial_value: "250"
- platform: sensor
name: Sol-Ark Load Energy
class: energy
unit_of_measurement: "kWh"
initial_value: "250.0"
- platform: sensor
name: Sol-Ark Base Load Power
class: power
unit_of_measurement: "W"
initial_value: "250"
- platform: sensor
name: Sol-Ark Base Load Energy
class: energy
unit_of_measurement: "kWh"
initial_value: "0.0"
Sol-Ark Solar Array:
- platform: sensor
name: Sol-Ark PV Power
class: power
unit_of_measurement: "W"
- platform: sensor
name: Sol-Ark PV Energy
class: energy
unit_of_measurement: "kWh"
initial_value: "300.0"
Sol-Ark Battery Storage:
- platform: sensor
name: Sol-Ark Battery SoC
class: battery
unit_of_measurement: "%"
initial_value: "85"
- platform: sensor
name: Sol-Ark Battery Power
class: power
unit_of_measurement: "W"
- platform: sensor
name: Sol-Ark Battery Voltage
class: voltage
unit_of_measurement: "V"
initial_value: "52.4"
- platform: sensor
name: Sol-Ark Battery Energy In
class: energy
unit_of_measurement: "kWh"
initial_value: "0.0"
- platform: sensor
name: Sol-Ark Battery Energy Out
class: energy
unit_of_measurement: "kWh"
initial_value: "0.0"
- Solar Generation: Smooth diurnal bell curve from sunrise (~06:00) to sunset (~19:30), peaking at
peak_solar_power(11 kW) at noon. - Dynamic House Load: Automatically aggregates
base_load(250 W) + all active linked appliance power sensors. - Battery Operating Strategies (
battery_strategy):backup(Default): Battery is treated as an emergency backup generator / UPS. While the grid is online, solar powers the house, tops up the battery, and exports excess; the battery sits preserved at 100% float charge and does not cycle daily. Nighttime deficits pull from the grid. When a blackout occurs (grid voltage drops to 0 V), the battery instantly takes over and powers the home.self_consumption: Standard daily cycling. Battery discharges every evening to minimize grid imports, common in regions with high peak-time electricity rates.
- Self-Consumption & Grid Export:
- Surplus solar powers the house, charges the battery, and exports any remaining excess to the grid.
- When solar is insufficient (night / overcast), battery discharges down to
battery_min_soc(20%), after which power seamlessly imports from the grid.
- Energy Dashboard Ready: Cumulative
kWhenergy sensors automatically accumulate over time to populate Home Assistant's native Energy Dashboard and Power Flow cards. - Controllable via
virtual.set_battery_socandvirtual.set_solar_power.
2. Thermal HVAC & House Simulation (type: thermal_hvac)
Simulates physical house insulation, outdoor weather leakage, and multi-stage heating/cooling with support for both electric heat pumps and natural gas / propane furnaces:
version: 1
simulations:
- type: thermal_hvac
name: "Main House Thermal Engine"
heating_type: "electric" # "electric" (heat pump / furnace) or "gas" (gas furnace / boiler)
climate_entity: "Main House Thermostat"
indoor_sensor: "Main Indoor Temp"
outdoor_sensor: "Main Outdoor Temp"
power_sensor: "Main HVAC Power" # Electric heat pump draw or gas furnace blower power
# gas_sensor: "Main Furnace Gas Flow" # For heating_type: gas (m³/hr)
# gas_energy_sensor: "Main Furnace Gas" # For heating_type: gas (cumulative m³ for Energy Tab)
sim_speed: 1.0 # Acceleration multiplier (e.g. 10.0 for 10x fast forward)
house_leakage_rate: 0.3 # Passive insulation loss (°C/hr per 10°C delta)
heat_rate_stage1: 1.5 # °C / hour
heat_rate_stage2: 3.0
cool_rate_stage1: 1.5
cool_rate_stage2: 3.0
fan_cool_rate: 0.2
heat_power_stage1: 1800.0 # Watts
heat_power_stage2: 3800.0
cool_power_stage1: 1400.0
cool_power_stage2: 2800.0
fan_power: 120.0
standby_power: 10.0
devices:
Main House HVAC:
- platform: climate
name: Main House Thermostat
initial_value: "heat"
initial_temperature: 21.0
initial_current_temperature: 20.0
- platform: sensor
name: Main Indoor Temp
class: temperature
unit_of_measurement: "°C"
initial_value: "20.0"
- platform: sensor
name: Main Outdoor Temp
class: temperature
unit_of_measurement: "°C"
initial_value: "4.0"
- platform: sensor
name: Main HVAC Power
class: power
unit_of_measurement: "W"
initial_value: "1800"
- platform: sensor
name: Main HVAC Energy
class: energy
unit_of_measurement: "kWh"
linked_power: "Main HVAC Power"
initial_value: "0.0"
- Multi-Fuel Heating Support:
- Electric (
heating_type: "electric"): Heat pump or electric furnace stages drawing electrical power (Watts) onpower_sensor. - Gas (
heating_type: "gas"): Gas furnace consuming fuel (m³/hr) ongas_sensor, accumulating cumulativem³ongas_energy_sensorfor Home Assistant's native Gas Energy Dashboard, and drawing electrical blower fan power (blower_power: 120 W) onpower_sensor.
- Electric (
- Passive Insulation Leakage: The house naturally loses or gains heat toward
outdoor_sensorbased onhouse_leakage_rate. Without active heating/cooling, the house cannot drift past ambient outdoor temperature. - Precision Accumulator: Uses an unrounded internal float accumulator to prevent mathematical truncation across 10-second ticks.
- Accelerate simulation time with the
virtual.set_sim_speedservice.
Switches
Simulates standard power switches or outlets.
Coffee Maker:
- platform: switch
initial_value: 'off'
class: outlet
Binary Sensors
Simulates on/off state sensors supporting all standard Home Assistant device classes (motion, door, window, presence, smoke, moisture, occupancy, etc.).
Front Door:
- platform: binary_sensor
initial_value: 'off'
class: door
Auto-Off Timeouts & Device Gating
Binary sensors (such as motion, sound, or occupancy detectors) can automatically reset back to off after a configured duration, and optionally gate their activation to another device (such as a camera or power switch):
Front Porch Camera:
- platform: camera
name: Porch Camera
image_url: "https://images.unsplash.com/photo-1518770660439-4636190af475?auto=format&fit=crop&w=640"
- platform: binary_sensor
name: Porch Motion
class: motion
off_delay: 15 # Automatically resets back to 'off' after 15 seconds
linked_entity: Porch Camera # Can only trigger when Porch Camera is powered on
- platform: binary_sensor
name: Porch Sound
class: sound
off_delay: 5
linked_entity: Porch Camera
off_delay: Duration in seconds before the sensor automatically turns backoff. If triggered again while already active, the countdown timer resets and extends.linked_entity: Sibling entity name or entity ID (e.g.camera.porch_camera,switch.plug). The binary sensor can only turn on when the linked entity is energized/on. If the linked entity powers off while motion is active, the binary sensor immediately clears tooff.- Controllable via
virtual.turn_on(with optionaldurationoverride),virtual.turn_off, andvirtual.toggle.
Buttons
Simulates push-button trigger entities (supporting device classes identify, restart, update). When pressed, fires the virtual_button_pressed event on the Home Assistant event bus for automations.
System Controls:
- platform: button
class: restart
Controllable via the native button.press service.
Sensors
Simulates numeric or string sensor entities. Standard device classes automatically assign appropriate units (temperature -> °C, humidity -> %, power -> W, battery -> %).
Outdoor Weather:
- platform: sensor
class: temperature
initial_value: 21.5
unit_of_measurement: '°C'
Battery Drain Simulation & Low-Battery Warnings
Virtual battery sensors can simulate natural battery discharge over months with time-acceleration controls to test low-battery notifications:
Front Door Lock:
- platform: lock
name: Front Door Lock
initial_value: "locked"
# Battery Percentage Sensor with drain simulation
- platform: sensor
name: Front Door Lock Battery
class: battery
unit_of_measurement: "%"
initial_value: "100"
battery_life_days: 90 # Complete discharge over ~3 months
sim_speed: 1.0 # Speed multiplier (e.g. 1000 for rapid testing)
# Companion Low-Battery Warning Sensor
- platform: binary_sensor
name: Front Door Lock Low Battery
class: battery
linked_battery_sensor: "Front Door Lock Battery"
low_battery_threshold: 15 # Flips to 'on' (Warning) when battery <= 15%
battery_life_days: Total expected battery lifespan in days (e.g.90or180).drain_rate: Optional direct percentage drop per day (%/day).sim_speed: Time acceleration multiplier (e.g.1000to fast-forward months into minutes).linked_battery_sensor: For binary battery sensors, links to a battery percentage sensor to automatically trigger whenlevel <= low_battery_threshold(default15%).- Battery level persists across Home Assistant restarts and can be set directly via
virtual.set.
Appliance Load Simulation & Power Profiling
Virtual sensors can simulate realistic appliance loads linked to a controlling switch (e.g. Sonoff smart plugs or relay-switched water heaters). The sensor automatically drops to 0 W when the linked switch is turned off, and simulates standby vs active power draws with optional noise/jitter when the switch is energized.
Example 1: Smart Plug with TV Load
Living Room TV Outlet:
- platform: switch
name: TV Plug
class: outlet
initial_value: "on"
- platform: sensor
name: TV Power
class: power
unit_of_measurement: "W"
linked_switch: "TV Plug"
standby_power: 3.5
active_power: 140.0
initial_load: "standby"
variance: 1.5
- platform: sensor
name: TV Energy
class: energy
unit_of_measurement: "kWh"
linked_power: "TV Power" # Auto-accumulates kWh without needing HA helpers
Example 2: Water Heater with Recurring Scheduled Duty Cycle
Utility Water Heater:
- platform: switch
name: Water Heater Switch
initial_value: "on"
- platform: sensor
name: Water Heater Power
class: power
unit_of_measurement: "W"
linked_switch: "Water Heater Switch"
standby_power: 0.0
active_power: 2400.0
cycle_duration: 600 # 10 minutes active
cycle_interval: 3600 # Repeats every 1 hour
cycle_align: "hour" # Aligned to :00 on the clock
linked_switch: Name or entity ID of the switch supplying mains power.linked_power: Name or entity ID of a companion power sensor to automatically integrate Watts into accumulating kWh for Home Assistant's Energy Dashboard.standby_power: Numeric wattage when switch is energized and appliance is idling.active_power: Numeric wattage when appliance is active/running.initial_load: Initial appliance state (standby,active, oroff).variance: Optional random uniform jitter (±W) so power graphs look authentic.cycle_duration: Duration in seconds of the active load cycle.cycle_interval: Frequency in seconds for recurring cycles.cycle_align:"hour"(aligns active phase with:00past the hour) or"interval"(relative to startup).- Exposes
load_state,control_mode,cycle_active,cycle_remaining, andnext_cycle_startin attributes for automated testing in AppDaemon and automations. - Controllable via
virtual.set,virtual.set_load, andvirtual.run_cycle.
Numbers
Simulates numeric inputs and sliders with custom bounds.
Target Temperature:
- platform: number
min: 15
max: 30
initial_value: 21
class: temperature
unit_of_measurement: '°C'
Controllable via the native number.set_value service.
Selects
Simulates multi-option dropdown selectors. Ideal for home modes, states, and automation presets.
House Mode:
- platform: select
options: ["Home", "Away", "Night", "Vacation"]
initial_value: "Home"
Controllable via the native select.select_option, select.select_first, select.select_last, and select.select_next services.
Texts
Simulates text input fields with optional min/max lengths, regex validation patterns, and display mode (text or password).
Announcement:
- platform: text
initial_value: "Welcome guests!"
min: 0
max: 255
mode: text
Controllable via the native text.set_value service.
Lights
Simulates virtual lights with brightness, color temperature, and full RGB/HS color support.
Living Room Accent:
- platform: light
initial_value: 'off'
support_brightness: true
initial_brightness: 255
support_color: true
initial_color: [0, 100]
support_color_temp: true
initial_color_temp: 3000
support_effect: true
initial_effect: "none"
Controllable via native light.turn_on and light.turn_off services.
Locks
Simulates door locks with optional realistic lock movement duration and jamming tests.
Front Door Lock:
- platform: lock
initial_value: locked
locking_time: 2
jamming_test: 10
locking_time: Optional duration in seconds for the locking/unlocking transition phase.jamming_test: Positive integer; triggers a random jamming failure approximately 1 out of every X attempts.- Controllable via native
lock.lock,lock.unlock, andlock.openservices.
Cameras
Simulates security and CCTV cameras for testing dashboard Picture Entity Cards, camera proxy streaming, and live feeds.
Front Porch Camera:
- platform: camera
image_url: "https://images.unsplash.com/photo-1518770660439-4636190af475?auto=format&fit=crop&w=640"
stream_url: "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"
image_url: Optional HTTP(S) image URL or local file path (e.g./local/camera.jpgor/config/www/camera.jpg). Used by Picture Entity Cards and snapshot previews. When omitted, an embedded test placeholder image is served.stream_url: Optional stream source URL (HLS.m3u8, RTSP, or HTTP MP4). Defaults out-of-the-box to the public Mux Big Buck Bunny HLS test stream (https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8). Set tononeor empty string""to disable live streaming and operate snapshot-only.initial_value: Optional initial state (idleby default, oroff).- Controllable via native
camera.turn_onandcamera.turn_offservices, as well asvirtual.set_image_urlandvirtual.set_stream_url.
Media Players
Simulates TVs, speakers, and media players. Ideal for testing automations, volume sync, and silent TTS / announcement testing without sounding real speakers.
Living Room TV:
- platform: media_player
class: tv
initial_value: idle
initial_volume: 0.4
source_list:
- TV
- HDMI 1
- HDMI 2
- Netflix
- YouTube
sound_mode_list:
- Standard
- Cinema
- Night
class: Optional device class (tv,speaker,receiver).initial_value: Initial state (off,on,idle,playing,paused).initial_volume: Volume slider level from0.0to1.0.source_list: Optional list of selectable input sources.sound_mode_list: Optional list of selectable sound modes.- Controllable via native
media_player.turn_on,media_player.turn_off,media_player.media_play,media_player.media_pause,media_player.media_stop,media_player.volume_set,media_player.volume_mute,media_player.select_source,media_player.select_sound_mode, andmedia_player.play_mediaservices.
Fans
Simulates multi-speed, reversible, and oscillating fans.
Living Room Ceiling Fan:
- platform: fan
initial_value: 'off'
speed_count: 4
direction: true
oscillate: true
speed_count: Number of speed tiers (e.g. 4 tiers = 25%, 50%, 75%, 100%).- Controllable via native
fan.turn_on,fan.turn_off,fan.set_percentage,fan.set_direction, andfan.oscillateservices.
Covers
Simulates blinds, shutters, garage doors, and shades with realistic opening and closing travel times.
Patio Blind:
- platform: cover
initial_value: closed
class: blind
open_close_duration: 15
open_close_tick: 1
open_close_duration: Travel time in seconds from fully open to fully closed.open_close_tick: Time interval in seconds between simulated position update events.- Controllable via native
cover.open_cover,cover.close_cover,cover.stop_cover, andcover.set_cover_positionservices.
Valves
Simulates water and gas valves with travel durations and position reporting.
Garden Irrigation Valve:
- platform: valve
initial_value: closed
class: water
open_close_duration: 5
open_close_tick: 1
Controllable via native valve.open_valve, valve.close_valve, valve.stop_valve, and valve.set_valve_position services.
Device Trackers
Simulates GPS coordinates or named zones for presence testing.
Family Member:
- platform: device_tracker
initial_value: home
Controllable via the virtual.move service.
Legacy YAML Configuration
For backward compatibility with older configurations, you can continue managing entities directly under platform keys in configuration.yaml by setting:
virtual:
yaml_config: true
When yaml_config: false (the default), Home Assistant automatically uses the modern Config Flow and virtual.yaml device files.
Services
The integration provides the following custom services:
virtual.set_available
Sets the availability state of any virtual entity.
- Target: Any virtual entity
- Fields:
value: Boolean (trueorfalse)
virtual.turn_on
Turns on a virtual binary sensor, with an optional duration parameter to pulse the sensor for a specific number of seconds before resetting to off.
- Target: Virtual binary sensor entities
- Fields:
duration: Optional seconds to stay on before resetting to off (overrides defaultoff_delay).
virtual.turn_off
Turns off a virtual binary sensor.
- Target: Virtual binary sensor entities
virtual.toggle
Toggles a virtual binary sensor.
- Target: Virtual binary sensor entities
virtual.set
Sets the state value of a virtual sensor.
- Target: Virtual sensor entities
- Fields:
value: String or number representing the new sensor value.
virtual.move
Moves a virtual device tracker to a new zone or GPS coordinates.
- Target: Virtual device tracker entities
- Fields:
location: Named zone or location string (e.g.home,work,away).gps: Object containinglatitudeandlongitude.gps_accuracy: Optional accuracy radius in meters.
virtual.set_current_temperature
Sets the current ambient temperature of a virtual climate entity.
- Target: Virtual climate entities
- Fields:
temperature: Number representing the new ambient room temperature (e.g.19.5).
virtual.set_image_url
Sets the still image URL or local file path for a virtual camera.
- Target: Virtual camera entities
- Fields:
image_url: HTTP(S) URL or local path to the still snapshot image.
virtual.set_stream_url
Sets the live stream URL for a virtual camera.
- Target: Virtual camera entities
- Fields:
stream_url: HLS, RTSP, or HTTP stream URL (or""/noneto disable streaming).
virtual.set_load
Sets the load state (active, standby, off, or auto to resume scheduled duty cycles) or injects custom power into an appliance power sensor.
- Target: Virtual power sensor entities
- Fields:
state: Operating state (active,standby,off,auto).power: Optional wattage override.
virtual.run_cycle
Triggers an active appliance load cycle for a specified duration (in seconds), after which the sensor automatically returns to standby or resumes its background schedule.
- Target: Virtual power sensor entities
- Fields:
duration: Run duration in seconds (optional; defaults tocycle_duration).
virtual.set_sim_speed
Sets the simulation speed multiplier for a virtual climate entity with thermal modeling.
- Target: Virtual climate entities
- Fields:
speed: Float multiplier (e.g.1.0for real-time,10.0for 10x speed).
virtual.set_light
Sets brightness, color (HS), color temperature (Kelvin), or effect on a virtual light without altering its on/off power state.
Ideal for circadian lighting, sleep modes, and nighttime automations that pre-stage brightness and warm amber color while lights are off, so they turn on at the desired level without blinding flashes. (Attribution: @Perlmint / PR #182).
- Target: Virtual light entities
- Fields:
brightness: Integer brightness level (0–255).hs_color: Color as[hue (0-360), saturation (0-100)].color_temp_kelvin: Color temperature in Kelvin (2000–6535).effect: Effect name fromeffect_list.
virtual.set_battery_soc
Manually sets the battery State of Charge percentage (0–100%) for a virtual energy hub / solar inverter simulation.
- Target: Virtual integration
- Fields:
value: Target battery SoC percentage (0–100).name: Optional simulation name if multiple are configured.
virtual.set_solar_power
Manually sets solar generation wattage (e.g. 7500), or set to auto to resume the natural sun diurnal curve.
- Target: Virtual integration
- Fields:
value: Numeric wattage string orauto.name: Optional simulation name if multiple are configured.
Ähnliche Projekte entdecken
Wird geladen…