title: Why Scene(Action-Set) added to Home(HMHome) always have updated Characteristic's(HMCharacteristic) values :HomeKit
body: <p>I am working on a Demo iOS application based on HomeKit API's.</p>
  
  <p>I have created Scene(Actions-Set) AS1 for Particular Home(H1) with some services(S1 S2...) to perform multiple action in a go.
  I can create multiple scene without any problems, but I am facing problem in updating the any of created scene</p>
  
  <p>Flow of My Application</p>
  
  <ul>
  <li>Show Added Home(ListView)</li>
  <li>Click on Any Home, detail screen appears With few Options(Accessory A1 ,Room A2  ,Scene A3....)</li>
  <li>Clicking on A1 Add the Accessory(can change the characteristic of added Accessory's service from here)</li>
  <li>A3 has a list of added Scene (Action-Set) as well a button to add new Scene (Action-Set) to current Home</li>
  <li>User can Click on any added Scene(ActionSet) to update its actions and name both</li>
  </ul>
  
  <p><strong>Problem :</strong> Once I changed the characteristic of services from Accessory A1 option then characteristics added to Scene's action gets updated to the same value.</p>
  
  <p><strong>My Assumption:</strong> I was thinking each created Scene (Action-Set) maintain its own characteristics's value separately and if user modify characteristics of any service from accessory A1(from somewhere else) then it should not affect the value of actions added to saved Scene(pre-condition - user picked that accessory in created Scene's action)</p>
  
  <p><strong>My Approach to Update Action-Set(Scene) as,</strong></p>
  
  <ul>
  <li>Once user click on any added Action-Set services list appear where user can click on any services to updated its characteristic</li>
  <li>Access Actions of current Action-Set</li>
  <li>Access characteristic of each action( HMCharacteristicWriteAction)
  Access service of characteristic</li>
  <li>Create instance  of CustomServices(to keep track of some other info like user included that service to into current action set etc.)  and add it to Data-source and avoid repetition</li>
  <li>Once user done with value change and click on update actions button</li>
  <li>Start the Update process</li>
  </ul>
  
  <p><strong>Update Scene (action-set)</strong></p>
  
  <p><strong>1.Check if User changed the name of Action-set,</strong></p>
  
  <ul>
  <li>Then update the name of action set first, once success block executed delete all past added actions if exist.</li>
  <li>Add new actions to updated scene.</li>
  </ul>
  
  <p><strong>2.If Scene(action-set) name is same as Old Name,</strong></p>
  
  <ul>
  <li>Delete all previous actions if exist.</li>
  <li>Add new actions to updated scene.</li>
  </ul>
  
  <p>Here is the code snippet(prepare datasource) which is use to populate services listView</p>
  
  <pre><code>func prepareDataSource(){
  
  var actionsArray = NSArray(array: 
  self.currentScene!.actions.allObjects)
  
      for (var index = 0 ; index&lt;actionsArray.count; index++ ){
  
          var sWritttenAction:HMCharacteristicWriteAction? = actionsArray[index] as? HMCharacteristicWriteAction
  
          if let sActionCharacteristic = sWritttenAction!.characteristic{
  
              var accessoryService = sActionCharacteristic.service as HMService
  
              if(!isServiceAlraedyAdded(accessoryService.name)){
                  var sceneService = DMIAccessoryService.initWithService(accessoryService)
                  sceneService.isSelected = true
                  //Add Services
                  self.services.append(sceneService)
                  self.addedServices.append(sceneService)
                  println("its a diffrent service")
              }
              else
              {
                  println("Already has the same service")
              }
          }
      }
  }
  </code></pre>
  
  <p>I have gone through the HomeKit documentation many times but found nothing related to this issue.</p>
  
  <p>As far as I understand the action-set's concept it should maintained characteristics value separately so that we could change it's actions values later on.</p>
  
  <p>I have been facing the this problem since last couple of days(<a href="https://stackoverflow.com/questions/27918567/why-action-set-added-to-home-always-have-services-with-current-updated-character">because couple of days back posted the same problem here</a>) and Now I am sure it is a bug in apple home api because once I try to re-execute the same action set( pre-condition: services characteristic's value changed by user from A1 option).It is executed successfully and update the all those accessories which have the same characteristics similar to created Scene (ActionSet).</p>
  
  <p>Please anybody who has found similar issue with update Scene(ActionSet) help me out.
  If my approach is wrong, Please feel free to point me.</p>