Code Examples
Ready-to-use code snippets and sample projects to connect Sanytron interfaces with Home Assistant, RosCard, MQTT, and the Sanytron REST API.
REST API Examples
Trigger a Scene
Activate "Movie Night" on your Astrion from any HTTP client.
curl -X POST https://api.sanytron.com/v1/scenes/movie_night/trigger \ -H "Authorization: Bearer YOUR_API_KEY"
Get Device State
Query the current state of any connected device.
curl https://api.sanytron.com/v1/devices/living_room_light \ -H "Authorization: Bearer YOUR_API_KEY"
List All Automations
Retrieve all configured automations across your ecosystem.
curl https://api.sanytron.com/v1/automations \ -H "Authorization: Bearer YOUR_API_KEY"
Home Assistant Integration
Map Astrion Button to HA Script
Map a physical button press to call a Home Assistant service.
// In RosCard dashboard configuration
{
"button": "btn_1",
"action": "call_service",
"service": "script.movie_mode",
"entity_id": "script.movie_mode"
}
MQTT Automation Bridge
Forward Astrion events to MQTT for custom integrations.
# In Home Assistant configuration.yaml
mqtt:
broker: localhost
automation:
- trigger:
platform: mqtt
topic: "astrion/button/btn_1"
action:
service: light.toggle
target:
entity_id: light.living_room
RosCard Templates
Simple Dashboard Card
A minimal RosCard template for displaying temperature and humidity.
{
"type": "custom:roscard",
"title": "Living Room",
"entities": [
"sensor.temperature",
"sensor.humidity"
]
}
Scene Control Card
A multi-button card for triggering common scenes.
{
"type": "custom:roscard",
"title": "Scenes",
"buttons": [
{"name": "Movie", "scene": "movie_night"},
{"name": "Reading", "scene": "reading"},
{"name": "Away", "scene": "away_mode"}
]
}